import { getCollection } from "astro:content"; export const prerender = true; const site = "https://simo.ng"; function urlEntry(path: string, date?: Date) { const loc = new URL(path, site).toString(); const lastmod = date ? `\n\t\t${date.toISOString()}` : ""; return `\n\t\n\t\t${loc}${lastmod}\n\t`; } export async function GET() { const posts = await getCollection("blogs"); const visiblePosts = posts.filter((post) => (import.meta.env.PROD ? !post.data.draft : true)); const urls = [ urlEntry("/"), urlEntry("/ram/"), urlEntry("/ram/embed/"), ...visiblePosts.flatMap((post) => [ urlEntry(`/ram/${post.id}/`, post.data.pubDate), urlEntry(`/ram/embed/${post.id}/`, post.data.pubDate), ]), ]; return new Response(`\n${urls.join("")}\n\n`, { headers: { "Content-Type": "application/xml; charset=utf-8", }, }); }