Update something
This commit is contained in:
parent
31c18af170
commit
2877f96fee
8 changed files with 1316 additions and 6561 deletions
28
src/pages/rss.xml.js
Normal file
28
src/pages/rss.xml.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
import rss from "@astrojs/rss";
|
||||
import { getCollection } from "astro:content";
|
||||
import getSortedPosts from "@/utils/getSortedPosts";
|
||||
import sanitizeHtml from "sanitize-html";
|
||||
import MarkdownIt from "markdown-it";
|
||||
import { SITE } from "@/config";
|
||||
|
||||
const parser = new MarkdownIt();
|
||||
|
||||
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, id }) => ({
|
||||
link: `posts/${id}/`,
|
||||
content: sanitizeHtml(parser.render(posts.body), {
|
||||
allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]),
|
||||
}),
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
pubDate: new Date(data.modDatetime ?? data.pubDatetime),
|
||||
customData: `<summary>${posts.frontmatter.description}</summary>`,
|
||||
})),
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue