navigation.html 1.98 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
<section class="sticky-top navigation">
	<div class="container">
		<nav class="navbar navbar-expand-lg navbar-dark">
			<a class="navbar-brand p-0" href="{{ .Site.BaseURL | relLangURL }}">
				{{ if .Site.Params.logo }}
				<img class="img-fluid" src="{{ .Site.Params.logo | absURL }}" alt="{{ .Site.Title }}">
				{{ else }}
				{{ .Site.Title }}
				{{ end }}
			</a>
11

12
13
14
			<button class="navbar-toggler rounded-0" type="button" data-toggle="collapse" data-target="#navigation">
				<span class="navbar-toggler-icon"></span>
			</button>
15

16
17
			<div class="collapse navbar-collapse" id="navigation">
				<ul class="navbar-nav ml-auto">
18
					<li class="nav-item"><a class="nav-link" href="/">{{ .Site.Params.home }}</a></li>
19
20
21
22
					{{ if .IsHome }}
					{{ range .Site.Menus.main }}
					<li class="nav-item"><a class="nav-link" href="{{ .URL }}">{{ .Name }}</a></li>
					{{ end }}
23

24
					{{ else }}
25

26
					{{ range .Site.Menus.main }}
27
28
29
					{{ if hasPrefix .URL "http" }}
					<li class="nav-item"><a class="nav-link" href="{{ .URL }}">{{ .Name }}</a>
					{{ else }}
30
					<li class="nav-item"><a class="nav-link" href="{{ $.Site.BaseURL | relLangURL }}{{ .URL }}">{{ .Name }}</a>
31
					{{ end }}
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
					</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.Permalink }}" selected>{{ .LanguageName }}
					</option>
					{{ else }}
					<option id="{{ $translation.Language }}" value="{{ $translation.Permalink }}">{{ .LanguageName }}</option>
					{{ end }}
					{{ end }}
					{{ end }}
					{{ end }}
				</select>
				{{ end }}
			</div>
		</nav>
	</div>
</section>