Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get routes config in routes function #107

Closed
padinko opened this issue Feb 25, 2020 · 1 comment
Closed

Get routes config in routes function #107

padinko opened this issue Feb 25, 2020 · 1 comment

Comments

@padinko
Copy link

padinko commented Feb 25, 2020

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

This feature request is available on Nuxt community (#c83)
@ghost ghost added the cmty:feature-request label Feb 25, 2020
@NicoPennec
Copy link
Member

NicoPennec commented Mar 24, 2020

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: '/'
  },
 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants