refactor: update the rss to use collections too

This commit is contained in:
Ruidy 2025-01-01 21:56:06 +01:00
parent 5acac485c7
commit c58ee4ddfa
No known key found for this signature in database
GPG key ID: E00F51288CB857CC

View file

@ -1,11 +1,17 @@
import rss, { pagesGlobToRssItems } from "@astrojs/rss";
import { getCollection } from "astro:content";
export async function GET(context) {
return rss({
title: "Astro Learner | Blog",
description: "My journey learning Astro",
site: context.site,
items: await pagesGlobToRssItems(import.meta.glob("./**/*.md")),
items: (await getCollection("blog")).map((post) => ({
title: post.data.title,
pubDate: post.data.pubDate,
description: post.data.description,
link: `/blog/${post.id}`,
})),
customData: `<language>en-us</language>`,
});
}