next-drupal icon indicating copy to clipboard operation
next-drupal copied to clipboard

Path translation in Umami demo does not follow getPathsFromContext or buildPathsFromResources and got a 404 error

Open jeyram opened this issue 3 years ago • 0 comments

Hi, I've found an issue with the path's translation. Drupal set both [node:title] languages, but when I switch between them in the Next SSR, it doesn't find the "/en/[node:source:title]-Spanish path" and generates a 404.

The problem is also present in your demo site (https://demo.next-drupal.org/es/recipes/bizcochos-veganos-de-chocolate-y-nueces) as shown below issue-umami-demo

I'm a noob in Next.js but I think this is related to the way the locale-switcher component is created.

I'm trying something related to this answer:

Maybe we can check node for system field "content_translations" somewhere in getPathsFromContext or buildPathsFromResources and return only such path which is exist in both nextjs and drupal locales?

We could. I'll look into it.

For now, I think what you could do is use two different calls for paths.

const pathsWithLocale = await getPathsFromContext("node--product", context)
const pathsWithoutLocale = await getPathsFromContext("node--blog", {})

const paths = [
    ...pathsWithLocale,
    ...pathsWIthoutLocale,
]

Can you give this a try and let me know?

Originally posted by @shadcn in https://github.com/chapter-three/next-drupal/issues/147#issuecomment-1098144089

jeyram avatar Aug 12 '22 19:08 jeyram