mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
b3a1d9d369
Add trailing slash to links for improved consistency with RSS links and to avoid unnecessary redirects. --------- Co-authored-by: satnaing <satnaingdev@gmail.com>
21 lines
596 B
TypeScript
21 lines
596 B
TypeScript
import rss from "@astrojs/rss";
|
|
import { getCollection } from "astro:content";
|
|
import getSortedPosts from "@utils/getSortedPosts";
|
|
import { SITE } from "@config";
|
|
|
|
export async function GET() {
|
|
const posts = await getCollection("blog");
|
|
const sortedPosts = getSortedPosts(posts);
|
|
return rss({
|
|
title: SITE.title,
|
|
description: SITE.desc,
|
|
site: SITE.website,
|
|
items: sortedPosts.map(({ data, slug }) => ({
|
|
link: `posts/${slug}/`,
|
|
title: data.title,
|
|
description: data.description,
|
|
pubDate: new Date(data.modDatetime ?? data.pubDatetime),
|
|
})),
|
|
});
|
|
}
|