fixtures: drop @cleverbeagle/seeder (sync Mongo, unmaintained) for a small idempotent async seeder (same dev accounts). sitemaps: drop dead gadicohen:sitemaps for a WebApp.connectHandlers /sitemap.xml with the same static page list (the per-fire section was already disabled). Verified on dev boot: 6 users ensured, sitemap serving; REST smoke byte-identical.
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
/* eslint-disable import/no-absolute-path */
|
|
import { Meteor } from 'meteor/meteor';
|
|
import { WebApp } from 'meteor/webapp';
|
|
|
|
/*
|
|
* /sitemap.xml — own implementation replacing gadicohen:sitemaps (pre-0.9
|
|
* package API, dead on Meteor 3). Static pages only: the per-fire section of
|
|
* the old handler was behind `firesMapEnabled = false` (dead code) and was
|
|
* dropped; see git history if it's ever wanted back.
|
|
*/
|
|
|
|
const PAGES = [
|
|
'/fires',
|
|
'/login',
|
|
'/signup',
|
|
'/recover-password',
|
|
'/credits',
|
|
'/terms',
|
|
'/license',
|
|
'/privacy',
|
|
'/about'
|
|
];
|
|
|
|
function xmlEscape(s) {
|
|
return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
}
|
|
|
|
WebApp.connectHandlers.use('/sitemap.xml', (req, res) => {
|
|
const lastmod = new Date().toISOString().slice(0, 10);
|
|
const urls = PAGES.map((page) => {
|
|
const loc = xmlEscape(Meteor.absoluteUrl(page.replace(/^\//, '')));
|
|
return ` <url>\n <loc>${loc}</loc>\n <lastmod>${lastmod}</lastmod>\n </url>`;
|
|
}).join('\n');
|
|
const body = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls}\n</urlset>\n`;
|
|
res.writeHead(200, { 'Content-Type': 'application/xml; charset=utf-8' });
|
|
res.end(body);
|
|
});
|