next-drupal
next-drupal copied to clipboard
Path translation in Umami demo does not follow getPathsFromContext or buildPathsFromResources and got a 404 error
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

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