Exclude i18n routes

altynbek07
0
altynbek07
commented a month ago

Module version
@nuxtjs/[email protected]

Describe the bug
Is there an elegant way to exclude i18n routes?

To Reproduce
Now it works like this for me:
In file nuxt.config.js:

...
modules: [
    ['@nuxtjs/sitemap', {
      exclude: [
        '/cart',
        '/en/cart',
        '/kk/cart',

        '/checkout/**',
        '/en/checkout/**',
        '/kk/checkout/**',
      ],
      ...
    }]
  ],
buildModules: [
    ['nuxt-i18n',
      {
        locales: [
          { code: 'ru', name: "Русский", file: 'ru.js' },
          { code: 'kk', name: "Қазақша", file: 'kk.js' },
          { code: 'en', name: "English", file: 'en.js' }
        ],
        defaultLocale: 'ru',
      }
    ],
    ...
  ],
...

Expected behavior
I would like something like this:
In file nuxt.config.js:

...
modules: [
    ['@nuxtjs/sitemap', {
      exclude: [
        '/cart',
        '/:lang/cart',

        '/checkout/**',
        '/:lang/checkout/**',
      ],
      ...
    }]
  ],
...
0
NicoPennec
2.0k
NicoPennec
commented a month ago

Instead the "exclude" option, you can use the filter option with the latest version of the module:

      filter: ({ routes }) => routes.filter(({ name }) => name.split('___')[1] === 'ru'),
0
Informations
QuestionUnresolved
#c93 - Created a month ago