feat: json feed and fix drafts displayed in rss

This commit is contained in:
草师傅 2025-08-29 21:52:55 +08:00
parent d31ba9eb9c
commit 377c541a21
Signed by: gb
GPG key ID: 43330A030E2D6478
2 changed files with 59 additions and 4 deletions

View file

@ -21,10 +21,12 @@ export async function GET(context) {
const container = await AstroContainer.create({ renderers });
// Load the content collection entries to add to our RSS feed.
const posts = (await getCollection("posts")).sort((a, b) =>
// Sort by publication date descending.
a.data.date > b.data.date ? -1 : 1
);
const posts = (await getCollection('posts', ({ data }) => {
return import.meta.env.PROD ? data.draft !== true : true;
})).sort((a, b) =>
// Sort by publication date descending.
a.data.date > b.data.date ? -1 : 1
);
// Loop over blog posts to create feed items for each, including full content.
const feedItems = [];