import { getPostImages, getPostPublishDate, getPostSlug, getPosts } from '$lib/cohost'; import { renderPostMarkdown, renderPostSummaryPlaintext } from '$lib/markdown/rendering'; import { minify as minifyXML } from 'minify-xml'; import config from '$lib/config'; /** @type {import('./$types').RequestHandler} */ export async function GET() { const posts = await getPosts(); let response = new Response(xml(posts)); response.headers.set('Cache-Control', 'max-age=0, s-maxage=3600'); response.headers.set('Content-Type', 'application/xml'); return response; } const xml = (/** @type {Post[]} */ posts) => minifyXML(` ${config.blogName} ${config.blogDescription} ${config.siteURL}/ 60 ${config.siteURL}/favicon.png ${config.blogName} ${config.siteURL}/ ${posts .map(post => ` ${post.headline} ${renderPostSummaryPlaintext(post.blocks)} ${config.siteURL}/${getPostSlug(post)}/ ${post.postingProject.displayName} ${getPostPublishDate(post)?.toUTCString()} ${getPostImages(post).length > 0 ? `` : ''} `)} `);