Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.

Commit 102ae5a

Browse files
author
lisilinhart
authored
Merge pull request #647 from storyblok/fix/translated-slugs
fix: Translated Slugs sync
2 parents 48f6edf + cf55083 commit 102ae5a

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/tasks/sync.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,25 @@ const SyncSpaces = {
6666
story: sourceStory,
6767
force_update: '1'
6868
}
69+
if (sourceStory.translated_slugs) {
70+
const sourceTranslatedSlugs = sourceStory.translated_slugs.map(s => {
71+
delete s.id
72+
return s
73+
})
74+
if (existingStory.data.stories.length === 1) {
75+
const storyData = await this.client.get('spaces/' + this.targetSpaceId + '/stories/' + existingStory.data.stories[0].id)
76+
if (storyData.data.story && storyData.data.story.translated_slugs) {
77+
const targetTranslatedSlugs = storyData.data.story.translated_slugs
78+
sourceTranslatedSlugs.forEach(translation => {
79+
if (targetTranslatedSlugs.find(t => t.lang === translation.lang)) {
80+
translation.id = targetTranslatedSlugs.find(t => t.lang === translation.lang).id
81+
}
82+
})
83+
}
84+
}
85+
payload.story.translated_slugs_attributes = sourceTranslatedSlugs
86+
delete payload.story.translated_slugs
87+
}
6988
if (sourceStory.published) {
7089
payload.publish = '1'
7190
}

0 commit comments

Comments
 (0)