devblog/src/pages/rss.xml.ts

21 lines
594 B
TypeScript
Raw Normal View History

2024-12-25 02:14:10 -05:00
import rss from "@astrojs/rss";
import { getCollection } from "astro:content";
2025-03-08 19:45:21 -05:00
import getSortedPosts from "@/utils/getSortedPosts";
import { SITE } from "@/config";
2024-12-25 02:14:10 -05:00
export async function GET() {
const posts = await getCollection("blog");
const sortedPosts = getSortedPosts(posts);
return rss({
title: SITE.title,
description: SITE.desc,
site: SITE.website,
2025-03-28 02:34:52 -04:00
items: sortedPosts.map(({ data, id }) => ({
2025-03-08 19:45:21 -05:00
link: `posts/${id}/`,
2024-12-25 02:14:10 -05:00
title: data.title,
description: data.description,
pubDate: new Date(data.modDatetime ?? data.pubDatetime),
})),
});
}