Skip to content

Commit 2220b95

Browse files
committed
RSS feed is added.
1 parent 718d5ac commit 2220b95

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

package-lock.json

Lines changed: 65 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@astrojs/check": "^0.7.0",
1616
"@astrojs/mdx": "^3.1.1",
1717
"@astrojs/react": "^3.6.0",
18+
"@astrojs/rss": "^4.0.11",
1819
"@astrojs/sitemap": "^3.1.6",
1920
"@astrojs/tailwind": "^5.1.0",
2021
"@headlessui/tailwindcss": "^0.2.1",

src/pages/rss.xml.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import rss from '@astrojs/rss';
2+
import { getCollection } from 'astro:content';
3+
4+
export async function GET(context) {
5+
const blog = await getCollection('blog');
6+
return rss({
7+
title: 'Efe Öge',
8+
description: 'Tech Tales from a Software Craftsman',
9+
site: context.site,
10+
items: blog.map((post) => ({
11+
title: post.data.title,
12+
pubDate: post.data.publishedAt,
13+
description: post.data.description,
14+
// Compute RSS link from post `id`
15+
// This example assumes all posts are rendered as `/blog/[id]` routes
16+
link: `/posts/${post.slug}`,
17+
})),
18+
});
19+
}

0 commit comments

Comments
 (0)