diff --git a/src/Elastic.ApiExplorer/ApiViewModel.cs b/src/Elastic.ApiExplorer/ApiViewModel.cs index 6541365c4..0cc7d464e 100644 --- a/src/Elastic.ApiExplorer/ApiViewModel.cs +++ b/src/Elastic.ApiExplorer/ApiViewModel.cs @@ -37,6 +37,7 @@ public GlobalLayoutViewModel CreateGlobalLayoutModel() => Previous = null, Next = null, NavigationHtml = NavigationHtml, + NavigationFileName = string.Empty, UrlPathPrefix = BuildContext.UrlPathPrefix, AllowIndexing = BuildContext.AllowIndexing, CanonicalBaseUrl = BuildContext.CanonicalBaseUrl, diff --git a/src/Elastic.ApiExplorer/OpenApiGenerator.cs b/src/Elastic.ApiExplorer/OpenApiGenerator.cs index 66dab39cc..cb08b4cde 100644 --- a/src/Elastic.ApiExplorer/OpenApiGenerator.cs +++ b/src/Elastic.ApiExplorer/OpenApiGenerator.cs @@ -288,11 +288,11 @@ private async Task Render(INavigationItem current, T page, ApiRend if (!outputFile.Directory!.Exists) outputFile.Directory.Create(); - var navigationHtml = await navigationRenderer.RenderNavigation(current.NavigationRoot, new Uri("http://ignored.example"), INavigationHtmlWriter.AllLevels, ctx); + var navigationRenderResult = await navigationRenderer.RenderNavigation(current.NavigationRoot, new Uri("http://ignored.example"), INavigationHtmlWriter.AllLevels, ctx); renderContext = renderContext with { CurrentNavigation = current, - NavigationHtml = navigationHtml + NavigationHtml = navigationRenderResult.Html }; await using var stream = _writeFileSystem.FileStream.New(outputFile.FullName, FileMode.OpenOrCreate); await page.RenderAsync(stream, renderContext, ctx); diff --git a/src/Elastic.Documentation.Site/Assets/main.ts b/src/Elastic.Documentation.Site/Assets/main.ts index 1eb75e5af..e35c9a59c 100644 --- a/src/Elastic.Documentation.Site/Assets/main.ts +++ b/src/Elastic.Documentation.Site/Assets/main.ts @@ -15,15 +15,23 @@ import { $, $$ } from 'select-dom' import { UAParser } from 'ua-parser-js' const { getOS } = new UAParser() +const isLazyLoadNavigationEnabled = + $('meta[property="docs:feature:lazy-load-navigation"]')?.content === 'true' document.addEventListener('htmx:load', function (event) { - console.log('htmx:load') - console.log(event.detail) initTocNav() initHighlight() initCopyButton() initTabs() - initNav() + + // We do this so that the navigation is not initialized twice + if (isLazyLoadNavigationEnabled) { + if (event.detail.elt.id === 'nav-tree') { + initNav() + } + } else { + initNav() + } initSmoothScroll() openDetailsWithAnchor() initDismissibleBanner() diff --git a/src/Elastic.Documentation.Site/Layout/_Head.cshtml b/src/Elastic.Documentation.Site/Layout/_Head.cshtml index ef3904a60..4bdbe5a38 100644 --- a/src/Elastic.Documentation.Site/Layout/_Head.cshtml +++ b/src/Elastic.Documentation.Site/Layout/_Head.cshtml @@ -34,3 +34,4 @@ { } + diff --git a/src/Elastic.Documentation.Site/Layout/_PagesNav.cshtml b/src/Elastic.Documentation.Site/Layout/_PagesNav.cshtml index baec6f8de..1ed9e8bf3 100644 --- a/src/Elastic.Documentation.Site/Layout/_PagesNav.cshtml +++ b/src/Elastic.Documentation.Site/Layout/_PagesNav.cshtml @@ -1,9 +1,9 @@ @inherits RazorSlice