-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy path_Layout.cshtml
More file actions
97 lines (92 loc) · 3.02 KB
/
_Layout.cshtml
File metadata and controls
97 lines (92 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
@inherits RazorLayoutSlice<MarkdownLayoutViewModel>
@using Elastic.Markdown
@implements IUsesLayout<Elastic.Documentation.Site._GlobalLayout, GlobalLayoutViewModel>
@functions {
public GlobalLayoutViewModel LayoutModel => Model;
protected override async Task ExecuteSectionAsync(string name)
{
if (name == GlobalSections.Footer && Model.Layout is not MarkdownPageLayout.Archive)
{
//this ensures we forward footer sections declared in this project into to GlobalLayout view's section
await RenderSectionAsync(GlobalSections.Footer);
}
if (name == GlobalSections.Head)
{
//this ensures we forward head sections declared in this project into to GlobalLayout view's section
await RenderSectionAsync(GlobalSections.Head);
}
}
private bool RenderHeaderAndFooter => Model.Layout is not MarkdownPageLayout.FullSearch;
private async Task RenderDefault()
{
<div class="relative">
<div class="min-h-screen
w-full
max-w-(--max-layout-width)
mx-auto
md:px-4
">
<div class="min-h-screen grid grid-cols-1 md:grid-cols-[var(--max-sidebar-width)_1fr] gap-4">
@await RenderPartialAsync(_PagesNav.Create<GlobalLayoutViewModel>(Model))
<main id="content-container" class="min-w-0 lg:grid lg:grid-cols-[minmax(0,var(--max-text-width))_minmax(0,var(--max-sidebar-width))] justify-end mx-4 gap-4">
@await RenderPartialAsync(_TableOfContents.Create(Model))
@{
var breadcrumbs = Model.Breadcrumbs.ToList();
var breadcrumbVisible = breadcrumbs.Count > 0 && (breadcrumbs.Count > 1 || Model.BuildType != BuildType.Isolated);
}
<div class="mb-9 mt-0 min-w-0 @(breadcrumbVisible ? "" : "pt-6")">
@await RenderPartialAsync(_Breadcrumbs.Create(Model))
<article id="markdown-content" class="markdown-content min-w-0">
<input type="checkbox" class="hidden" id="pages-nav-hamburger">
@await RenderBodyAsync()
</article>
@await RenderPartialAsync(_PrevNextNav.Create(Model))
</div>
</main>
</div>
</div>
</div>
}
}
@if (RenderHeaderAndFooter)
{
if (Model.BuildType == BuildType.Assembler)
{
@(await RenderPartialAsync(_AssemblerHeader.Create<GlobalLayoutViewModel>(Model)))
}
else
{
@(await RenderPartialAsync(_IsolatedHeader.Create<GlobalLayoutViewModel>(Model)))
}
}
<div id="main-container">
@switch (Model.Layout)
{
case MarkdownPageLayout.NotFound:
await RenderPartialAsync(_NotFound.Create(Model));
break;
case MarkdownPageLayout.LandingPage:
await RenderPartialAsync(_LandingPage.Create(Model));
break;
case MarkdownPageLayout.Archive:
await RenderPartialAsync(_Archive.Create(Model));
break;
case MarkdownPageLayout.FullSearch:
await RenderPartialAsync(_FullSearch.Create(Model));
break;
default:
await RenderDefault();
break;
}
</div>
@if (RenderHeaderAndFooter)
{
if (Model.BuildType == BuildType.Assembler)
{
@(await RenderPartialAsync(_AssemblerFooter.Create<GlobalLayoutViewModel>(Model)))
}
else
{
@(await RenderPartialAsync(_IsolatedFooter.Create<GlobalLayoutViewModel>(Model)))
}
}