InkSoul/themes/meme_cdn/layouts/partials/menu.html

53 lines
2.5 KiB
HTML

<nav class="nav">
<ul class="menu" id="menu">
{{ if .Site.Params.activeInSection }}
{{ .Scratch.Set "currentPage" (.Site.GetPage (printf `/%s` .Section)) }}
{{ else }}
{{ .Scratch.Set "currentPage" . }}
{{ end }}
{{ $currentPage := .Scratch.Get "currentPage" }}
{{ $ctx := . }}
{{ range .Site.Menus.main }}
{{ if and (eq .Identifier "theme-switcher") $.Site.Params.enableDarkMode }}
{{ if eq $.Site.Params.headerLayout "flex" }}
{{ $switcher := partial "components/dark-mode.html" $ctx }}
{{ with $switcher }}
<li class="menu-item">
{{ . }}
</li>
{{ end }}
{{ end }}
{{ else if eq .Identifier "lang-switcher" }}
{{ if and $.Site.IsMultiLingual $.Site.Params.enableLangToggle }}
{{ if eq $.Site.Params.headerLayout "flex" }}
{{ $switcher := partial "components/multilingual.html" $ctx }}
{{ with $switcher }}
<li class="menu-item">
{{ . }}
</li>
{{ end }}
{{ end }}
{{ end }}
{{ else if eq .Identifier "search" }}
{{ if and (eq $.Site.Params.headerLayout "flex") (or $.Site.Params.enableLunrSearch $.Site.Params.enableAlgoliaSearch) }}
{{- $iconName := (string .Post) -}}
<li class="menu-item search-item">
{{ partial "components/search.html" (dict "$" $ctx "iconName" $iconName) }}
</li>
{{ end }}
{{ else }}
<li class="menu-item{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} active{{ end }}">
{{- $linkType := (string .Pre) -}}
<a href="{{ .URL }}"{{ if eq $linkType "external" }} target="_blank" rel="external noopener"{{ end }}>
{{- $iconName := (string .Post) -}}
{{- partial "utils/icon.html" (dict "$" $ "name" $iconName "class" .Identifier) -}}
{{- with .Name -}}
<span class="menu-item-name">{{ . }}</span>
{{- end -}}
</a>
</li>
{{ end }}
{{ end }}
</ul>
</nav>