Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Summary

When using blake bake --includeDrafts, draft posts are now correctly excluded from GeneratedContentIndex.cs while still being baked to .razor files. 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
  • Integration test: Verify drafts are baked but excluded from index when --includeDrafts is used

Behavior:

# With --includeDrafts flag:
blake bake --includeDrafts

# Draft posts now:
# ✓ Generate .razor files → /posts/draft-post.razor (accessible by URL)
# ✓ Excluded from GeneratedContentIndex.cs (not in navigation)

🧷 This PR will be released as a preview by default.

To trigger a stable release:

  • Remove the preview label
  • Add the release label
  • Optionally add Semver-Minor or Semver-Major to control version bump

🏷️ Add labels to control release notes:

  • enhancement, bug, breaking-change, dependencies
  • Or use ignore-for-release to suppress it from notes
Original prompt

This section details on the original issue you should resolve

<issue_title>:bug: Posts marked draft are included in navigation</issue_title>
<issue_description>By default blake bake will ignore posts that have draft: true in the frontmatter. That's working well.

However, if you call blake bake --includeDraft, it should include them (working) but not list them in the content index (not working). Posts marked as draft show up in the site's navigation which is not the intent. The intent of baking a draft post is that it's there and accessible by URL if you know it, but should not appear in the content index and therefore not be listed in the site's navigation.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@github-actions github-actions bot added preview Triggers a release of preview version of Nuget packages enhancement New feature or request Blake.BuildTools labels Dec 10, 2025
Copilot AI changed the title [WIP] Fix navigation issue for draft posts in blake bake Fix: Exclude draft posts from navigation when using --includeDrafts Dec 10, 2025
Copilot AI requested a review from matt-goldman December 10, 2025 12:09
@matt-goldman matt-goldman marked this pull request as ready for review December 10, 2025 12:10
Copilot AI review requested due to automatic review settings December 10, 2025 12:10
Copy link
Contributor

Copilot AI left a 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.WriteIndex to 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()},");
Copy link

Copilot AI Dec 10, 2025

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.

Suggested change
sb.AppendLine($" Draft = {page.Draft.ToString().ToLowerInvariant()},");
sb.AppendLine(" Draft = false,");

Copilot uses AI. Check for mistakes.
@matt-goldman
Copy link
Owner

Bad call on my part - this is the responsibility of the template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Blake.BuildTools enhancement New feature or request preview Triggers a release of preview version of Nuget packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Posts marked draft are included in navigation

2 participants