This repository has been archived on 2025-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
coryd.dev-astro/src/pages/feeds/links.xml.js
2024-11-18 06:42:05 -08:00

28 lines
711 B
JavaScript

import { generateRssFeed } from "@utils/generateRssFeed";
import { fetchGlobals } from "@utils/data/globals.js";
import { fetchLinks } from "@utils/data/links";
export const prerender = true;
export async function GET() {
const globals = await fetchGlobals();
const links = await fetchLinks();
const rss = generateRssFeed({
permalink: "/feeds/links.xml",
title: "Links feed",
globals,
data: links,
});
const filePath = path.resolve("public/feeds/links.xml");
await fs.mkdir(path.dirname(filePath), { recursive: true });
await fs.writeFile(filePath, rss);
return new Response(rss, {
status: 200,
headers: {
"Content-Type": "application/rss+xml",
},
});
}