This commit is contained in:
parent
ab405f6e45
commit
804e00a6db
3 changed files with 6 additions and 4 deletions
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
@ -25,8 +25,10 @@
|
|||
"typescript": "^5.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/markdown-it": "^13.0.7",
|
||||
"@types/node": "^20.11.2",
|
||||
"@types/rss": "^0.0.32",
|
||||
"@types/sanitize-html": "^2.9.5",
|
||||
"prettier": "^3.2.2"
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
import rss from '@astrojs/rss';
|
||||
import rss, { type RSSFeedItem } from '@astrojs/rss';
|
||||
import { getCollection } from 'astro:content';
|
||||
import sanitizeHtml from 'sanitize-html';
|
||||
import MarkdownIt from 'markdown-it';
|
||||
|
||||
const parser = new MarkdownIt();
|
||||
|
||||
export async function GET(context) {
|
||||
export async function GET(context: { site: any; }) {
|
||||
const posts = await getCollection('posts');
|
||||
|
||||
return rss({
|
||||
|
@ -14,9 +14,9 @@ export async function GET(context) {
|
|||
site: context.site,
|
||||
items: posts.map((post) => ({
|
||||
title: post.data.title,
|
||||
pubDate: post.data.date,
|
||||
pubDate: new Date(post.data.date),
|
||||
content: sanitizeHtml(parser.render(post.body)),
|
||||
link: `/posts/${post.slug}`,
|
||||
})),
|
||||
})) as RSSFeedItem[],
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue