Skip to content

Commit 8780e3a

Browse files
committed
Fetch blog posts for RSS feed generation
1 parent 8586fab commit 8780e3a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/pages/rss.xml.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
import rss, { pagesGlobToRssItems } from "@astrojs/rss";
1+
import rss from "@astrojs/rss";
2+
import { getCollection } from 'astro:content';
23

34
export async function GET(context) {
5+
const blog = await getCollection('blog');
46
return rss({
57
title: "Astro Learner | Blog",
68
description: "My journey learning Astro",
79
site: context.site,
8-
items: await pagesGlobToRssItems(import.meta.glob("./**/*.md")),
10+
items: blog.map((post) => ({
11+
title: post.data.title,
12+
pubDate: post.data.publishDate,
13+
description: post.data.description,
14+
link: `/posts/${post.data.slug}/`,
15+
})),
916
customData: `<language>en-us</language>`,
1017
});
1118
}

0 commit comments

Comments
 (0)