import { articlesNewestFirst } from '@/lib/articles';
import { SITE_DESCRIPTION, SITE_NAME, SITE_URL } from '@/lib/seo';
export const dynamic = 'force-static';
function escapeXml(s: string): string {
return s
.replaceAll('&', '&')
.replaceAll('<', '<')
.replaceAll('>', '>')
.replaceAll('"', '"')
.replaceAll("'", ''');
}
export function GET(): Response {
const articles = articlesNewestFirst();
const lastBuildDate = new Date(
articles[0]?.dateModified ?? articles[0]?.datePublished ?? '2026-05-31',
).toUTCString();
const items = articles
.map((a) => {
const url = `${SITE_URL}/guides/${a.slug}`;
return ` -
${escapeXml(a.title)}
${url}
${url}
${escapeXml(a.description)}
${new Date(a.datePublished).toUTCString()}
`;
})
.join('\n');
const xml = `
${escapeXml(`${SITE_NAME} — MCP guides`)}
${SITE_URL}/guides
${escapeXml(SITE_DESCRIPTION)}
en
${lastBuildDate}
${items}
`;
return new Response(xml, {
headers: {
'content-type': 'application/rss+xml; charset=utf-8',
'cache-control': 'public, max-age=3600',
},
});
}