Skip to content

Commit 89c4049

Browse files
robertmclawsclaude
andcommitted
Skip auto-navigation population when template defines explicit sections
When a MintlifyTemplate specifies Tabs, Anchors, Dropdowns, or Products directly in the <Navigation> XML, the renderer was still calling PopulateNavigationFromPath which unconditionally initialized Pages and auto-discovered MDX files from disk. This produced a spurious "navigation.pages" block alongside the explicit "navigation.tabs" in the output docs.json. Fix by checking for explicit navigation sections after loading the template config and skipping both PopulateNavigationFromPath and BuildNavigationStructure when they are present. The NavigationType-based auto-generation path (where Pages are discovered then moved to a Tab by ApplyNavigationType) is unaffected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3350374 commit 89c4049

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

src/CloudNimble.DotNetDocs.Mintlify/MintlifyRenderer.cs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,27 @@ public async Task RenderAsync(DocAssembly? model)
136136
.Where(d => !string.IsNullOrWhiteSpace(d))
137137
.ToArray();
138138

139-
// First: Discover existing MDX files in documentation root, preserving template navigation
140-
// Exclude DocumentationReference output directories to prevent them from being treated as conceptual docs
141-
_docsJsonManager.PopulateNavigationFromPath(Context.DocumentationRootPath, new[] { ".mdx" }, includeApiReference: false, preserveExisting: true, excludeDirectories: excludeDirectories);
142-
143-
// Second: Add API reference content to existing navigation ONLY if model exists
144-
if (model is not null)
145-
{
146-
BuildNavigationStructure(_docsJsonManager.Configuration!, model);
139+
// Determine whether the template already defines explicit navigation sections.
140+
// When Tabs, Anchors, Dropdowns, or Products are present, all navigation is
141+
// managed by the template — auto-discovery into Pages would produce a spurious
142+
// parallel "pages" block alongside the explicit sections.
143+
var templateNav = _docsJsonManager.Configuration?.Navigation;
144+
var hasExplicitSections = templateNav?.Tabs is not null
145+
|| templateNav?.Anchors is not null
146+
|| templateNav?.Dropdowns is not null
147+
|| templateNav?.Products is not null;
148+
149+
if (!hasExplicitSections)
150+
{
151+
// First: Discover existing MDX files in documentation root, preserving template navigation
152+
// Exclude DocumentationReference output directories to prevent them from being treated as conceptual docs
153+
_docsJsonManager.PopulateNavigationFromPath(Context.DocumentationRootPath, new[] { ".mdx" }, includeApiReference: false, preserveExisting: true, excludeDirectories: excludeDirectories);
154+
155+
// Second: Add API reference content to existing navigation ONLY if model exists
156+
if (model is not null)
157+
{
158+
BuildNavigationStructure(_docsJsonManager.Configuration!, model);
159+
}
147160
}
148161

149162
// Third: Apply NavigationType from template to move root content to Tabs/Products if configured

0 commit comments

Comments
 (0)