Skip to content

Instantly share code, notes, and snippets.

@mike-casas
Created March 19, 2021 17:40
Show Gist options
  • Save mike-casas/22d11e63052892cf99f80702f6739d21 to your computer and use it in GitHub Desktop.
Save mike-casas/22d11e63052892cf99f80702f6739d21 to your computer and use it in GitHub Desktop.
sitemap diff
const Sitemapper = require('sitemapper');
(async () => {
const sitemap = new Sitemapper();
const oldSiteMapXml = await sitemap.fetch(
'https://auth0.com/blog/sitemap.xml',
);
const newSiteMapXml = await sitemap.fetch(
'http://localhost:3000/blog/sitemap.xml',
);
const intersection = oldSiteMapXml.sites.filter((x) =>
newSiteMapXml.sites.includes(x),
);
const diff = oldSiteMapXml.sites.filter(
(x) => !newSiteMapXml.sites.includes(x),
);
console.log(`New Sitemap ${newSiteMapXml.sites.length}`);
console.log(`Old Sitemap ${oldSiteMapXml.sites.length}`);
console.log(`Sitemap intersection ${intersection.length}`);
console.log(`Sitemap diff ${diff.length}`);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment