diff --git a/bun.lockb b/bun.lockb index e0daf6d9..954d2e08 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 811a8114..8d7a026d 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,8 @@ "@tailwindcss/forms": "^0.5.10", "@tailwindcss/typography": "^0.5.16", "@types/bun": "latest", + "@types/markdown-it": "^14.1.2", + "@types/sanitize-html": "^2.16.0", "fast-xml-parser": "^4.5.3", "kleur": "^4.1.5", "prettier": "^3.5.3", @@ -28,6 +30,8 @@ "@astrojs/tailwind": "^5.1.5", "@astrojs/ts-plugin": "^1.10.4", "astro": "^4.16.18", + "markdown-it": "^14.1.0", + "sanitize-html": "^2.17.0", "tailwindcss": "^3.4.17" } } diff --git a/src/pages/posts.rss.ts b/src/pages/posts.rss.ts index 4dc9ad1a..dc05eb9f 100644 --- a/src/pages/posts.rss.ts +++ b/src/pages/posts.rss.ts @@ -1,6 +1,10 @@ import rss from "@astrojs/rss"; import { getCollection } from "astro:content"; import type { APIContext } from "astro"; +import sanitizeHtml from 'sanitize-html'; +import MarkdownIt from 'markdown-it'; + +const parser = new MarkdownIt(); export async function GET(context: APIContext) { const posts = await getCollection("posts"); @@ -13,6 +17,9 @@ export async function GET(context: APIContext) { .map((post) => ({ title: post.data.title, description: post.data.description, + content: sanitizeHtml(parser.render(post.body), { + allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']) + }), author: post.data.author, pubDate: post.data.date, categories: [post.data.type],