172 lines
6.5 KiB
HTML
172 lines
6.5 KiB
HTML
{{/* variables for enabling/disabling various features */}}
|
|
{{ $blogEnabled := site.Params.features.blog.enable | default false }}
|
|
{{ $blogTitle := site.Params.features.blog.title | default (i18n "posts") }}
|
|
{{ $notesEnabled := site.Params.features.notes.enable | default false }}
|
|
{{ $notesTitle := site.Params.features.notes.title | default (i18n "notes") }}
|
|
{{ $maxVisibleSections := site.Params.topNavbar.maxVisibleSections | default 5 }}
|
|
|
|
{{/* keep backward compatibility for blog post */}}
|
|
{{ if site.Params.enableBlogPost }}
|
|
{{ $blogEnabled = true }}
|
|
{{ end }}
|
|
|
|
{{/* by default, don't use any logo */}}
|
|
{{ $mainLogo := "" }}
|
|
{{ $invertedLogo := "" }}
|
|
{{ $darkLogo := "" }}
|
|
|
|
{{/* if custom logo has been provided, use them */}}
|
|
{{ if site.Params.logo.main }}
|
|
{{ $mainLogo = site.Params.logo.main }}
|
|
{{ end }}
|
|
{{ if site.Params.logo.inverted }}
|
|
{{ $invertedLogo = site.Params.logo.inverted }}
|
|
{{ end }}
|
|
{{ if site.Params.logo.dark }}
|
|
{{ $darkLogo = site.Params.logo.dark }}
|
|
{{ end }}
|
|
|
|
{{/* resize the logos. don't resize svg because it is not supported */}}
|
|
{{ if $mainLogo }}
|
|
{{ $mainLogo = resources.Get $mainLogo}}
|
|
{{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }}
|
|
{{ $mainLogo = $mainLogo.Resize "42x" }}
|
|
{{ end }}
|
|
{{ $mainLogo = $mainLogo.RelPermalink}}
|
|
{{ end }}
|
|
|
|
{{ if $invertedLogo }}
|
|
{{ $invertedLogo = resources.Get $invertedLogo}}
|
|
{{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}}
|
|
{{ $invertedLogo = $invertedLogo.Resize "42x" }}
|
|
{{ end }}
|
|
{{ $invertedLogo = $invertedLogo.RelPermalink}}
|
|
{{ end }}
|
|
|
|
{{ if $darkLogo }}
|
|
{{ $darkLogo = resources.Get $darkLogo}}
|
|
{{ if and $darkLogo (ne $darkLogo.MediaType.SubType "svg")}}
|
|
{{ $darkLogo = $darkLogo.Resize "42x" }}
|
|
{{ end }}
|
|
{{ $darkLogo = $darkLogo.RelPermalink}}
|
|
{{ end }}
|
|
|
|
{{ $logo := $mainLogo }}
|
|
{{ if .IsHome }}
|
|
{{ $logo = $invertedLogo }}
|
|
{{ end }}
|
|
|
|
{{ $customMenus := site.Params.customMenus }}
|
|
{{ if (index site.Data site.Language.Lang).site.customMenus }}
|
|
{{ $customMenus = (index site.Data site.Language.Lang).site.customMenus }}
|
|
{{ end }}
|
|
|
|
{{ $sections := site.Data.sections }}
|
|
{{ if (index site.Data site.Language.Lang).sections }}
|
|
{{ $sections = (index site.Data site.Language.Lang).sections }}
|
|
{{ end }}
|
|
|
|
{{ $navBarTitle := (index site.Data site.Language.Lang).site.navBarTitle }}
|
|
{{ if not $navBarTitle }}
|
|
{{ $navBarTitle = site.Title }}
|
|
{{ end }}
|
|
|
|
<nav class="navbar navbar-expand-xl top-navbar shadow {{ if .IsHome}}transparent-navbar homepage{{end}}" id="top-navbar">
|
|
<div class="container">
|
|
{{ if not .IsHome }}
|
|
<button class="navbar-toggler navbar-light" id="sidebar-toggler" type="button">
|
|
<i data-feather="sidebar"></i>
|
|
</button>
|
|
{{ end }}
|
|
<a class="navbar-brand" href="{{ site.BaseURL | relLangURL }}">
|
|
{{ if $logo }}
|
|
<img src="{{ $logo }}" id="logo" alt="Logo">
|
|
{{ end }}
|
|
{{- $navBarTitle -}}
|
|
</a>
|
|
<button
|
|
class="navbar-toggler {{if .IsHome}}navbar-dark{{else}}navbar-light{{end}}"
|
|
id="navbar-toggler"
|
|
type="button"
|
|
data-bs-toggle="collapse"
|
|
data-bs-target="#top-nav-items"
|
|
aria-label="menu"
|
|
>
|
|
<i data-feather="menu"></i>
|
|
</button>
|
|
|
|
<div class="collapse navbar-collapse dynamic-navbar" id="top-nav-items">
|
|
<ul class="nav navbar-nav ms-auto">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="{{ if .IsHome }}#home{{else}}{{ site.BaseURL | relLangURL }}#home{{end}}">{{ i18n "home" }}</a>
|
|
</li>
|
|
{{ if $sections }}
|
|
{{ $sectionCount := 1 }}
|
|
{{ range sort $sections "section.weight" }}
|
|
{{ if and (.section.enable) (.section.showOnNavbar)}}
|
|
{{ $sectionCount = add $sectionCount 1}}
|
|
{{ if le $sectionCount $maxVisibleSections }}
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="{{ partial "helpers/get-section-url.html" . }}">{{ .section.name }}</a>
|
|
</li>
|
|
{{ end }}
|
|
{{ end }}
|
|
{{- end }}
|
|
{{ if gt $sectionCount $maxVisibleSections }}
|
|
<li class="nav-item dropdown">
|
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{i18n "more" }}</a>
|
|
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
|
{{ $sectionCount := 1 }}
|
|
{{ range sort $sections "section.weight" }}
|
|
{{ if and (.section.enable) (.section.showOnNavbar) }}
|
|
{{ $sectionCount = add $sectionCount 1}}
|
|
{{ if gt $sectionCount $maxVisibleSections }}
|
|
<a class="dropdown-item" href="{{ partial "helpers/get-section-url.html" . }}">{{ .section.name }}</a>
|
|
{{ end }}
|
|
{{ end }}
|
|
{{- end }}
|
|
</div>
|
|
</li>
|
|
{{ end }}
|
|
{{- end }}
|
|
{{ $shouldAddSeparator:= partial "helpers/add-navbar-separator.html" . }}
|
|
{{ if $shouldAddSeparator }}
|
|
<div id="top-navbar-divider"></div>
|
|
{{ end }}
|
|
{{ if $blogEnabled }}
|
|
<li class="nav-item">
|
|
<a class="nav-link" id="blog-link" href="{{ path.Join (site.BaseURL | relLangURL) "posts" }}">{{ $blogTitle }}</a>
|
|
</li>
|
|
{{ end }}
|
|
{{ if $notesEnabled }}
|
|
<li class="nav-item">
|
|
<a class="nav-link" id="note-link" href="{{ path.Join (site.BaseURL | relLangURL) "notes" }}">{{ $notesTitle }}</a>
|
|
</li>
|
|
{{ end }}
|
|
{{ range $customMenus }}
|
|
{{ if (not .hideFromNavbar) }}
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="{{ .url }}">{{ .name }}</a>
|
|
</li>
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ if .IsTranslated }}
|
|
{{ partial "navigators/lang-selector.html" . }}
|
|
{{ end }}
|
|
{{ if or site.Params.features.darkMode.enable site.Params.features.theme.enable }}
|
|
{{ partial "navigators/theme-selector.html" . }}
|
|
{{ end }}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<!-- Store the logo information in a hidden img for the JS -->
|
|
{{ if $mainLogo }}
|
|
<img src="{{ $mainLogo }}" class="d-none" id="main-logo" alt="Logo">
|
|
{{ end }}
|
|
{{ if $invertedLogo }}
|
|
<img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo">
|
|
{{ end }}
|
|
{{ if $darkLogo }}
|
|
<img src="{{ $darkLogo }}" class="d-none" id="dark-logo" alt="Dark Logo">
|
|
{{ end }}
|
|
</nav>
|