Skip to content

Add draft flag for blog posts#43

Merged
minimaldesign merged 1 commit into
mainfrom
blog-draft-flag
Jul 22, 2026
Merged

Add draft flag for blog posts#43
minimaldesign merged 1 commit into
mainfrom
blog-draft-flag

Conversation

@minimaldesign

Copy link
Copy Markdown
Owner

Astro has no native draft support (markdown.drafts was 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.
  • New getBlogPosts() in src/scripts/content.js filters drafts when import.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 outside utilities.js because it imports astro:content, which must stay out of client bundles.
  • Marks css-container-queries-examples as a draft.

Verification

Dev: post is linked from /blog/ and its route renders normally.

Production build: astro check clean (0 errors, 0 warnings), 104 pages built, and grep -rl "css-container-queries-examples" _site returns 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 development build would ship them.

🤖 Generated with Claude Code

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

netlify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploy Preview for mcssdev ready!

Name Link
🔨 Latest commit ef1f2e9
🔍 Latest deploy log https://app.netlify.com/projects/mcssdev/deploys/6a610b7d1eff280008ce7fa2
😎 Deploy Preview https://deploy-preview-43--mcssdev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 98
Accessibility: 98
Best Practices: 100
SEO: 99
PWA: 70
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@minimaldesign
minimaldesign merged commit 62d2175 into main Jul 22, 2026
5 checks passed
@minimaldesign
minimaldesign deleted the blog-draft-flag branch July 22, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant