import { getLegacyArticlesBySection } from "@/lib/articles/legacy-source"; export const dynamic = "force-dynamic"; export const revalidate = 1800; const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || "https://avbeat.com"; function escapeXml(s: string): string { return s .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """) .replace(/'/g, "'"); } export async function GET() { let items = ""; try { const articles = await getLegacyArticlesBySection("news", 50); items = articles .map((a) => { const url = `${SITE_URL}/news/${a.slug}`; const pubDate = a.date ? new Date(a.date).toUTCString() : new Date().toUTCString(); const title = escapeXml(a.title || "Untitled"); const description = escapeXml(a.excerpt || ""); return ` ${title} ${url} ${url} ${pubDate} ${description} `; }) .join("\n"); } catch { // serve an empty but valid feed on failure items = ""; } const body = ` AV Beat ${SITE_URL} News & Intelligence for Broadcast, Post-Production & Streaming Technology en-us ${new Date().toUTCString()} ${items} `; return new Response(body, { headers: { "Content-Type": "application/rss+xml; charset=utf-8", "Cache-Control": "public, max-age=1800, s-maxage=1800, stale-while-revalidate=3600", }, }); }