Skip to content

Instantly share code, notes, and snippets.

@MaikelVeen
Created February 28, 2021 12:53
Show Gist options
  • Save MaikelVeen/c4aff09605d1088ef1c2806e09c1e4d7 to your computer and use it in GitHub Desktop.
Save MaikelVeen/c4aff09605d1088ef1c2806e09c1e4d7 to your computer and use it in GitHub Desktop.
const GetUrlElement = ({ host, route, date }: Url): string => {
if (date) {
return `<url><loc>${host}${route}</loc><lastmod>${date}</lastmod></url>`;
} else return `<url><loc>${host}${route}</loc></url>`;
};
const GetSitemapXml = (urls: Array<Url>): string => `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${urls.map((url) => GetUrlElement(url)).join('')}
</urlset>`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment