studiocms
Version:
Astro Native CMS for AstroDB. Built from the ground up by the Astro community.
22 lines (21 loc) • 639 B
JavaScript
import { sitemaps } from "virtual:studiocms/sitemaps";
const template = (entries) => `<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${entries.map((entry) => `<sitemap><loc>${entry.location}</loc></sitemap>`).join("")}
</sitemapindex>`;
const GET = async (context) => {
const CurrentUrl = context.url;
const sitemap = template(
sitemaps.map((sitemap2) => ({ location: new URL(sitemap2, CurrentUrl).toString() }))
);
return new Response(sitemap, {
status: 200,
headers: {
"Content-Type": "application/xml"
}
});
};
export {
GET,
template
};