Repository Public
1import { env } from "@/lib/env";2import { allPublishedForFeeds } from "@/server/sheets";34export const dynamic = "force-dynamic";5const esc = (s: string) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);67export async function GET() {8 const items = (await allPublishedForFeeds()).slice(0, 100);9 const xml = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel>10<title>Sheet — by Simon-Pierre Boucher</title><link>${env.appUrl}</link><atom:link href="${env.appUrl}/rss.xml" rel="self" type="application/rss+xml"/>11<description>Fiches scientifiques, techniques et pédagogiques / Scientific, technical and teaching sheets</description><language>fr-CA</language>12${items.length ? `<lastBuildDate>${items[0].published_at.toUTCString()}</lastBuildDate>` : ""}13${items.map((i) => `<item><title>${esc(i.title)}</title><link>${env.appUrl}/s/${i.slug}</link><guid isPermaLink="true">${env.appUrl}/s/${i.slug}</guid><pubDate>${i.first_published_at.toUTCString()}</pubDate><dc:creator>Simon-Pierre Boucher</dc:creator><dc:language>${i.locale}</dc:language><description>${esc(i.summary)}</description></item>`).join("\n")}14</channel></rss>`;15 return new Response(xml, { headers: { "Content-Type": "application/rss+xml; charset=utf-8", "Cache-Control": "public, max-age=600" } });16}17