Hey,
I’m using multiple domains for my single Meteor application. Now I need to generate individual sitemaps for each of this domains, I’m using here gadicohen:sitemaps
I think the best way to achieve this would be by changing one line in the gadicohen:sitemaps library. You would just need to change line 67 of the sitemaps.js file from:
pages = pages();
to
pages = pages(req);
I’d suggest opening a PR with this change (or cloning the package and making the change in your local code). Once this is in place the incoming request will then be available in the sitemaps.add function, and you can use it to toggle your URLs dynamically. For example:
sitemaps.add('/sitemap.xml', function sitemaps(req) {
let host = Meteor.absoluteUrl();
if (req && req.headers && req.headers.host) {
host = `http://${req.headers.host}/`;
}
return [
{ page: `${host}page1`, lastmod: new Date() },
{ page: `${host}page2`, lastmod: new Date() }
];
});