Dynamic routes in pages subdirectory not working #3081
Unanswered
d-kirkland
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi. I posted this in issues a few days ago, but I haven't received any guidance. So I am trying here. I would be most appreciative of any advice.
I have a problem with dynamic links in subfolders in the pages directory. I have gone through the documentation a number of times, and I have not been able to solve this, so I am posting the question here.
I have a repository with the problem here: https://github.com/d-kirkland/i18n-dynamic-link-problem
The problem: I have a link on the index.vue page that should direct to pages/customers/challenges/[slug].vue. I have set up the routes like so:
And the link looks like this:
<NuxtLink :to="localePath({ name: 'customers-challenges-slug', params: { slug: currentRoute }})"> {{ t('links.challenge') }} </NuxtLink>
The problem is that when I click on the link when I am the EN locale, I am directed to /en/customers/challenges/food. That is not a problem, but when I click on the link in the DE locale, I am directed to /de/customers/challenges/lebensmittel. This is where the problem is. I would expect the link in the DE locale to link to /de/kunden/challenges/lebensmittel. NuxtLink/localePath is picking up the slug, but it is not getting the route correct. I have provided all of the content of the files, and the link to the repository is above. Is there something that I am doing wrong?
Here is the index.vue page:
I am pulling the data in from a headless CMS, so the source object is meant as a substitute from data from the CMS.
There is then a pages/customers/challenges/[slug].vue page that looks like this:
Then the nuxt.config.ts file:
And then the locales/routes/index.js file:
package.json:
Beta Was this translation helpful? Give feedback.
All reactions