Skip to content

Commit

Permalink
feat: Add the version information to the routes during sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobefu committed Jan 16, 2025
1 parent 607a7cf commit 644a061
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/cs_sdk/functions/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func addAllAssets(data map[string]interface{}) error {
Locale: publishDetails["locale"].(string),
Url: assetData["url"].(string),
Parent: parentUid,
Version: int(assetData["_version"].(float64)),
Version: getVersion(assetData),
Filesize: filesize,
Height: assetHeight,
Width: assetWidth,
Expand Down Expand Up @@ -243,6 +243,7 @@ func addSyncRoutes(data map[string]interface{}, routes *map[string]structs.Route
locale := publishDetails["locale"].(string)
slug := getSlug(data)
parent := getParentUid(data)
version := getVersion(data)
updatedAt := getUpdatedAt(data)
excludeSitemap := getExcludeSitemap(data)
isPublished := hasPublishDetails
Expand All @@ -258,6 +259,7 @@ func addSyncRoutes(data map[string]interface{}, routes *map[string]structs.Route
Slug: slug,
Url: slug,
Parent: parent,
Version: version,
UpdatedAt: updatedAt,
ExcludeSitemap: excludeSitemap,
Published: isPublished,
Expand Down Expand Up @@ -418,6 +420,16 @@ func getParentUid(data map[string]interface{}) string {
return parentUid
}

func getVersion(data map[string]interface{}) int {
version, hasVersion := data["_version"]

if !hasVersion {
return 0
}

return int(version.(float64))
}

func getAssetDimensions(asset map[string]interface{}) (int, int) {
dimension, hasDimension := asset["dimension"].(map[string]interface{})

Expand Down Expand Up @@ -485,6 +497,7 @@ func processSyncData(routes map[string]structs.Route) error {
Slug: route.Slug,
Url: url,
Parent: route.Parent,
Version: route.Version,
UpdatedAt: route.UpdatedAt,
ExcludeSitemap: route.ExcludeSitemap,
Published: route.Published,
Expand Down

0 comments on commit 644a061

Please sign in to comment.