Commit 2cd862e
Changed files (1)
src
pages
src/pages/rss.xml.ts
@@ -1,13 +1,13 @@
import { siteConfig } from '@/config';
import rss from '@astrojs/rss';
import { getSortedPosts } from '@utils/content-utils';
-import type { AstroGlobal } from 'astro';
+import type { APIRoute } from 'astro';
import MarkdownIt from 'markdown-it';
import sanitizeHtml from 'sanitize-html';
const parser = new MarkdownIt();
-export async function GET(context: AstroGlobal) {
+export const GET: APIRoute = async function (context) {
const posts = await getSortedPosts();
return rss({
title: siteConfig.title,
@@ -19,9 +19,9 @@ export async function GET(context: AstroGlobal) {
pubDate: post.data.published,
description: post.data.description,
link: `/posts/${post.data.slug}`,
- content: sanitizeHtml(parser.render(post.body), {
+ content: sanitizeHtml(parser.render(post.body || ''), {
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']),
}),
})),
});
-}
+};