From ebcf0bbb9e74454cc5628905bb021db7d1a34f56 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 11:47:38 +0000 Subject: [PATCH 1/3] Initial plan From 170105ad51a16fefcf3596c653e1c3039c7164a0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 11:54:00 +0000 Subject: [PATCH 2/3] Fix: Exclude draft posts from content index when using --includeDrafts flag Co-authored-by: matt-goldman <19944129+matt-goldman@users.noreply.github.com> --- .../Generator/ContentIndexBuilder.cs | 5 +- .../Commands/BlakeBakeCommandTests.cs | 49 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/Blake.BuildTools/Generator/ContentIndexBuilder.cs b/src/Blake.BuildTools/Generator/ContentIndexBuilder.cs index b35c6ce..06e12f7 100644 --- a/src/Blake.BuildTools/Generator/ContentIndexBuilder.cs +++ b/src/Blake.BuildTools/Generator/ContentIndexBuilder.cs @@ -16,7 +16,10 @@ public static void WriteIndex(string outputPath, List allPages, bool sb.AppendLine(" public static partial List GetPages() => new()"); sb.AppendLine(" {"); - foreach (var page in allPages) + // Filter out draft pages - they should be accessible by URL but not listed in navigation + var nonDraftPages = allPages.Where(p => !p.Draft).ToList(); + + foreach (var page in nonDraftPages) { try { diff --git a/tests/Blake.IntegrationTests/Commands/BlakeBakeCommandTests.cs b/tests/Blake.IntegrationTests/Commands/BlakeBakeCommandTests.cs index e0e091a..d9ef3a6 100644 --- a/tests/Blake.IntegrationTests/Commands/BlakeBakeCommandTests.cs +++ b/tests/Blake.IntegrationTests/Commands/BlakeBakeCommandTests.cs @@ -203,6 +203,55 @@ public async Task BlakeBake_WithIncludeDraftsFlag_IncludesDrafts() FileSystemHelper.AssertFileExists(Path.Combine(testDir, ".generated", "posts", "DraftPost.razor")); } + [Fact] + public async Task BlakeBake_WithIncludeDraftsFlag_ExcludesDraftsFromContentIndex() + { + // Arrange + var testDir = CreateTempDirectory("blake-bake-drafts-not-in-index"); + + // Create a published post + FileSystemHelper.CreateMarkdownFile( + Path.Combine(testDir, "Posts", "published-post.md"), + "Published Post", + "This post is published.", + new Dictionary { ["draft"] = false } + ); + + // Create a draft post + FileSystemHelper.CreateMarkdownFile( + Path.Combine(testDir, "Posts", "draft-post.md"), + "Draft Post", + "This post is a draft.", + new Dictionary { ["draft"] = true } + ); + + FileSystemHelper.CreateRazorTemplate( + Path.Combine(testDir, "Posts", "template.razor"), + @"@page ""/posts/{Slug}"" +

@Title

+
@Body
" + ); + + // Act + var result = await RunBlakeCommandAsync(["bake", testDir, "--includeDrafts"]); + + // Assert + Assert.Equal(0, result.ExitCode); + + // Both posts should be generated as razor files + FileSystemHelper.AssertFileExists(Path.Combine(testDir, ".generated", "posts", "PublishedPost.razor")); + FileSystemHelper.AssertFileExists(Path.Combine(testDir, ".generated", "posts", "DraftPost.razor")); + + // Content index should be created + var indexPath = Path.Combine(testDir, ".generated", "GeneratedContentIndex.cs"); + FileSystemHelper.AssertFileExists(indexPath); + + // Content index should contain published post but not draft post + var indexContent = File.ReadAllText(indexPath); + Assert.Contains("Published Post", indexContent); + Assert.DoesNotContain("Draft Post", indexContent); + } + [Fact] public async Task BlakeBake_WithTemplateInSameFolder_UsesTemplate() { From 95502e5b408051547cb6e46d99565faa6a8d12f8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 12:06:30 +0000 Subject: [PATCH 3/3] Add clarifying comment about Draft property in generated index Co-authored-by: matt-goldman <19944129+matt-goldman@users.noreply.github.com> --- src/Blake.BuildTools/Generator/ContentIndexBuilder.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Blake.BuildTools/Generator/ContentIndexBuilder.cs b/src/Blake.BuildTools/Generator/ContentIndexBuilder.cs index 06e12f7..74b3c1a 100644 --- a/src/Blake.BuildTools/Generator/ContentIndexBuilder.cs +++ b/src/Blake.BuildTools/Generator/ContentIndexBuilder.cs @@ -32,6 +32,8 @@ public static void WriteIndex(string outputPath, List allPages, bool if (page.Date.HasValue) sb.AppendLine( $" 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()},"); sb.AppendLine($" IconIdentifier = @\"{page.IconIdentifier}\","); if (page.Tags.Count > 0)