@@ -3,14 +3,33 @@ import { getCollection } from 'astro:content';
33import { SITE_TITLE , SITE_DESCRIPTION } from '../consts' ;
44
55export async function GET ( context ) {
6- const posts = await getCollection ( 'blog' ) ;
7- return rss ( {
8- title : SITE_TITLE ,
9- description : SITE_DESCRIPTION ,
10- site : context . site ,
11- items : posts . map ( ( post ) => ( {
12- ...post . data ,
13- link : `/blog/${ post . slug } /` ,
14- } ) ) ,
15- } ) ;
6+ // Retrieve all published blog posts from the "blog" collection
7+ const posts = await getCollection ( 'blog' , ( { data } ) => ! data . draft ) ;
8+
9+ // Map each post to an RSS feed item.
10+ // Here we include the full content from the post body.
11+ // (If you need to render Markdown to HTML, you may use post.render() with appropriate rendering logic.)
12+ const items = posts . map ( ( post ) => ( {
13+ title : post . data . title ,
14+ // Link to the blog post page; adjust if your routing differs.
15+ link : `/blog/${ post . slug } /` ,
16+ // Publication date from frontmatter
17+ pubDate : post . data . pubDate ,
18+ // A short summary/description for the feed item
19+ description : post . data . description ,
20+ // Full post content – note that post.body is the raw Markdown.
21+ // For proper HTML, ensure your collection loader converts it, or use post.render() to generate HTML.
22+ content : post . body ,
23+ // Optional: add categories if available
24+ categories : post . data . tags || [ ] ,
25+ // Optionally, include the author field if present
26+ author : post . data . author || undefined ,
27+ } ) ) ;
28+
29+ return rss ( {
30+ title : SITE_TITLE ,
31+ description : SITE_DESCRIPTION ,
32+ site : context . site ,
33+ items,
34+ } ) ;
1635}
0 commit comments