dot-hugo/layouts/partials/navigation.html

68 lines
2.6 KiB
HTML
Raw Normal View History

2020-01-27 03:57:24 +00:00
<nav class="navbar navbar-expand-md {{ if .IsHome }}navbar-dark{{ else }}navbar-light{{ end }}">
2020-02-08 04:40:37 +00:00
<div class="container">
2020-07-05 03:21:01 +00:00
<a class="navbar-brand px-2" href="{{ site.BaseURL | relLangURL }}">
{{ $logo:= site.Params.logo }}
{{ $logoWhite:= site.Params.logo_white }}
2020-02-08 04:40:37 +00:00
{{ if (or $logo $logoWhite) }}
{{ if .IsHome }}
<img class="img-fluid" src="{{if $logoWhite }}{{ $logoWhite | absURL }} {{ else }} {{ $logo | absURL }}{{ end }}"
2020-07-05 03:21:01 +00:00
alt="{{ site.Title }}">
{{ else }}
2020-07-05 03:21:01 +00:00
<img class="img-fluid" src="{{ $logo | absURL }}" alt="{{ site.Title }}">
{{ end }}
2019-08-22 06:39:33 +00:00
{{ else }}
2020-07-05 03:21:01 +00:00
{{ site.Title }}
2019-08-22 06:39:33 +00:00
{{ end }}
2020-02-08 04:40:37 +00:00
</a>
<button class="navbar-toggler border-0" type="button" data-toggle="collapse" data-target="#navigation"
aria-controls="navigation" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse text-center" id="navigation">
<ul class="navbar-nav ml-auto">
2020-07-05 03:21:01 +00:00
{{ range site.Menus.main }}
2020-02-08 04:40:37 +00:00
{{ if .HasChildren }}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle text-dark" href="#" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
{{ .Name }}
</a>
<div class="dropdown-menu">
{{ range .Children }}
<a class="dropdown-item" href="{{ .URL | relLangURL }}">{{ .Name }}</a>
{{ end }}
</div>
</li>
{{ else }}
<li class="nav-item">
<a class="nav-link text-dark" href="{{ .URL | relLangURL }}">{{ .Name }}</a>
</li>
{{ end }}
{{ end }}
</ul>
<!-- Language List -->
2020-07-05 03:21:01 +00:00
{{- if site.IsMultiLingual }}
2020-02-08 04:40:37 +00:00
<select class="lang-list {{ if not .IsHome }}dark{{ end }}" id="select-language"
onchange="location = this.value;">
2020-07-05 03:21:01 +00:00
{{ $siteLanguages := site.Languages}}
2020-02-08 04:40:37 +00:00
{{ $pageLang := .Page.Lang}}
{{ range .Page.AllTranslations }}
{{ $translation := .}}
{{ range $siteLanguages }}
{{ if eq $translation.Lang .Lang }}
{{ $selected := false }}
{{ if eq $pageLang .Lang}}
<option id="{{ $translation.Language }}" value="{{ $translation.Permalink }}" selected>{{ .LanguageName }}
</option>
{{ else }}
<option id="{{ $translation.Language }}" value="{{ $translation.Permalink }}">{{ .LanguageName }}</option>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</select>
2019-08-22 06:39:33 +00:00
{{ end }}
2020-02-08 04:40:37 +00:00
</div>
</div>
</nav>