Prevent drafts from being added to the RSS feed

This commit is contained in:
Maciej Pędzich 2024-09-23 16:43:45 +02:00
parent b86b16836c
commit 35c5c4a39e
Signed by: maciejpedzich
GPG Key ID: CE4A303D84882F0D

View File

@ -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,