Get routes config in routes function

padinko
5
padinko
commented 2 months 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)

-or-

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

idea
0
NicoPennec
1.7k
NicoPennec
commented 16 days 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 }) {
        console.log(routes)
        return routes
      }
    }
  ]

`

console output
```
{
name: 'index',
path: '/',
component: '/Users/user/project/pages/index.vue',
chunkName: 'pages/index',
url: '/'
},

0
Informations
Feature RequestOpen
#c83 - Created 2 months ago