-
Notifications
You must be signed in to change notification settings - Fork 2
Fix: Exclude draft posts from navigation when using --includeDrafts #61
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
Conversation
…s flag Co-authored-by: matt-goldman <[email protected]>
Co-authored-by: matt-goldman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug where draft posts were incorrectly appearing in site navigation when using the --includeDrafts flag. The fix ensures that draft posts are baked to .razor files (accessible via direct URL) but excluded from GeneratedContentIndex.cs (navigation), which is the intended behavior.
- Adds filtering logic in
ContentIndexBuilder.WriteIndexto exclude draft pages from the generated content index - Adds comprehensive integration test to verify drafts are baked but excluded from the index
- Maintains backward compatibility: without
--includeDrafts, drafts are still completely excluded from baking
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Blake.BuildTools/Generator/ContentIndexBuilder.cs |
Filters out draft pages before writing to content index, ensuring they don't appear in navigation |
tests/Blake.IntegrationTests/Commands/BlakeBakeCommandTests.cs |
Adds integration test verifying drafts are baked to .razor files but excluded from GeneratedContentIndex.cs when --includeDrafts is used |
| $" Date = new DateTime({page.Date.Value.Year}, {page.Date.Value.Month}, {page.Date.Value.Day}),"); | ||
| // Draft property is always false here since drafts are filtered out above | ||
| // We include it for consistency with PageModel structure and explicit state indication | ||
| sb.AppendLine($" Draft = {page.Draft.ToString().ToLowerInvariant()},"); |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Since drafts are filtered out on line 20, page.Draft will always be false here. Consider replacing page.Draft.ToString().ToLowerInvariant() with a hardcoded false on line 37 to make the code more explicit and avoid unnecessary property evaluation:
sb.AppendLine($" Draft = false,");This would make the code match the comment's explanation more directly.
| sb.AppendLine($" Draft = {page.Draft.ToString().ToLowerInvariant()},"); | |
| sb.AppendLine(" Draft = false,"); |
|
Bad call on my part - this is the responsibility of the template |
Summary
When using
blake bake --includeDrafts, draft posts are now correctly excluded fromGeneratedContentIndex.cswhile still being baked to.razorfiles. Draft posts remain accessible via direct URL but no longer appear in site navigation.Changes:
ContentIndexBuilder.WriteIndex: Filter draft pages before writing to content index--includeDraftsis usedBehavior:
🧷 This PR will be released as a preview by default.
To trigger a stable release:
previewlabelreleaselabelSemver-MinororSemver-Majorto control version bump🏷️ Add labels to control release notes:
enhancement,bug,breaking-change,dependenciesignore-for-releaseto suppress it from notesOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.