@@ -41,12 +41,11 @@ public DocumentationGroup(
41
41
)
42
42
{
43
43
Depth = depth ;
44
- var foundIndex = ProcessTocItems ( toc , lookup , folderLookup , depth , out var groups , out var files , out var navigationItems ) ;
44
+ Index = ProcessTocItems ( index , toc , lookup , folderLookup , depth , out var groups , out var files , out var navigationItems ) ;
45
45
46
46
GroupsInOrder = groups ;
47
47
FilesInOrder = files ;
48
48
NavigationItems = navigationItems ;
49
- Index = index ?? foundIndex ;
50
49
51
50
if ( Index is not null )
52
51
FilesInOrder = FilesInOrder . Except ( [ Index ] ) . ToList ( ) ;
@@ -55,19 +54,19 @@ public DocumentationGroup(
55
54
}
56
55
57
56
private MarkdownFile ? ProcessTocItems (
57
+ MarkdownFile ? configuredIndex ,
58
58
IReadOnlyCollection < ITocItem > toc ,
59
59
IDictionary < string , DocumentationFile > lookup ,
60
60
IDictionary < string , DocumentationFile [ ] > folderLookup ,
61
61
int depth ,
62
62
out List < DocumentationGroup > groups ,
63
63
out List < MarkdownFile > files ,
64
- out List < INavigationItem > navigationItems
65
- )
64
+ out List < INavigationItem > navigationItems )
66
65
{
67
66
groups = [ ] ;
68
67
navigationItems = [ ] ;
69
68
files = [ ] ;
70
- MarkdownFile ? indexFile = null ;
69
+ var indexFile = configuredIndex ;
71
70
foreach ( var ( tocItem , index ) in toc . Select ( ( t , i ) => ( t , i ) ) )
72
71
{
73
72
if ( tocItem is FileReference file )
@@ -89,9 +88,14 @@ out List<INavigationItem> navigationItems
89
88
}
90
89
91
90
files . Add ( md ) ;
92
- navigationItems . Add ( new FileNavigation ( index , depth , md ) ) ;
93
91
if ( file . Path . EndsWith ( "index.md" ) && d is MarkdownFile i )
94
92
indexFile ??= i ;
93
+
94
+ // add the page to navigation items unless it's the index file
95
+ // the index file can either be the discovered `index.md` or the parent group's
96
+ // explicit index page. E.g. when grouping related files together.
97
+ if ( indexFile != md )
98
+ navigationItems . Add ( new FileNavigation ( index , depth , md ) ) ;
95
99
}
96
100
else if ( tocItem is FolderReference folder )
97
101
{
0 commit comments