Skip to content

Commit c82078b

Browse files
NetdocsCopilot
andcommitted
feat(tags): warn when the tags marker renders an empty index
A tags page whose index is empty renders as a blank body, which looks like a bug. Emit a build warning when the '<!-- material/tags -->' marker is present but no tags were collected (no page declared 'tags:' front matter, or they were all hidden as shadow tags), so the empty page is diagnosable instead of silent. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a8a203e commit c82078b

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/Netdocs.Plugins/TagsPlugin.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Text.Json;
2+
using Microsoft.Extensions.Logging;
23
using Netdocs.Abstractions;
34
using Netdocs.Core.Content;
45

@@ -79,10 +80,25 @@ private static void RenderTagIndex(SiteContext site, SortedDictionary<string, Li
7980
var markdown = new System.Text.StringBuilder();
8081
RenderNode(root, 0, markdown);
8182

83+
var replaced = 0;
8284
foreach (var page in site.Pages)
8385
{
8486
if (page.RawMarkdown.Contains(marker, StringComparison.Ordinal))
87+
{
8588
page.RawMarkdown = page.RawMarkdown.Replace(marker, markdown.ToString());
89+
replaced++;
90+
}
91+
}
92+
93+
// A tags page with an empty index renders as a blank body, which looks like a bug. Surface
94+
// why: either no page declared front-matter tags, or they were all hidden as shadow tags.
95+
if (replaced > 0 && index.Count == 0)
96+
{
97+
var log = site.LoggerFactory.CreateLogger("tags");
98+
log.LogWarning(
99+
"Tags marker '<!-- material/tags -->' found on {Pages} page(s) but the tag index is empty; " +
100+
"the tags page will be blank. Add 'tags:' front matter to pages, or check shadow-tag settings.",
101+
replaced);
86102
}
87103
}
88104

0 commit comments

Comments
 (0)