From c58ee4ddfa4c5582b249e1b09f2d2f4e81fbfb5f Mon Sep 17 00:00:00 2001 From: Ruidy Date: Wed, 1 Jan 2025 21:56:06 +0100 Subject: [PATCH] refactor: update the rss to use collections too --- src/pages/rss.xml.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index ba13516..8cbaa2d 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -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: `en-us`, }); }