import { listArticles } from '@/lib/engine';
const SITE = 'https://zeropost.ru';
function escapeXml(s = '') {
return s
.replace(/&/g, '&')
.replace(//g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}
export async function GET() {
const articles = await listArticles({ limit: 50 });
const items = articles.map(a => `
-
${escapeXml(a.title)}
${SITE}/blog/${a.slug}
${SITE}/blog/${a.slug}
${new Date(a.published_at).toUTCString()}
${escapeXml(a.excerpt || '')}
${(a.tags || []).map(t => `${escapeXml(t)}`).join('')}
`).join('');
const xml = `
ZeroPost
${SITE}
Блог про практическое применение ИИ
ru
${items}
`;
return new Response(xml, {
headers: {
'Content-Type': 'application/rss+xml; charset=utf-8',
'Cache-Control': 'public, max-age=600, s-maxage=600',
},
});
}