import * as config from '$lib/config' import type { Post } from '$lib/types' export const prerender = true export async function GET({ fetch }) { const response = await fetch('api/posts') const posts: Post[] = await response.json() const headers = { 'Content-Type': 'application/xml' } const xml = ` ${config.title} ${config.description} ${config.url} ${posts .map( (post) => ` ${post.title} ${post.description} ${config.url}/${post.slug} ${config.url}/${post.slug} ${new Date(post.date).toUTCString()} ` ) .join('')} `.trim() return new Response(xml, { headers }) }