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

Options for static routes #15

Closed
delucis opened this issue Feb 17, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@delucis
Copy link
Contributor

commented Feb 17, 2018

Hi, thanks for your work on this module!

When passing dynamic routes, setting extra options is possible, e.g.

routes: [
  { url: '/dynamic/1', changefreq: 'daily', priority: 1 /* etc. */ }
]

But for “static” routes, there doesn’t seem to be any way to pass such options.

If I add a static route to the routes option, it gets duplicated because static and dynamic routes are merged using lodash’s union(). It ends up comparing, e.g. '/route' with { url: '/route', changefreq: 'daily' }, which aren’t equal so both are included.

Is there a solution? If not, perhaps the following might make sense:

  1. Improve the merge strategy in the createCache() method to avoid such duplicates. This would allow overriding static routes by adding them to the routes option.

  2. Allow for a default set of route options to be set, which are applied to static routes (or all routes?)

// maybe something like this?
sitemap: {
  routeDefaults: {
    changefreq: 'daily'
  },
  routes: [ '/foo', '/bar' ]
}
// would be equivalent to, with routeDefaults also applying to static routes
sitemap: {
  routes: [
    { url: '/foo', changefreq: 'daily' },
    { url: '/bar', changefreq: 'daily' }
  ]
}

Any thoughts? I might have misread index.js, so maybe another solution would be better. Would be happy to work on a solution if there’s interest.

This feature request is available on Nuxt.js community (#c10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.