blob: d428cc974e5d5afd5324c1ad6a5885bea03aacab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import rss from "@astrojs/rss";
import type { APIContext } from "astro";
import { getAllPosts } from "@/data/post";
import { siteConfig } from "@/site.config";
export const GET = async (context: APIContext) => {
const posts = await getAllPosts();
return rss({
title: siteConfig.title,
description: siteConfig.description,
site: context.site || import.meta.env.SITE,
items: posts.map((post) => ({
title: post.data.title,
description: post.data.description,
pubDate: post.data.publishDate,
link: `posts/${post.id}/`,
author: post.data.author,
})),
customData: `<atom:link href="${context.site}rss.xml" rel="self" type="application/rss+xml" xmlns:atom="http://www.w3.org/2005/Atom" />`,
});
};
|