Add draft flag for blog posts#43
Merged
Merged
Conversation
Astro has no native draft support (markdown.drafts was removed in v4), so gate posts behind a schema flag instead. Drafts render in dev and are filtered out of production builds: listing, tag pages, routes, RSS, sitemap. All blog reads go through getBlogPosts() in scripts/content.js so the filter cannot be forgotten on a new call site. It lives outside utilities.js because it imports astro:content, which must stay out of client bundles. Marks the container queries post as a draft. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
✅ Deploy Preview for mcssdev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Astro has no native draft support (
markdown.draftswas removed in v4), so this adds a schema flag instead.draft: z.boolean().default(false)on the blog schema, so existing posts need no frontmatter change.getBlogPosts()insrc/scripts/content.jsfilters drafts whenimport.meta.env.PROD. All five blog reads (listing, post route, both tag pages, RSS) now go through it so the filter can't be forgotten on a future call site. It sits outsideutilities.jsbecause it importsastro:content, which must stay out of client bundles.css-container-queries-examplesas a draft.Verification
Dev: post is linked from
/blog/and its route renders normally.Production build:
astro checkclean (0 errors, 0 warnings), 104 pages built, andgrep -rl "css-container-queries-examples" _sitereturns nothing. The route is gone, RSS drops to 19 items from 20 posts, and/tags/queries/is not generated since that tag was unique to this post. No stale sitemap entry, as the sitemap derives from built pages.Note: drafts are hidden in prod but not secret in dev. A deployed dev server or a
--mode developmentbuild would ship them.🤖 Generated with Claude Code