Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

sitemap.xml.ts

16 lines529 Bytes

1import type { APIRoute } from "astro";
2​
3import { absoluteUrl, STATIC_PAGES } from "../lib/seo";
4​
5export const GET: APIRoute = () => {
6 const urls = STATIC_PAGES.map(
7 (page) =>
8 ` <url><loc>${absoluteUrl(page.path)}</loc><priority>${page.priority}</priority></url>`,
9 );
10 const body = `<?xml version="1.0" encoding="UTF-8"?>
11<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
12${urls.join("\n")}
13</urlset>
14`;
15 return new Response(body, { headers: { "Content-Type": "application/xml; charset=utf-8" } });
16};