import { NextResponse } from 'next/server' import { latestModified } from '@/lib/content/utils' import { SITE_URL } from '@/lib/core/utils/urls' import { getAllPostMeta } from '@/lib/library/registry' import { LIBRARY_SECTION } from '@/lib/library/seo' export const revalidate = 3600 export async function GET() { const posts = await getAllPostMeta() const items = posts.slice(0, 50) const site = SITE_URL const lastBuildDate = (latestModified(items) ?? new Date()).toUTCString() const xml = ` Sim ${LIBRARY_SECTION.name} ${site} ${LIBRARY_SECTION.description} en-us ${lastBuildDate} ${items .map( (p) => ` <![CDATA[${p.title}]]> ${p.canonical} ${p.canonical} ${new Date(p.date).toUTCString()} ${(p.authors || [p.author]) .map((a) => ``) .join('\n')} ${p.tags.map((t) => ``).join('\n ')} ` ) .join('')} ` return new NextResponse(xml, { headers: { 'Content-Type': 'application/xml; charset=utf-8', 'Cache-Control': 'public, s-maxage=3600, stale-while-revalidate=86400', }, }) }