Skip to content

Commit 1b88283

Browse files
authored
Refactor navigation further to be less reliant on markdown properties. (#1357)
* Refactor markdown and layout rendering by decoupling from `GlobalLayoutViewModel`. Streamline layout handling, enhance navigation item visibility logic, and rework documentation file structures for improved maintainability. (#1353) * Refactor markdown and layout rendering by decoupling from `GlobalLayoutViewModel`. Streamline layout handling, enhance navigation item visibility logic, and rework documentation file structures for improved maintainability. `Hidden` is a pure navigation property now as its removed from `MarkdownFile`. `GetCurrentNavigation()` is now non nullable * Ensure NavigationIndex is a navigation property. * Update advertising of landing-page-path * update landing page path output * Add xmldocs for IsPhantom (cherry picked from commit 8df9149) * Ensure links.json considers all navigation items (cherry picked from commit 40f1332d45593f7c0bbbaf08ac540807ad5b5395) * remove commented line * update test file output order
1 parent 5d4b323 commit 1b88283

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+380
-325
lines changed

src/Elastic.ApiExplorer/Endpoints/ApiEndpoint.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,13 @@ public EndpointNavigationItem(int depth, string url, ApiEndpoint apiEndpoint, La
5858
public ApiEndpoint Index { get; }
5959
public string Url { get; }
6060
public string NavigationTitle { get; }
61+
public bool Hidden => false;
6162

6263
public IReadOnlyCollection<OperationNavigationItem> NavigationItems { get; set; } = [];
6364

6465
public INodeNavigationItem<INavigationModel, INavigationItem> NavigationRoot { get; }
6566

6667
public INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; }
68+
69+
public int NavigationIndex { get; set; }
6770
}

src/Elastic.ApiExplorer/Endpoints/EndpointView.cshtml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,15 @@
77
{
88
DocSetName = "Api Explorer",
99
Description = "",
10-
Layout = null,
11-
PageTocItems = [],
1210
CurrentNavigationItem = Model.CurrentNavigationItem,
1311
Previous = null,
1412
Next = null,
1513
NavigationHtml = Model.NavigationHtml,
16-
LegacyPage = null,
1714
UrlPathPrefix = null,
18-
GithubEditUrl = null,
19-
ReportIssueUrl = null,
2015
AllowIndexing = false,
2116
CanonicalBaseUrl = null,
2217
GoogleTagManager = new GoogleTagManagerConfiguration(),
2318
Features = new FeatureFlags([]),
24-
Parents =
25-
[
26-
],
27-
Products = null,
2819
StaticFileContentHashProvider = Model.StaticFileContentHashProvider
2920
};
3021
}

src/Elastic.ApiExplorer/Landing/LandingNavigationItem.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ public class LandingNavigationItem : INodeNavigationItem<ApiLanding, EndpointNav
3434
public int Depth { get; }
3535
public ApiLanding Index { get; }
3636
public INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; }
37+
public int NavigationIndex { get; set; }
3738
public IReadOnlyCollection<EndpointNavigationItem> NavigationItems { get; set; } = [];
3839
public string Url { get; }
40+
public bool Hidden => false;
3941

4042
//TODO
4143
public string NavigationTitle { get; } = "API Documentation";

src/Elastic.ApiExplorer/Landing/LandingView.cshtml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,15 @@
77
{
88
DocSetName = "Api Explorer",
99
Description = "",
10-
Layout = null,
11-
PageTocItems = [],
1210
CurrentNavigationItem = Model.CurrentNavigationItem,
1311
Previous = null,
1412
Next = null,
1513
NavigationHtml = Model.NavigationHtml,
16-
LegacyPage = null,
1714
UrlPathPrefix = null,
18-
GithubEditUrl = null,
19-
ReportIssueUrl = null,
2015
AllowIndexing = false,
2116
CanonicalBaseUrl = null,
2217
GoogleTagManager = new GoogleTagManagerConfiguration(),
2318
Features = new FeatureFlags([]),
24-
Parents =
25-
[
26-
],
27-
Products = null,
2819
StaticFileContentHashProvider = Model.StaticFileContentHashProvider
2920
};
3021
}

src/Elastic.ApiExplorer/Operations/OperationNavigationItem.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ public OperationNavigationItem(int depth, string url, ApiOperation apiOperation,
4747
public int Depth { get; }
4848
public ApiOperation Model { get; }
4949
public string Url { get; }
50+
public bool Hidden => false;
5051

5152
public string NavigationTitle { get; }
5253

5354
public INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; }
55+
56+
public int NavigationIndex { get; set; }
57+
5458
}

src/Elastic.ApiExplorer/Operations/OperationView.cshtml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,15 @@
77
{
88
DocSetName = "Api Explorer",
99
Description = "",
10-
Layout = null,
11-
PageTocItems = [],
1210
CurrentNavigationItem = Model.CurrentNavigationItem,
1311
Previous = null,
1412
Next = null,
1513
NavigationHtml = Model.NavigationHtml,
16-
LegacyPage = null,
1714
UrlPathPrefix = null,
18-
GithubEditUrl = null,
19-
ReportIssueUrl = null,
2015
AllowIndexing = false,
2116
CanonicalBaseUrl = null,
2217
GoogleTagManager = new GoogleTagManagerConfiguration(),
2318
Features = new FeatureFlags([]),
24-
Parents =
25-
[
26-
],
27-
Products = null,
2819
StaticFileContentHashProvider = Model.StaticFileContentHashProvider
2920
};
3021
}

src/Elastic.Documentation.Configuration/TableOfContents/ITocItem.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,20 @@ public record TocReference(Uri Source, ITableOfContentsScope TableOfContentsScop
2222
{
2323
public IReadOnlyDictionary<Uri, TocReference> TocReferences { get; } =
2424
Children.OfType<TocReference>().ToDictionary(kv => kv.Source, kv => kv);
25+
26+
/// <summary>
27+
/// A phantom table of contents is a table of contents that is not rendered in the UI but is used to generate the TOC.
28+
/// This should be used sparingly and needs explicit configuration in navigation.yml.
29+
/// It's typically used for container TOC that holds various other TOC's where its children are rehomed throughout the navigation.
30+
/// <para>Examples of phantom toc's:</para>
31+
/// <list type="">
32+
/// <item> - toc: elasticsearch://reference</item>
33+
/// <item> - toc: docs-content://</item>
34+
/// </list>
35+
/// <para>Because navigation.yml does exhaustive checks to ensure all toc.yml files are referenced, marking these containers as phantoms
36+
/// ensures that these skip validation checks
37+
/// </para>
38+
/// </summary>
39+
public bool IsPhantom { get; init; }
2540
}
41+

src/Elastic.Documentation.Site/Layout/_Head.cshtml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@inherits RazorSlice<Elastic.Documentation.Site.GlobalLayoutViewModel>
22
@using FontPreloader = Elastic.Documentation.Site.FileProviders.FontPreloader
3-
<head hx-head="merge">
43
<meta charset="utf-8">
54
<title>@Model.Title</title>
65
<meta name="description" content="@Model.Description">
@@ -35,9 +34,3 @@
3534
{
3635
<meta property="og:url" content="@Model.CanonicalUrl" />
3736
}
38-
@if (!string.IsNullOrEmpty(Model.Products))
39-
{
40-
<meta class="elastic" name="product_name" content="@(Model.Products)"/>
41-
<meta name="DC.subject" content="@(Model.Products)"/>
42-
}
43-
</head>

src/Elastic.Documentation.Site/Layout/_SecondaryNav.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<nav id="secondary-nav" class="bg-grey-10 border-t-1 border-grey-20 font-sans font-semibold text-sm text-ink-light md:text-base">
33
<div class="max-w-(--max-layout-width) flex mx-auto justify-between items-center p-6">
44
<div class="flex gap-2 flex-nowrap items-center">
5-
@if (Model.Layout != LayoutName.LandingPage)
5+
@if (Model.RenderHamburgerIcon)
66
{
77
@* ReSharper disable once Html.IdNotResolved *@
88
<label role="button" class="md:hidden cursor-pointer" for="pages-nav-hamburger">

src/Elastic.Documentation.Site/Navigation/INavigationItem.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ public interface INavigationItem
3030
/// TODO: This should be read-only however currently needs the setter in assembler.
3131
/// </remarks>
3232
INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; }
33+
34+
bool Hidden { get; }
35+
36+
int NavigationIndex { get; set; }
3337
}
3438

3539
/// Represents a leaf node in the navigation tree with associated model data.

0 commit comments

Comments
 (0)