blog/src/pages/rss.xml.ts

19 lines
490 B
TypeScript
Raw Normal View History

2023-08-31 04:51:10 +00:00
import rss from "@astrojs/rss";
import { getCollection } from "astro:content";
import { SITE_TITLE, SITE_DESCRIPTION } from "../consts";
export async function GET(context) {
const posts = await getCollection("posts");
return rss({
title: SITE_TITLE,
description: SITE_DESCRIPTION,
site: context.site,
items: posts.map((post) => ({
title: post.data.title,
pubDate: post.data.date,
// ...post.data,
link: `/blog/${post.slug}/`,
})),
});
}