File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff line change 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+
17export 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 ,
You can’t perform that action at this time.
0 commit comments