23 lines
762 B
JavaScript
23 lines
762 B
JavaScript
import rss from "@astrojs/rss";
|
|
import { getCollection } from "astro:content";
|
|
import { SITE_TITLE, SITE_DESCRIPTION } from "../consts";
|
|
import { ACTIVE_BLOG_SITE } from "../blog-sites.js";
|
|
import { typographicText } from "@/lib/typography";
|
|
|
|
export async function GET(context) {
|
|
const posts = (await getCollection(ACTIVE_BLOG_SITE.key)).sort(
|
|
(a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf(),
|
|
);
|
|
|
|
return rss({
|
|
title: SITE_TITLE,
|
|
description: typographicText(SITE_DESCRIPTION),
|
|
site: context.site,
|
|
items: posts.map((post) => ({
|
|
...post.data,
|
|
title: typographicText(post.data.title),
|
|
description: typographicText(post.data.description),
|
|
link: `/${post.id.replace(/\/index$/, "")}/`,
|
|
})),
|
|
});
|
|
}
|