dot-hugo/layouts/partials/navigation.html

53 lines
2 KiB
HTML
Raw Normal View History

2019-01-06 10:40:05 +00:00
<nav class="navbar navbar-expand-lg navbar-light">
2019-06-15 05:48:38 +00:00
<a class="navbar-brand" href="{{ .Site.BaseURL }}{{ .Language.LanguageName | lower }}">{{ .Site.Params.logo }}</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>
2019-01-06 10:40:05 +00:00
<div class="collapse navbar-collapse text-center" id="navigation">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
2019-06-15 05:48:38 +00:00
<a class="nav-link text-dark" href="{{ .Site.BaseURL }}{{ .Language.LanguageName | lower }}">{{ .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 }}
2019-06-15 05:48:38 +00:00
<a class="dropdown-item" href="{{ .URL | absURL }}">{{ .Name }}</a>
{{ end }}
</div>
</li>
{{ else }}
<li class="nav-item">
2019-06-15 05:48:38 +00:00
<a class="nav-link text-dark" href="{{ .URL | absURL }}">{{ .Name }}</a>
</li>
{{ end }}
{{ end }}
</ul>
<!-- Language List -->
2019-08-22 06:39:33 +00:00
<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 }}
2019-08-22 06:39:33 +00:00
{{ end }}
{{ end }}
{{ end }}
</select>
</div>
</nav>