File tree Expand file tree Collapse file tree 3 files changed +194
-0
lines changed
Expand file tree Collapse file tree 3 files changed +194
-0
lines changed Original file line number Diff line number Diff line change 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}
Original file line number Diff line number Diff line change 11import rss from '@astrojs/rss' ;
22import { getCollection } from 'astro:content' ;
33import 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 ) {
You can’t perform that action at this time.
0 commit comments