Get routes config in routes function

commented a year ago

What problem does this feature solve?

We are using named dynamic routes (path can change, but name doesn't, so all occurences of path in app are changed automaticly). Now we use api to generate dynamic routes, but can't access actual router config, so we can only staticly add this routes.. but when path changed, we need to change sitemap routes too. It will be great if we can use named routes and change only path and sitemap will still work without change

What does the proposed changes look like?

there will be router config in router parameter (probably second, so callback is still usable)


there will be some this in router function where we can access router config

commented 10 months ago

Hi @padinko

I'm not sure to understand your request, but have you take a look to the filter feature?

It's a function that allow to filter or update the routes just before sitemap generation. On the routes parameter, you can find the name or path of each route, and thus update them dynamically.

Let me know if enough for your need.

eg. config.nuxt.js

  sitemap: [
      filter ({ routes }) {
        return routes


console output

    name: 'index',
    path: '/',
    component: '/Users/user/project/pages/index.vue',
    chunkName: 'pages/index',
    url: '/'
Feature RequestOpen
#c83 - Created a year ago