You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. 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:
'customer/challenges/[slug]': {
en: '/customers/challenges/[slug]',
de: '/kunden/challenges/[slug]',
},
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?
The issue in your reproduction appears to be that you're not using the route names in the pages configuration object, so the custom route paths are not applied.
const pages = {
'index': {
en: '/',
de: '/',
},
// use route name
- 'customer/challenges/index': {+ 'customers-challenges': {
en: '/customers/challenges',
de: '/kunden/challenges',
},
// use route name
- 'customer-challenges-slug': {+ 'customers-challenges-slug': {
en: '/customers/challenges/[slug]',
de: '/kunden/challenges/[slug]',
},
}
export default pages;
Sorry for the late response! Perhaps you already resolved this issue on your own, but if you have any questions let me know and I'll reopen this issue 🙏
Hi. 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:
The text was updated successfully, but these errors were encountered: