dot-hugo/layouts/partials/navigation.html

67 lines
No EOL
2.4 KiB
HTML

<nav class="navbar navbar-expand-lg navbar-light">
<a class="navbar-brand" href="{{ .Site.BaseURL | relLangURL }}">
{{ $logo:= .Site.Params.logo }}
{{ $logoWhite:= .Site.Params.logoWhite }}
{{ if (or (eq $logo "") (eq $logoWhite "")) }}
{{ .Site.Title }}
{{ else }}
{{ if .IsHome }}
<img class="img-fluid" src="{{ $logoWhite | absURL }}" alt="{{ .Site.Title }}">
{{ else }}
<img class="img-fluid" src="{{ $logo | absURL }}" alt="{{ .Site.Title }}">
{{ end }}
{{ end }}
</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">
<li class="nav-item">
<a class="nav-link text-dark" href="{{ .Site.BaseURL | relLangURL }}">{{ .Site.Params.home }}</a>
</li>
{{ range .Site.Menus.main }}
{{ 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 -->
{{- if .Site.IsMultiLingual }}
<select id="select-language" onchange="location = this.value;">
{{ $siteLanguages := .Site.Languages}}
{{ $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.URL }}" selected>{{ .LanguageName }}
</option>
{{ else }}
<option id="{{ $translation.Language }}" value="{{ $translation.URL }}">{{ .LanguageName }}</option>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</select>
{{ end }}
</div>
</nav>