2024-12-25 02:14:10 -05:00
|
|
|
import rss from "@astrojs/rss";
|
|
|
|
import { getCollection } from "astro:content";
|
2025-03-08 19:45:21 -05:00
|
|
|
import getSortedPosts from "@/utils/getSortedPosts";
|
|
|
|
import { SITE } from "@/config";
|
2025-03-25 21:25:13 -04:00
|
|
|
import { globalImageUrls } from "@/utils/globalImageUrls";
|
|
|
|
import sanitizeHtml from "sanitize-html";
|
2024-12-25 02:14:10 -05:00
|
|
|
|
|
|
|
export async function GET() {
|
|
|
|
const posts = await getCollection("blog");
|
|
|
|
const sortedPosts = getSortedPosts(posts);
|
|
|
|
return rss({
|
|
|
|
title: SITE.title,
|
|
|
|
description: SITE.desc,
|
|
|
|
site: SITE.website,
|
2025-03-25 21:25:13 -04:00
|
|
|
items: sortedPosts.map(({ data, id, rendered }) => ({
|
|
|
|
content: globalImageUrls(
|
|
|
|
SITE.website,
|
|
|
|
sanitizeHtml(rendered?.html, {
|
|
|
|
allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]),
|
|
|
|
}),
|
|
|
|
),
|
2025-03-08 19:45:21 -05:00
|
|
|
link: `posts/${id}/`,
|
2024-12-25 02:14:10 -05:00
|
|
|
title: data.title,
|
|
|
|
description: data.description,
|
|
|
|
pubDate: new Date(data.modDatetime ?? data.pubDatetime),
|
|
|
|
})),
|
|
|
|
});
|
|
|
|
}
|