Skip to content

Add simple header for IsPrimaryNavEnabled==false #802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2025
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
1 change: 1 addition & 0 deletions src/Elastic.Markdown/Slices/HtmlWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ private async Task<string> RenderLayout(MarkdownFile markdown, MarkdownDocument

var slice = Index.Create(new IndexViewModel
{
DocSetName = DocumentationSet.Name,
Title = markdown.Title ?? "[TITLE NOT SET]",
Description = markdown.YamlFrontMatter?.Description ?? descriptionGenerator.GenerateDescription(document),
TitleRaw = markdown.TitleRaw ?? "[TITLE NOT SET]",
Expand Down
1 change: 1 addition & 0 deletions src/Elastic.Markdown/Slices/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@functions {
public LayoutViewModel LayoutModel => new()
{
DocSetName = Model.DocSetName,
Title = $"Elastic Documentation: {Model.Title}",
Description = Model.Description,
PageTocItems = Model.PageTocItems.Where(i => i is { Level: 2 or 3 }).ToList(),
Expand Down
23 changes: 20 additions & 3 deletions src/Elastic.Markdown/Slices/Layout/_Header.cshtml
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
@inherits RazorSlice<LayoutViewModel>

<div id="elastic-nav"></div>
<script src="https://www.elastic.co/elastic-nav.js"></script>
@if (Model.Features.IsPrimaryNavEnabled)
{
<div id="elastic-nav"></div>
<script src="https://www.elastic.co/elastic-nav.js"></script>
@await RenderPartialAsync(_SecondaryNav.Create(Model))
}
else
{
<header class="sticky top-0 z-50 bg-blue-developer text-white text-lg font-semibold h-(--offset-top) flex items-center px-6">
<div class="container mx-auto">
<div class="flex justify-between items-center">
<label role="button" class="md:hidden cursor-pointer" for="pages-nav-hamburger">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-8">
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25H12"/>
</svg>
</label>
<a href="@Model.Link("/")" class="flex items-center gap-2">
<img src="@Model.Static("logo-elastic-glyph-color.svg")" alt="" width="32" height="32">
@Model.DocSetName
</a>
</div>
</div>
</header>
}
3 changes: 3 additions & 0 deletions src/Elastic.Markdown/Slices/_ViewModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Elastic.Markdown.Slices;

public class IndexViewModel
{
public required string DocSetName { get; init; }
public required string Title { get; init; }
public required string Description { get; init; }
public required string TitleRaw { get; init; }
Expand All @@ -32,6 +33,8 @@ public class IndexViewModel

public class LayoutViewModel
{
public required string DocSetName { get; init; }

/// Used to identify the navigation for the current compilation
/// We want to reset users sessionStorage every time this changes to invalidate
/// the guids that no longer exist
Expand Down
16 changes: 16 additions & 0 deletions src/Elastic.Markdown/_static/logo-elastic-glyph-color.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading