-
Notifications
You must be signed in to change notification settings - Fork 783
/
Copy pathnavbar.html
66 lines (65 loc) · 2.53 KB
/
navbar.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
61
62
63
64
65
66
{{ $cover := and
(.HasShortcode "blocks/cover")
(not .Site.Params.ui.navbar_translucent_over_cover_disable)
-}}
<nav class="js-navbar-scroll navbar navbar-expand-md navbar-dark
{{- if $cover }} td-navbar-cover {{- end }} td-navbar">
<div class="container px-0">
<a class="navbar-brand" href="{{ .Site.Home.RelPermalink }}">
{{- /**/ -}}
<span class="navbar-brand__logo navbar-logo">
{{- if ne .Site.Params.ui.navbar_logo false -}}
{{ with resources.Get "icons/logo.svg" -}}
{{ ( . | minify).Content | safeHTML -}}
{{ end -}}
{{ end -}}
</span>
{{- /**/ -}}
<span class="text-uppercase font-weight-bold">
{{- .Site.Title -}}
</span>
{{- /**/ -}}
</a>
<div class="filler"></div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#main_navbar" aria-controls="main_navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse ml-md-auto" id="main_navbar">
<ul class="navbar-nav ml-auto pt-4 pt-md-0 my-2 my-md-1">
{{ $p := . -}}
{{ range .Site.Menus.main -}}
{{ $longContent := gt (len .Name) 10 -}}
<li class="nav-item mr-2 mr-lg-4 mt-1 mt-lg-0 {{- if $longContent }} long-content {{- end }}">
{{ $active := or ($p.IsMenuCurrent "main" .) ($p.HasMenuCurrent "main" .) -}}
{{ with .Page }}{{ $active = or $active ( $.IsDescendant .) }}{{ end -}}
{{ $pre := .Pre -}}
{{ $post := .Post -}}
{{ $url := urls.Parse .URL -}}
{{ $baseurl := urls.Parse $.Site.Params.Baseurl -}}
<a {{/**/ -}}
class="nav-link {{- if $active }} active {{- end }}" {{/**/ -}}
href="{{ with .Page }}{{ .RelPermalink }}{{ else }}{{ .URL | relLangURL }}{{ end }}"
{{- if ne $url.Host $baseurl.Host }} target="_blank" {{- end -}}
>
{{- with .Pre }}{{ $pre }}{{ end -}}
<span {{- if $active }} class="active" {{- end }}>
{{- .Name -}}
</span>
{{- with .Post }}{{ $post }}{{ end -}}
</a>
</li>
{{ end -}}
{{ if .Site.Params.versions -}}
<li class="nav-item dropdown mt-1 mt-lg-0">
{{ partial "navbar-version-selector.html" . -}}
</li>
{{ end -}}
{{ if (gt (len .Site.Home.Translations) 0) -}}
<li class="nav-item dropdown mt-1 mt-lg-0 mr-2">
{{ partial "navbar-lang-selector.html" . -}}
</li>
{{ end -}}
</ul>
</div>
</div>
</nav>