Skip to content

Commit a82dadd

Browse files
committed
Fix rss configuration
1 parent d98d3a5 commit a82dadd

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

bun.lockb

-4.36 KB
Binary file not shown.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
"@astrojs/rss": "^4.0.11",
1818
"@astrojs/sitemap": "^3.4.1",
1919
"astro": "^4.11.5",
20+
"markdown-it": "^14.1.0",
2021
"prettier": "^3.3.2",
2122
"prettier-plugin-astro": "^0.14.0",
2223
"rehype-autolink-headings": "^7.1.0",
2324
"rehype-slug": "^6.0.0",
2425
"rehype-stringify": "^10.0.0",
2526
"remark-toc": "^9.0.0",
27+
"sanitize-html": "^2.17.0",
2628
"typescript": "^5.5.3"
2729
},
2830
"devDependencies": {

src/pages/rss.xml.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1+
import rss from '@astrojs/rss';
2+
import { getCollection } from "astro:content";
3+
import sanitizeHtml from 'sanitize-html';
4+
import MarkdownIt from 'markdown-it';
5+
const parser = new MarkdownIt();
6+
17
export async function GET(context) {
28
const blog = await getCollection("blog");
39

410
const items = await Promise.all(
511
blog.map(async (post) => {
6-
const { html } = await post.render();
7-
812
return {
913
title: post.data.title,
1014
pubDate: post.data.pubDate,
1115
description: post.data.description,
1216
link: `/blog/${post.slug}/`,
13-
content: html,
17+
content: sanitizeHtml(parser.render(post.body), {
18+
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img'])
19+
}),
1420
categories: post.data.tags || [],
1521
author: "CuddlyBunion341",
1622
guid: post.slug,

0 commit comments

Comments
 (0)