Closed madebyfabian closed 3 years ago
Or - maybe even better - with a *
glob value in the options.routes section, so that you can specify it even more detailled.
On the other hand, you can precisely control priorities using filter function.
Without i18n:
sitemap: {
filter({ routes }) {
return routes.map(route => {
// object containing [routeName]: [priority] pairs
const priorities: = {
index: 1,
about: 0.6,
}
// assign priority by route name or default (.5)
return { ...route, priority: priorities[route.name] || 0.5 }
})
},
}
With i18n:
sitemap: {
i18n: true,
filter({ routes }) {
return routes.map(route => {
const routeName = route.name.replace(/___.{0,}/, '') // remove i18n locale suffix
// object containing [routeName]: [priority] pairs
const priorities = {
index: 1,
about: 0.6,
}
// assign priority by route name without locale suffix or default (.5)
return { ...route, priority: priorities[routeName] || 0.5 }
})
},
}
@themeler Thanks for pointing this out! This does work great! Haven't found this in the docs, but here is it: https://sitemap.nuxtjs.org/usage/sitemap-options#filter-optional---function
I'll close this issue now, thanks again.
What problem does this feature solve?
Hello there, I thought of something that I think many users of this package would appreciate. I ran into this issue today.
What's the current problem?
If I use the sitemap package and configure it as following:
all my pages don't have a
<priority>
entry in the sitemap.xml. If I do:all pages get the priority 1, which is not the point of a priority itsself. What I could do now is to define every subpage myself and set the priority to something like 0.80. But then the whole point of the plugin is gone, since I could also just write & update the sitemap.xml myself.
What does the proposed changes look like?
What would be the solution
Maybe to add a config param like
prioritySubpages
that sets the priority of all subpages to a specific value. So this:would be parsed into: