Created
February 28, 2021 12:53
-
-
Save MaikelVeen/c4aff09605d1088ef1c2806e09c1e4d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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