-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@astrojs/rss includes drafts in output #5505
Comments
I'm also looking into this issue and trying to figure out how it could be better. But to make it more intuitive, we might have to change how currently Currently, there's no way for the RSS generator to get the metadata from the source. astro/packages/astro-rss/src/index.ts Line 22 in 5877dcb
Also, due to how Are there any design considerations here? Is there any possibility of moving it into the |
As a workaround, you can filter out the draft items from your import rss from '@astrojs/rss';
const postImportResult = import.meta.glob('../posts/**/*.md', { eager: true });
const posts = Object.values(postImportResult).filter(
post => !post.frontmatter.draft
);
export const get = () => rss({
title: 'Buzz’s Blog',
description: 'A humble Astronaut’s guide to the stars',
site: import.meta.env.SITE,
items: posts.map((post) => ({
link: post.url,
title: post.frontmatter.title,
pubDate: post.frontmatter.pubDate,
}))
}); Should also be fairly simple to add this logic to the RSS package directly:
|
What version of
astro
are you using?1.6.12
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Mac
Describe the Bug
When an item is marked as a draft in the frontmatter, it is still included in the XML output. You can see this behavior in the default blog example.
They should be excluded by default, and ideally added based on integration configuration or build flags.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-exbbav?file=src%2Fpages%2Fblog%2Ffirst-post.md,dist%2Frss.xml&on=stackblitz
Participation
The text was updated successfully, but these errors were encountered: