Open ver1nty opened 2 years ago
is there a workaround?
This is also a problem for us. The only workaround I can see is to load the story with the default slug and then extract the translated slug – if it's even there. Seems like too much overhead. Any idea when this can be fixed?
I actually found a usable workaround:
Using resolve_links: 'url'
when querying the content will include more information about the story that the link points to, including the full_slug
with the correct translated slug!
This is how we are solving it for now:
export function getUrlFromLinkObject(link: MultilinkStoryblok | undefined) {
if(!link) return '';
if (link.linktype === 'story') {
if (link.story?.full_slug) {
return '/' + link.story.full_slug;
} else {
return link.cached_url;
}
}
return link.url;
}
The issue occurs while working with: (check one with "x")
Current behavior: When fetching a Link object of a different language than the default one through the API (both REST and GraphQL), the slug of the returned object is not translated but the default language. It contains the language prefix, but the slug parts are of the default language. Ex.:
es/slug-part-1-in-english/slug-part-2-in-english
Meanwhile, if we fetch a Paragraph object that contains a link, it returns the translated slug. Ex.:
es/slug-part-1-in-spanish/slug-part-2-in-spanish
Expected behavior: The returned Link object of a different language than the default one should contain the translated slug. Just as the Paragraph object behaves.
Steps to reproduce: