From 35c5c4a39ef95787171e7a5dac5b4a4bba31453b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Mon, 23 Sep 2024 16:43:45 +0200 Subject: [PATCH] Prevent drafts from being added to the RSS feed --- src/pages/rss.xml.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index b5b4631..3a76fa3 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -3,9 +3,9 @@ import { getCollection } from 'astro:content'; import { SITE_TITLE, SITE_DESCRIPTION } from '../consts'; export async function GET(context) { - const posts = (await getCollection('blog')).sort( - (a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf() - ); + const posts = (await getCollection('blog')) + .filter((p) => !p.data.draft) + .sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()); const { body } = await rss({ title: SITE_TITLE,