44
55using System . Collections . Concurrent ;
66using Elastic . Documentation . Configuration ;
7+ using Elastic . Documentation . Extensions ;
78
89namespace Elastic . Documentation . Site . Navigation ;
910
@@ -12,19 +13,29 @@ public class IsolatedBuildNavigationHtmlWriter(BuildContext context, IRootNaviga
1213{
1314 private readonly ConcurrentDictionary < ( string , int ) , string > _renderedNavigationCache = [ ] ;
1415
15- public async Task < string > RenderNavigation ( IRootNavigationItem < INavigationModel , INavigationItem > currentRootNavigation , Uri navigationSource , int maxLevel , Cancel ctx = default )
16+ public async Task < NavigationRenderResult > RenderNavigation ( IRootNavigationItem < INavigationModel , INavigationItem > currentRootNavigation ,
17+ Uri navigationSource , int maxLevel , Cancel ctx = default )
1618 {
1719 var navigation = context . Configuration . Features . PrimaryNavEnabled || currentRootNavigation . IsUsingNavigationDropdown
1820 ? currentRootNavigation
1921 : siteRoot ;
20-
22+ var id = ShortId . Create ( $ " { ( navigation . Id , maxLevel ) . GetHashCode ( ) } " ) ;
2123 if ( _renderedNavigationCache . TryGetValue ( ( navigation . Id , maxLevel ) , out var value ) )
22- return value ;
23-
24+ {
25+ return new NavigationRenderResult
26+ {
27+ Html = value ,
28+ Id = id
29+ } ;
30+ }
2431 var model = CreateNavigationModel ( navigation , maxLevel ) ;
2532 value = await ( ( INavigationHtmlWriter ) this ) . Render ( model , ctx ) ;
2633 _renderedNavigationCache [ ( navigation . Id , maxLevel ) ] = value ;
27- return value ;
34+ return new NavigationRenderResult
35+ {
36+ Html = value ,
37+ Id = id
38+ } ;
2839 }
2940
3041 private NavigationViewModel CreateNavigationModel ( IRootNavigationItem < INavigationModel , INavigationItem > navigation , int maxLevel ) =>
0 commit comments