@@ -44,19 +44,21 @@ public string Render(string markdown, IFileInfo? source)
4444 return MarkdownFile . CreateHtml ( parsed ) ;
4545 }
4646
47- public async Task < ( string , string ) > RenderLayout ( MarkdownFile markdown , Cancel ctx = default )
47+ public async Task < RenderResult > RenderLayout ( MarkdownFile markdown , Cancel ctx = default )
4848 {
4949 var document = await markdown . ParseFullAsync ( ctx ) ;
5050 return await RenderLayout ( markdown , document , ctx ) ;
5151 }
5252
53- private async Task < ( string , string ) > RenderLayout ( MarkdownFile markdown , MarkdownDocument document , Cancel ctx = default )
53+ private async Task < RenderResult > RenderLayout ( MarkdownFile markdown , MarkdownDocument document , Cancel ctx = default )
5454 {
5555 var html = MarkdownFile . CreateHtml ( document ) ;
5656 await DocumentationSet . Tree . Resolve ( ctx ) ;
5757
5858 var fullNavigationHtml = await NavigationHtmlWriter . RenderNavigation ( markdown . NavigationRoot , markdown . NavigationSource , - 1 , ctx ) ;
59- var miniNavigationHtml = await NavigationHtmlWriter . RenderNavigation ( markdown . NavigationRoot , markdown . NavigationSource , 1 , ctx ) ;
59+ var miniNavigationHtml = DocumentationSet . Context . Configuration . Features . LazyLoadNavigation
60+ ? await NavigationHtmlWriter . RenderNavigation ( markdown . NavigationRoot , markdown . NavigationSource , 1 , ctx )
61+ : "lazy navigation feature disabled" ;
6062
6163 var current = PositionalNavigation . GetCurrent ( markdown ) ;
6264 var previous = PositionalNavigation . GetPrevious ( markdown ) ;
@@ -116,7 +118,7 @@ public string Render(string markdown, IFileInfo? source)
116118 PreviousDocument = previous ,
117119 NextDocument = next ,
118120 Parents = parents ,
119- NavigationHtml = miniNavigationHtml ,
121+ NavigationHtml = DocumentationSet . Configuration . Features . LazyLoadNavigation ? miniNavigationHtml : fullNavigationHtml ,
120122 UrlPathPrefix = markdown . UrlPathPrefix ,
121123 AppliesTo = markdown . YamlFrontMatter ? . AppliesTo ,
122124 GithubEditUrl = editUrl ,
@@ -133,7 +135,12 @@ public string Render(string markdown, IFileInfo? source)
133135 Products = allProducts ,
134136 VersionsConfig = DocumentationSet . Context . VersionsConfig
135137 } ) ;
136- return ( fullNavigationHtml , await slice . RenderAsync ( cancellationToken : ctx ) ) ;
138+ return new RenderResult
139+ {
140+ Html = await slice . RenderAsync ( cancellationToken : ctx ) ,
141+ FullNavigationPartialHtml = fullNavigationHtml
142+ } ;
143+
137144 }
138145
139146 public async Task < MarkdownDocument > WriteAsync ( IFileInfo outputFile , MarkdownFile markdown , IConversionCollector ? collector , Cancel ctx = default )
@@ -161,10 +168,20 @@ public async Task<MarkdownDocument> WriteAsync(IFileInfo outputFile, MarkdownFil
161168 var document = await markdown . ParseFullAsync ( ctx ) ;
162169
163170 var rendered = await RenderLayout ( markdown , document , ctx ) ;
164- collector ? . Collect ( markdown , document , rendered . Item2 ) ;
165- await writeFileSystem . File . WriteAllTextAsync ( path , rendered . Item2 , ctx ) ;
166- await writeFileSystem . File . WriteAllTextAsync ( path . Replace ( ".html" , ".nav.html" ) , rendered . Item1 , ctx ) ;
171+ collector ? . Collect ( markdown , document , rendered . Html ) ;
172+ await writeFileSystem . File . WriteAllTextAsync ( path , rendered . Html , ctx ) ;
173+
174+ if ( DocumentationSet . Configuration . Features . LazyLoadNavigation )
175+ {
176+ await writeFileSystem . File . WriteAllTextAsync ( path . Replace ( ".html" , ".nav.html" ) , rendered . FullNavigationPartialHtml , ctx ) ;
177+ }
167178 return document ;
168179 }
169180
170181}
182+
183+ public record RenderResult
184+ {
185+ public required string Html { get ; init ; }
186+ public required string FullNavigationPartialHtml { get ; init ; }
187+ }
0 commit comments