nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.75k stars 483 forks source link

Custom Route Paths Bug with dynamic Sub-Paths #3035

Closed danbaechtold closed 3 months ago

danbaechtold commented 4 months ago

Environment

Stackblitz (Reproduction starter (v8 and higher))

Reproduction

https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-qr67sy

Describe the bug

Having this config:

customRoutes: 'config',
pages: {
  tours: {
    en: '/trails-en',
    nl: '/trails-nl',
  },
  'tours/[provider]': {
    en: '/trails-en/[provider]',
    nl: '/trails-nl/[provider]',
  },
  'tours/[provider]/[slug]': {
    en: '/trails-en/[provider]/[slug]',
    nl: '/trails-nl/[provider]/[slug]',
  },
}

And these pages:

pages/
├─ tours/
├─── [provider]/
├───── [slug].vue
├───── index.vue
├─── index.vue

I get the following results:

Additional context

No response

Logs

No response

danbaechtold commented 3 months ago

My bad, I've made a mistake in the pages configuration:

The ../index was missing in the pages key.

This is the correct configuration:

customRoutes: 'config',
pages: {
  'tours/index': {
    en: '/trails-en',
    nl: '/trails-nl',
  },
  'tours/[provider]/index': {
    en: '/trails-en/[provider]',
    nl: '/trails-nl/[provider]',
  },
  'tours/[provider]/[slug]': {
    en: '/trails-en/[provider]/[slug]',
    nl: '/trails-nl/[provider]/[slug]',
  },
}
denFete commented 1 month ago

@danbaechtold You saved my day, thanks! Couldn't find any docs with that folder structure