-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrss.xml.ts
More file actions
29 lines (26 loc) · 1010 Bytes
/
rss.xml.ts
File metadata and controls
29 lines (26 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import rss from "@astrojs/rss";
import type { APIContext } from "astro";
import { getCollection } from "astro:content";
import { postUrl, withBase } from "../lib/utils";
export const prerender = true;
export async function GET(context: APIContext) {
const allPosts = await getCollection("posts");
const posts = allPosts
.filter((p) => p.data.published)
.sort((a, b) => b.data.publishDate.getTime() - a.data.publishDate.getTime())
.slice(0, 50);
return rss({
title: "Python Insider",
description: "The official blog of the Python core development team.",
site: context.site!.toString(),
xmlns: { dc: "http://purl.org/dc/elements/1.1/" },
items: posts.map((post) => ({
title: post.data.title,
pubDate: post.data.publishDate,
description: post.data.description ?? "",
link: withBase(`${postUrl(post.id, post.data.publishDate)}/`),
customData: `<dc:creator>${post.data.author}</dc:creator>`,
categories: post.data.tags,
})),
});
}