Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Elastic.ApiExplorer/Endpoints/ApiEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ public EndpointNavigationItem(int depth, string url, ApiEndpoint apiEndpoint, La
public ApiEndpoint Index { get; }
public string Url { get; }
public string NavigationTitle { get; }
public bool Hidden => false;

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

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

public INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; }

public int NavigationIndex { get; set; }
}
9 changes: 0 additions & 9 deletions src/Elastic.ApiExplorer/Endpoints/EndpointView.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,15 @@
{
DocSetName = "Api Explorer",
Description = "",
Layout = null,
PageTocItems = [],
CurrentNavigationItem = Model.CurrentNavigationItem,
Previous = null,
Next = null,
NavigationHtml = Model.NavigationHtml,
LegacyPage = null,
UrlPathPrefix = null,
GithubEditUrl = null,
ReportIssueUrl = null,
AllowIndexing = false,
CanonicalBaseUrl = null,
GoogleTagManager = new GoogleTagManagerConfiguration(),
Features = new FeatureFlags([]),
Parents =
[
],
Products = null,
StaticFileContentHashProvider = Model.StaticFileContentHashProvider
};
}
Expand Down
2 changes: 2 additions & 0 deletions src/Elastic.ApiExplorer/Landing/LandingNavigationItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public class LandingNavigationItem : INodeNavigationItem<ApiLanding, EndpointNav
public int Depth { get; }
public ApiLanding Index { get; }
public INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; }
public int NavigationIndex { get; set; }
public IReadOnlyCollection<EndpointNavigationItem> NavigationItems { get; set; } = [];
public string Url { get; }
public bool Hidden => false;

//TODO
public string NavigationTitle { get; } = "API Documentation";
Expand Down
9 changes: 0 additions & 9 deletions src/Elastic.ApiExplorer/Landing/LandingView.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,15 @@
{
DocSetName = "Api Explorer",
Description = "",
Layout = null,
PageTocItems = [],
CurrentNavigationItem = Model.CurrentNavigationItem,
Previous = null,
Next = null,
NavigationHtml = Model.NavigationHtml,
LegacyPage = null,
UrlPathPrefix = null,
GithubEditUrl = null,
ReportIssueUrl = null,
AllowIndexing = false,
CanonicalBaseUrl = null,
GoogleTagManager = new GoogleTagManagerConfiguration(),
Features = new FeatureFlags([]),
Parents =
[
],
Products = null,
StaticFileContentHashProvider = Model.StaticFileContentHashProvider
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ public OperationNavigationItem(int depth, string url, ApiOperation apiOperation,
public int Depth { get; }
public ApiOperation Model { get; }
public string Url { get; }
public bool Hidden => false;

public string NavigationTitle { get; }

public INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; }

public int NavigationIndex { get; set; }

}
9 changes: 0 additions & 9 deletions src/Elastic.ApiExplorer/Operations/OperationView.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,15 @@
{
DocSetName = "Api Explorer",
Description = "",
Layout = null,
PageTocItems = [],
CurrentNavigationItem = Model.CurrentNavigationItem,
Previous = null,
Next = null,
NavigationHtml = Model.NavigationHtml,
LegacyPage = null,
UrlPathPrefix = null,
GithubEditUrl = null,
ReportIssueUrl = null,
AllowIndexing = false,
CanonicalBaseUrl = null,
GoogleTagManager = new GoogleTagManagerConfiguration(),
Features = new FeatureFlags([]),
Parents =
[
],
Products = null,
StaticFileContentHashProvider = Model.StaticFileContentHashProvider
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,20 @@ public record TocReference(Uri Source, ITableOfContentsScope TableOfContentsScop
{
public IReadOnlyDictionary<Uri, TocReference> TocReferences { get; } =
Children.OfType<TocReference>().ToDictionary(kv => kv.Source, kv => kv);

/// <summary>
/// A phantom table of contents is a table of contents that is not rendered in the UI but is used to generate the TOC.
/// This should be used sparingly and needs explicit configuration in navigation.yml.
/// It's typically used for container TOC that holds various other TOC's where its children are rehomed throughout the navigation.
/// <para>Examples of phantom toc's:</para>
/// <list type="">
/// <item> - toc: elasticsearch://reference</item>
/// <item> - toc: docs-content://</item>
/// </list>
/// <para>Because navigation.yml does exhaustive checks to ensure all toc.yml files are referenced, marking these containers as phantoms
/// ensures that these skip validation checks
/// </para>
/// </summary>
public bool IsPhantom { get; init; }
}

7 changes: 0 additions & 7 deletions src/Elastic.Documentation.Site/Layout/_Head.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@inherits RazorSlice<Elastic.Documentation.Site.GlobalLayoutViewModel>
@using FontPreloader = Elastic.Documentation.Site.FileProviders.FontPreloader
<head hx-head="merge">
<meta charset="utf-8">
<title>@Model.Title</title>
<meta name="description" content="@Model.Description">
Expand Down Expand Up @@ -35,9 +34,3 @@
{
<meta property="og:url" content="@Model.CanonicalUrl" />
}
@if (!string.IsNullOrEmpty(Model.Products))
{
<meta class="elastic" name="product_name" content="@(Model.Products)"/>
<meta name="DC.subject" content="@(Model.Products)"/>
}
</head>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<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">
<div class="max-w-(--max-layout-width) flex mx-auto justify-between items-center p-6">
<div class="flex gap-2 flex-nowrap items-center">
@if (Model.Layout != LayoutName.LandingPage)
@if (Model.RenderHamburgerIcon)
{
@* ReSharper disable once Html.IdNotResolved *@
<label role="button" class="md:hidden cursor-pointer" for="pages-nav-hamburger">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public interface INavigationItem
/// TODO: This should be read-only however currently needs the setter in assembler.
/// </remarks>
INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; }

bool Hidden { get; }

int NavigationIndex { get; set; }
}

/// Represents a leaf node in the navigation tree with associated model data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
}
@foreach (var item in Model.SubTree.NavigationItems)
{
if (item.Hidden)
{
continue;
}
if (item is INodeNavigationItem<INavigationModel, INavigationItem> { NavigationItems.Count: 0, Index: not null } group)
{
<li class="flex group/li pr-8 @(isTopLevel ? "font-semibold mt-6" : "mt-4")">
Expand Down
42 changes: 6 additions & 36 deletions src/Elastic.Documentation.Site/_GlobalLayout.cshtml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
@inherits RazorLayoutSlice<GlobalLayoutViewModel>
<!DOCTYPE html>
<html lang="en" class="h-screen" xmlns="http://www.w3.org/1999/html">
@await RenderPartialAsync(_Head.Create(Model))

@{
var layout = Model.Layout;
}
<head hx-head="merge">
@await RenderPartialAsync(_Head.Create(Model))
@await RenderSectionAsync(GlobalSections.Head)
</head>

<body
class="group/body text-ink has-[#primary-nav-hamburger:checked]:overflow-hidden"
Expand All @@ -18,38 +17,9 @@
}
@(await RenderPartialAsync(_Header.Create(Model)))
<div id="main-container" class="flex flex-col items-center border-t-1 border-grey-20">
@switch (layout)
{
case LayoutName.NotFound:
await RenderPartialAsync(_NotFound.Create(Model));
break;
case LayoutName.LandingPage:
await RenderPartialAsync(_LandingPage.Create(Model));
break;
case LayoutName.Archive:
await RenderPartialAsync(_Archive.Create(Model));
break;
default:
await RenderBodyAsync();
break;
}
@(await RenderBodyAsync())
</div>
@await RenderPartialAsync(_Footer.Create(Model))
@if (layout is not LayoutName.Archive)
{
<aside id="dismissible-banner" class="admonition tip">
<div class="container flex justify-between items-center mx-auto">
<p>
Welcome to the docs for the <a class="link text-base" href="/docs/get-started/versioning-availability#find-docs-for-your-product-version">latest Elastic product versions</a>, including Elastic Stack 9.0 and Elastic Cloud Serverless.
To view previous versions, go to <a class="link text-base" target="_blank" href="https://elastic.co/guide">elastic.co/guide</a>.
</p>
<button id="dismissible-button">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12"/>
</svg>
</button>
</div>
</aside>
}
@await RenderSectionAsync(GlobalSections.Footer)
</body>
</html>
34 changes: 14 additions & 20 deletions src/Elastic.Documentation.Site/_ViewModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,41 @@

using Elastic.Documentation.Configuration.Assembler;
using Elastic.Documentation.Configuration.Builder;
using Elastic.Documentation.Legacy;
using Elastic.Documentation.Site.FileProviders;
using Elastic.Documentation.Site.Navigation;

namespace Elastic.Documentation.Site;

public static class GlobalSections
{
public const string Head = "head";
public const string Footer = "footer";
}

public class GlobalLayoutViewModel
{
public required string DocSetName { get; init; }
public string Title { get; set; } = "Elastic Documentation";
public required string Description { get; init; }
public required LayoutName? Layout { get; init; }

public required IReadOnlyCollection<PageTocItem> PageTocItems { get; init; }
public required INavigationItem? CurrentNavigationItem { get; init; }
public required INavigationItem CurrentNavigationItem { get; init; }
public required INavigationItem? Previous { get; init; }
public required INavigationItem? Next { get; init; }

public required string NavigationHtml { get; init; }
public required LegacyPageMapping? LegacyPage { get; init; }
public required string? UrlPathPrefix { get; init; }
public required string? GithubEditUrl { get; init; }
public required string? ReportIssueUrl { get; init; }
public required bool AllowIndexing { get; init; }
public required Uri? CanonicalBaseUrl { get; init; }
public required GoogleTagManagerConfiguration GoogleTagManager { get; init; }
public string? CanonicalUrl => CanonicalBaseUrl is not null ?
new Uri(CanonicalBaseUrl, CurrentNavigationItem?.Url).ToString().TrimEnd('/') : null;

public required FeatureFlags Features { get; init; }

public required INavigationItem[] Parents { get; init; }
// TODO move to @inject
public required GoogleTagManagerConfiguration GoogleTagManager { get; init; }
public required bool AllowIndexing { get; init; }
public required StaticFileContentHashProvider StaticFileContentHashProvider { get; init; }

public required string? Products { get; init; }
public bool RenderHamburgerIcon { get; init; } = true;

public string Static(string path)
{
Expand All @@ -46,19 +49,10 @@ public string Static(string path)
: $"{UrlPathPrefix}/{staticPath}?v={contentHash}";
}

// TODO move to @inject
public required StaticFileContentHashProvider StaticFileContentHashProvider { get; init; }

public string Link(string path)
{
path = path.AsSpan().TrimStart('/').ToString();
return $"{UrlPathPrefix}/{path}";
}
}

public record PageTocItem
{
public required string Heading { get; init; }
public required string Slug { get; init; }
public required int Level { get; init; }
}
1 change: 1 addition & 0 deletions src/Elastic.Markdown/IO/DocumentationFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Elastic.Documentation.Site;
using Elastic.Markdown.Myst;
using Elastic.Markdown.Myst.FrontMatter;
using Elastic.Markdown.Slices;

namespace Elastic.Markdown.IO;

Expand Down
Loading
Loading