-
-
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
Draft frontmatter flag not respected in collection #6400
Comments
Also, the type definition for the filter function I suggested in the workaround doesn't make sense, and doesn't match the documentation. Type definition, .astro/types.d.ts:
According to the doc the return type of the filter function should be |
The The second definition aligns with the documentation. |
Yeah, I know TS does it that way, with unknown instead of boolean - wrongly, but as I understand the correct way broke too many existing code But the types.d.ts I get is not overloaded, it only has the first definition, which doesn't work. This is my types.d.ts
|
Is there any update on this? It took me a long time to figure out why my markdown drafts were still being built in production, and after finally realising it was to do with the
Regardless of the status of the bugfix, it feels like a small note acknowledging the bug in the documentation next to the drafts section would have saved me a lot time, and I'm sure it will help many others until the problem is resolved. |
After much discussion with the team, we've made the decision to deprecate the Drafts were introduced back before Astro 1.0, when Astro was purely a static site generator and Despite this deprecation, we understand the need for previewing unpublished content. There is an ongoing roadmap discussion about supporting preview deployments for headless CMSs. Hopefully whatever eventual API emerges from that discussion can also accommodate local content. In the meantime, manually filtering your Content Collection posts using this approach is a perfectly valid way to implement drafts in userland. await getCollection("post", ({ data }) => import.meta.env.DEV || !data?.draft)) |
This is so flipping disappointing. |
What version of
astro
are you using?2.0.2
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
pnpm
What operating system are you using?
Mac
Describe the Bug
draft: true
in frontmatter of pages is respected, but in frontmatter of collections it isn't when generating static site.As a workaround one can create a filter when calling
getCollection
and alsogetStaticPath
But that's not consistent with pages (where ItJustWorks) or with user expectations
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-tlp8uq
Participation
The text was updated successfully, but these errors were encountered: