From c938ed446ae9f22e4d97d0b5eadd616830027856 Mon Sep 17 00:00:00 2001 From: Graham Hall Date: Sat, 11 Feb 2023 16:35:42 -0500 Subject: [PATCH] rss improvements --- src/pages/rss.xml.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index 69ac95b..c7558e7 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -1,5 +1,8 @@ import rss from "@astrojs/rss"; import { getCollection } from "astro:content"; +import sanitizeHtml from "sanitize-html"; +import MarkdownIt from "markdown-it"; +const parser = new MarkdownIt({ html: true }); export async function get(context) { const blog = await getCollection("blog"); @@ -12,12 +15,9 @@ export async function get(context) { items: blog .sort((a, b) => Date.parse(b.data.pubDate) - Date.parse(a.data.pubDate)) .map((post) => ({ - title: post.data.title, - pubDate: post.data.pubDate, - // description: post.body, - // Compute RSS link from post `slug` - // This example assumes all posts are rendered as `/blog/[slug]` routes link: `/posts/${post.slug}/`, + content: sanitizeHtml(parser.render(post.body)), + ...post.data, })), }); }