Open olets opened 3 years ago
PS furthermore my expectation is that filter()
in each sitemap would operate on the modified routes. I think the above is the only piece missing, but I suppose there could be a solution for the routes without filtering that doesn't still work with filtering:
sitemap: {
hostname: 'multiple',
sitemaps: [
{
hostname: 'https://myhost1.com',
path: '/sitemap1.xml',
filter ({ routes }) {
return routes.filter(r => sitemap1Filter(r))
},
},
{
hostname: 'https://myhost2.com',
path: '/sitemap2.xml',
filter ({ routes }) {
return routes.filter(r => sitemap2Filter(r))
},
}
],
}
would in my expectation use the generator-modified routes
.
Create an example repo:
Working with single sitemap https://github.com/olets/nuxt-sitemap-generator-issue-demos/tree/nuxt-community/sitemap-module/issues/214/single-sitemap
Not working with multiple sitemaps https://github.com/olets/nuxt-sitemap-generator-issue-demos/tree/nuxt-community/sitemap-module/issues/214/multiple-sitemaps
Clone, yarn
, yarn generate
Expectation
If I hook into
generate
to changesitemap.routes
, those changes are reflected in the sitemaps generated by the module.Actual
If I hook into
generate
to changesitemap.routes
, those changes are reflected in the sitemap-module output if the module is configured to output a single sitemap but not if the module is configured to output multiple sitemaps.Details
I'm hooking into
generate
to add generated routes to the sitemaproutes
. Essentially:(h/t https://dev.to/andynoir/sitemap-for-dynamic-routes-in-nuxtjs-4b96 for the general idea)
That works with a single sitemap:
The
sitemap.xml
generated when I runyarn generate
reflects theroutes
as set in the generator.But it doesn't work with multiple sitemaps:
The
sitemap1.xml
andsitemap2.xml
generated when I runyarn generate
are the same as they would be if I removed my custom generator.