diff --git a/src/pages/sitemap.xml.ts b/src/pages/sitemap.xml.ts new file mode 100644 index 0000000..e86cf4e --- /dev/null +++ b/src/pages/sitemap.xml.ts @@ -0,0 +1,23 @@ +import type { APIContext } from 'astro' +import { getCollection } from 'astro:content' + + +export async function GET(context: APIContext) { + const notes = await getCollection('notes') + + let sitemap = ` + + ${context.site} + ${context.site}services + ${context.site}cinema` + + notes.forEach(note => { + sitemap += `${context.site}notes/${note.slug}` + }) + + sitemap += '' + + const resp = new Response(sitemap) + resp.headers.set("Content-Type", "application/xml") + return resp +}