Files
avbeat-com/src/app/rss/route.ts
Ryan Salazar dd93a74bdf Brand cleanup: swap remaining user-facing BB strings + accent blue → AV orange
Hit pages we didn't get the first pass: rss, gear, show-coverage,
articles/[slug], contributor, manufacturers, login, client-login, terms,
dashboard/show-calendar, and team-page derive helpers (domain + comment).
2026-06-01 15:39:09 +00:00

61 lines
1.8 KiB
TypeScript

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, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&apos;");
}
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 ` <item>
<title>${title}</title>
<link>${url}</link>
<guid isPermaLink="true">${url}</guid>
<pubDate>${pubDate}</pubDate>
<description>${description}</description>
</item>`;
})
.join("\n");
} catch {
// serve an empty but valid feed on failure
items = "";
}
const body = `<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>AV Beat</title>
<link>${SITE_URL}</link>
<atom:link href="${SITE_URL}/rss" rel="self" type="application/rss+xml" />
<description>News &amp; Intelligence for Broadcast, Post-Production &amp; Streaming Technology</description>
<language>en-us</language>
<lastBuildDate>${new Date().toUTCString()}</lastBuildDate>
${items}
</channel>
</rss>`;
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",
},
});
}