aboutsummaryrefslogtreecommitdiff
path: root/src/pages/feed.xml.js
blob: 5aea78baeb83fc94f2f50426c0edf772f310da4a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { getCollection } from "astro:content";
import rss from "@astrojs/rss";

export async function GET(context) {
	const title = "RSS Feed | Valentin Popov Blog";
	const description = "Follow the latest posts from Valentin Popov via RSS.";

	const posts = await getCollection("blog", ({ data }) => {
		return data.draft !== true;
	});

	return rss({
		customData: `<language>en</language>`,
		description: description,
		items: posts.map((post) => ({
			description: post.data.description,
			link: `/blog/${post.id}`,
			pubDate: post.data.datePublished,
			title: post.data.title,
		})),
		site: context.site,
		title: title,
	});
}