Skip to content

Commit d6104f5

Browse files
authored
feat(rss): add full post content to RSS feed (#42)
1 parent fe0fb50 commit d6104f5

File tree

3 files changed

+194
-0
lines changed

3 files changed

+194
-0
lines changed

package-lock.json

Lines changed: 181 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@
1515
"@tailwindcss/typography": "^0.5.19",
1616
"@tailwindcss/vite": "^4.1.18",
1717
"astro": "^5.16.6",
18+
"markdown-it": "^14.1.0",
1819
"mermaid": "^11.12.2",
20+
"sanitize-html": "^2.17.0",
1921
"sharp": "^0.34.5",
2022
"tailwindcss": "^4.1.18"
23+
},
24+
"devDependencies": {
25+
"@types/markdown-it": "^14.1.2",
26+
"@types/sanitize-html": "^2.16.0"
2127
}
2228
}

src/pages/rss.xml.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import rss from '@astrojs/rss';
22
import { getCollection } from 'astro:content';
33
import type { APIContext } from 'astro';
4+
import sanitizeHtml from 'sanitize-html';
5+
import MarkdownIt from 'markdown-it';
6+
7+
const parser = new MarkdownIt();
48

59
// Get the date portion in Eastern time and return a Date at noon UTC
610
// This ensures the pubDate displays the correct calendar date regardless of timezone
@@ -40,6 +44,9 @@ export async function GET(context: APIContext) {
4044
description: post.data.description || '',
4145
link: `/${slug}/`,
4246
categories: post.data.categories,
47+
content: sanitizeHtml(parser.render(post.body ?? ''), {
48+
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']),
49+
}),
4350
};
4451

4552
if (post.data.image) {

0 commit comments

Comments
 (0)