Skip to content

Commit 6a710e0

Browse files
authored
Add simple header for IsPrimaryNavEnabled==false (#802)
1 parent d6d7425 commit 6a710e0

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

src/Elastic.Markdown/Slices/HtmlWriter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ private async Task<string> RenderLayout(MarkdownFile markdown, MarkdownDocument
100100

101101
var slice = Index.Create(new IndexViewModel
102102
{
103+
DocSetName = DocumentationSet.Name,
103104
Title = markdown.Title ?? "[TITLE NOT SET]",
104105
Description = markdown.YamlFrontMatter?.Description ?? descriptionGenerator.GenerateDescription(document),
105106
TitleRaw = markdown.TitleRaw ?? "[TITLE NOT SET]",

src/Elastic.Markdown/Slices/Index.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
@functions {
55
public LayoutViewModel LayoutModel => new()
66
{
7+
DocSetName = Model.DocSetName,
78
Title = $"Elastic Documentation: {Model.Title}",
89
Description = Model.Description,
910
PageTocItems = Model.PageTocItems.Where(i => i is { Level: 2 or 3 }).ToList(),
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
@inherits RazorSlice<LayoutViewModel>
2-
3-
<div id="elastic-nav"></div>
4-
<script src="https://www.elastic.co/elastic-nav.js"></script>
52
@if (Model.Features.IsPrimaryNavEnabled)
63
{
4+
<div id="elastic-nav"></div>
5+
<script src="https://www.elastic.co/elastic-nav.js"></script>
76
@await RenderPartialAsync(_SecondaryNav.Create(Model))
87
}
8+
else
9+
{
10+
<header class="sticky top-0 z-50 bg-blue-developer text-white text-lg font-semibold h-(--offset-top) flex items-center px-6">
11+
<div class="container mx-auto">
12+
<div class="flex justify-between items-center">
13+
<label role="button" class="md:hidden cursor-pointer" for="pages-nav-hamburger">
14+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-8">
15+
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25H12"/>
16+
</svg>
17+
</label>
18+
<a href="@Model.Link("/")" class="flex items-center gap-2">
19+
<img src="@Model.Static("logo-elastic-glyph-color.svg")" alt="" width="32" height="32">
20+
@Model.DocSetName
21+
</a>
22+
</div>
23+
</div>
24+
</header>
25+
}

src/Elastic.Markdown/Slices/_ViewModels.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Elastic.Markdown.Slices;
1010

1111
public class IndexViewModel
1212
{
13+
public required string DocSetName { get; init; }
1314
public required string Title { get; init; }
1415
public required string Description { get; init; }
1516
public required string TitleRaw { get; init; }
@@ -32,6 +33,8 @@ public class IndexViewModel
3233

3334
public class LayoutViewModel
3435
{
36+
public required string DocSetName { get; init; }
37+
3538
/// Used to identify the navigation for the current compilation
3639
/// We want to reset users sessionStorage every time this changes to invalidate
3740
/// the guids that no longer exist
Lines changed: 16 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)