storyblok / storyblok-js-client

Universal JavaScript client for Storyblok's API
MIT License
124 stars 85 forks source link

Translated slugs for linked stories are not replaced in the link object properly leaving non translated slugs in the rendered DOM #554

Closed SebbeJohansson closed 15 hours ago

SebbeJohansson commented 1 year ago

When linking to a translated page from another page, we see a behaviour where the non translated slug is what is returned in the link object, despite the translated slug being present in the links object and in the story object within the link object.

Expected Behavior

We expect that the proper slug is presented in the link object so that we can always trust the link inside of the same place.

Current Behavior

The wrong slug is presented.

How it looks in the story object coming from the storyApi.get() method: image

Steps to Reproduce

  1. Connect two stories together by linking from one of them to the other.
  2. Go to the story that is linked from.
  3. Check the returned link.

Suggested solutions

SebbeJohansson commented 1 year ago

After upgrading to lastest this is also now not working with story resolve relations.

ademarCardoso commented 1 year ago

After upgrading to lastest this is also now not working with story resolve relations.

One question, is this problem in resolve relations only with many stories? for example with more than 25 ?

SebbeJohansson commented 1 year ago

@ademarCardoso Hi! Nope this problem exists with any number of them. This seems to only happen in our big nuxt2 application and only on the server. The weirdest part of this is that it is working in a server side middleware.

I have tried to reproduce this in a stackblitz but haven't been able to. Here is my attempt: https://stackblitz.com/edit/nuxt-2-sdk-demo-mbnbsu?file=package.json

I have been talking to @alvarosabu and @Dawntraoz about this on discord (cant remember if you were involved there or not, but i don't think so). Also had a ball with Alvaro where we couldn't reproduce it, but verified that this issue is present in the big application.

As a workaround we are trying to make an edge function in Fastly to handle all our storyblok requests. The reason initially for this was to cache and obscure our fetching, but now this will be another reason to do it.

sumerokr commented 1 year ago

One of the biggest pain points in Storyblok is how to resolve translated links. This is such a baseline feature, but mostly broken. See https://github.com/storyblok/storyblok/issues/694, https://github.com/storyblok/storyblok/issues/812, https://github.com/storyblok/storyblok/issues/884, https://github.com/storyblok/storyblok/issues/728 that are open for months and even years. You want to have a "Link" field that links to another page? Sure you can, but without a "name" field at all (page title). And when you try to solve it using "resolve_links" thing, "name" (page title) property is there, but not translated. Such a bad joke.

SebbeJohansson commented 1 year ago

For me specifically this is happening inside a nuxt2 project and I am still not able to reproduce it in a different nuxt2 project.

bezrodnow commented 3 months ago

Has anyone found a solution or workaround for this issue so far? I am currently stuck on this as well.

SebbeJohansson commented 3 months ago

@bezrodnow Nope as far as i can tell this is still an issue.

alvarosabu commented 3 weeks ago

Hi all, I need a minimal reproduction to properly triage this issue internally.

Thanks

SebbeJohansson commented 3 weeks ago

Hi. Tried again, but wasn't able to make a minimal reproduction version. Sorry.