Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ internal TableOfContentsTree(
TreeCollector.Collect(source, this);
}

protected override DocumentationGroup DefaultNavigation => this;

}

[DebuggerDisplay("Group >{Depth} {FolderName} ({NavigationItems.Count} items)")]
Expand Down Expand Up @@ -147,6 +149,8 @@ public class DocumentationGroup : INavigationGroup

public string FolderName { get; }

protected virtual DocumentationGroup DefaultNavigation => this;

protected DocumentationGroup(
TableOfContentsTreeCollector treeCollector,
BuildContext context,
Expand Down Expand Up @@ -178,7 +182,13 @@ protected DocumentationGroup(
NavigationSource = navigationSource;
_treeCollector = treeCollector;
Depth = depth;
toplevelTree ??= this;
// Virtual calls don't use state so while ugly not an issue
// We'll need to address this more structurally
// ReSharper disable VirtualMemberCallInConstructor
toplevelTree ??= DefaultNavigation;
if (parent?.Depth == 0)
toplevelTree = DefaultNavigation;
// ReSharper enable VirtualMemberCallInConstructor
NavigationRoot = toplevelTree;
// ReSharper restore VirtualMemberCallInConstructor
Index = ProcessTocItems(context, toplevelTree, index, lookups, depth, ref fileIndex, out var groups, out var files, out var navigationItems);
Expand Down
Loading