1
- {{/* We cache this partial for bigger sites and set the active class client side. */}}
2
- {{ $sidebarCacheLimit := cond (isset .Site.Params.ui "sidebar_cache_limit") .Site.Params.ui.sidebar_cache_limit 2000 -}}
3
- {{ $shouldDelayActive := ge (len .Site.Pages) $sidebarCacheLimit -}}
1
+ {{/* Always cache this partial; set the active class client side. */}}
2
+ {{ $shouldDelayActive := true }}
4
3
< div id ="td-sidebar-menu " class ="td-sidebar__inner{{ if $shouldDelayActive }} d-none{{ end }} ">
5
4
{{ if not .Site.Params.ui.sidebar_search_disable -}}
6
5
< form class ="td-sidebar__search d-flex align-items-center ">
7
6
{{ partial "search-input.html" . }}
8
- < button class ="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fas fa-bars " type ="button " data-toggle ="collapse " data-target ="#td-section-nav " aria-controls ="td-docs -nav " aria-expanded ="false " aria-label ="Toggle section navigation ">
7
+ < button class ="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fas fa-bars " type ="button " data-toggle ="collapse " data-target ="#td-section-nav " aria-controls ="td-section -nav " aria-expanded ="false " aria-label ="Toggle section navigation ">
9
8
</ button >
10
9
</ form >
11
10
{{ else -}}
12
11
< div id ="content-mobile ">
13
12
< form class ="td-sidebar__search d-flex align-items-center ">
14
13
{{ partial "search-input.html" . }}
15
- < button class ="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fas fa-bars " type ="button " data-toggle ="collapse " data-target ="#td-section-nav " aria-controls ="td-docs -nav " aria-expanded ="false " aria-label ="Toggle section navigation ">
14
+ < button class ="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fas fa-bars " type ="button " data-toggle ="collapse " data-target ="#td-section-nav " aria-controls ="td-section -nav " aria-expanded ="false " aria-label ="Toggle section navigation ">
16
15
</ button >
17
16
</ form >
18
17
</ div >
19
18
< div id ="content-desktop "> </ div >
20
19
{{ end -}}
21
20
< nav class ="collapse td-sidebar-nav{{ if .Site.Params.ui.sidebar_menu_foldable }} foldable-nav{{ end }} " id ="td-section-nav ">
22
- <!-- {{ if (gt (len .Site.Home.Translations) 0) }}
21
+ {{- if (and false (gt (len .Site.Home.Translations) 0) ) - }}
23
22
< div class ="nav-item dropdown d-block d-lg-none ">
24
23
{{ partial "navbar-lang-selector.html" . }}
25
24
</ div >
26
- {{ end }} -->
27
- <!-- {{ $navRoot := cond (and (ne .Params.toc_root true) (eq .Site.Home.Type "docs")) .Site.Home .FirstSection }} -->
25
+ {{ end -}}
26
+ {{ $navRoot := cond (and (ne .Params.toc_root true) (eq .Site.Home.Type "docs")) .Site.Home .FirstSection -}}
28
27
{{ $ulNr := 0 -}}
29
28
{{ $ulShow := cond (isset .Site.Params.ui "ul_show") .Site.Params.ui.ul_show 1 -}}
30
29
{{ $sidebarMenuTruncate := cond (isset .Site.Params.ui "sidebar_menu_truncate") .Site.Params.ui.sidebar_menu_truncate 50 -}}
31
- {{ $currentLang := .Site.Language -}}
30
+ {{ $currentLang := string .Site.Language -}}
32
31
< ul class ="td-sidebar-nav__section pr-md-3 ul-{{ $ulNr }} ">
33
- {{ template "section-tree-nav-section" (dict "page" . "section" .FirstSection "shouldDelayActive" $shouldDelayActive "sidebarMenuTruncate" $sidebarMenuTruncate "ulNr" $ulNr "ulShow" (add $ulShow 1) "currentLang" $currentLang) }}
32
+ {{ template "section-tree-nav-section" (dict "page" . "section" $navRoot "shouldDelayActive" $shouldDelayActive "sidebarMenuTruncate" $sidebarMenuTruncate "ulNr" $ulNr "ulShow" (add $ulShow 1) "currentLang" $currentLang) }}
34
33
</ ul >
35
34
</ nav >
36
35
</ div >
42
41
{{ $treeRoot := cond (eq .ulNr 0) true false -}}
43
42
{{ $ulNr := .ulNr -}}
44
43
{{ $ulShow := .ulShow -}}
44
+ {{ $currentLang := .currentLang -}}
45
45
{{ $active := and (not $shouldDelayActive) (eq $s $p) -}}
46
46
{{ $activePath := and (not $shouldDelayActive) ($p.IsDescendant $s) -}}
47
- {{ $show := cond (or (lt $ulNr $ulShow) $activePath (and (not $shouldDelayActive) (eq $s.Parent $p.Parent)) (and (not $shouldDelayActive) (eq $s.Parent $p)) (and (not $shouldDelayActive) ($p.IsDescendant $s.Parent))) true false -}}
47
+ {{ $show := cond (or (lt $ulNr $ulShow) $activePath (and (not $shouldDelayActive) (eq $s.Parent $p.Parent)) (and (not $shouldDelayActive) (eq $s.Parent $p)) (not $p.Site.Params.ui.sidebar_menu_compact) ( and (not $shouldDelayActive) ($p.IsDescendant $s.Parent))) true false -}}
48
48
{{ $mid := printf "m-%s" ($s.RelPermalink | anchorize) -}}
49
49
{{ $pages_tmp := where (union $s.Pages $s.Sections).ByWeight ".Params.toc_hide" "!=" true -}}
50
50
{{/* We get untranslated subpages below to make sure we build all levels of the sidenav in localizationed docs sets */}}
60
60
{{ $withChild := gt (len $pages) 0 -}}
61
61
{{ $manualLink := cond (isset $s.Params "manuallink") $s.Params.manualLink ( cond (isset $s.Params "manuallinkrelref") (relref $s $s.Params.manualLinkRelref) $s.RelPermalink) -}}
62
62
{{ $manualLinkTitle := cond (isset $s.Params "manuallinktitle") $s.Params.manualLinkTitle $s.Title -}}
63
-
63
+ {{ $isForeignLanguage := (ne (string $s.Lang) ($.currentLang)) -}}
64
64
< li class ="td-sidebar-nav__section-title td-sidebar-nav__section{{ if $withChild }} with-child{{ else }} without-child{{ end }}{{ if $activePath }} active-path{{ end }}{{ if (not (or $show $p.Site.Params.ui.sidebar_menu_foldable )) }} collapse{{ end }} " id ="{{ $mid }}-li ">
65
65
{{ if (and $p.Site.Params.ui.sidebar_menu_foldable (ge $ulNr 1)) -}}
66
- < input type ="checkbox " id ="{{ $mid }}-check "{{ if $activePath}} checked{{ end }} />
67
- < label for ="{{ $mid }}-check "> < a href ="{{ $manualLink }} "{{ if ne $s.LinkTitle $manualLinkTitle }} title ="{{ $manualLinkTitle }} "{{ end }}{{ with $s.Params.manualLinkTarget }} target ="{{ . }} "{{ if eq . "_blank" }} rel="noopener "{{ end }}{{ end }} class ="align-left pl-0 {{ if $active}} active{{ end }} td-sidebar-link{{ if $s.IsPage }} td-sidebar-link__page{{ else }} td-sidebar-link__section{{ end }}{{ if $treeRoot }} tree-root{{ end }} " id ="{{ $mid }} "> {{ with $s.Params.Icon}}< i class ="{{ . }} "> </ i > {{ end }}< span class ="{{ if $active }}td-sidebar-nav-active-item{{ end }} "> {{ $s.LinkTitle }}</ span > </ a > </ label >
66
+ < input type ="checkbox " id ="{{ $mid }}-check "{{ if $activePath}} checked{{ end }} />
67
+ < label for ="{{ $mid }}-check "> < a href ="{{ $manualLink }} "{{ if ne $s.LinkTitle $manualLinkTitle }} title ="{{ $manualLinkTitle }} "{{ end }}{{ with $s.Params.manualLinkTarget }} target ="{{ . }} "{{ if eq . "_blank" }} rel="noopener "{{ end }}{{ end }} class ="align-left pl-0 {{ if $active}} active{{ end }} td-sidebar-link{{ if $s.IsPage }} td-sidebar-link__page{{ else }} td-sidebar-link__section{{ end }}{{ if $treeRoot }} tree-root{{ end }} " id ="{{ $mid }} "> {{ with $s.Params.Icon}}< i class ="{{ . }} "> </ i > {{ end }}< span class ="{{ if $active }}td-sidebar-nav-active-item{{ end }} "> {{ $s.LinkTitle }}</ span > {{ if $isForeignLanguage }} < small title =" {{ T (printf " i18n_language_name_long_%s " $s.Lang ) }}" > ({{ $s.Lang | upper }}) </ small > {{ end -}} </ a > </ label >
68
68
{{ else -}}
69
- {{ if not $treeRoot }}
70
- < a href ="{{ $manualLink }} "{{ if ne $s.LinkTitle $manualLinkTitle }} title ="{{ $manualLinkTitle }} "{{ end }}{{ with $s.Params.manualLinkTarget }} target ="{{ . }} "{{ if eq . "_blank" }} rel="noopener "{{ end }}{{ end }} class ="align-left pl-0{{ if $active}} active{{ end }} td-sidebar-link{{ if $s.IsPage }} td-sidebar-link__page{{ else }} td-sidebar-link__section{{ end }} " id ="{{ $mid }} "> {{ with $s.Params.Icon}}< i class ="{{ . }} "> </ i > {{ end }}< span class ="{{ if $active }}td-sidebar-nav-active-item{{ end }} "> {{ $s.LinkTitle }}</ span > </ a >
71
- {{ end -}}
72
- {{ end -}}
73
- {{ if $withChild -}}
74
- {{ $ulNr := add $ulNr 1 -}}
75
- < ul class ="ul-{{ $ulNr }}{{ if (gt $ulNr 1)}} foldable{{end}} ">
76
- {{ $pages := where (union $s.Pages $s.Sections).ByWeight ".Params.toc_hide" "!=" true -}}
77
- {{ with site.Params.language_alternatives -}}
78
- {{ range . }}
79
- {{ with (where $.section.Translations ".Lang" . ) -}}
80
- {{ $p := index . 0 -}}
81
- {{ $pages = where ( $pages | lang.Merge (union $p.Pages $p.Sections)) ".Params.toc_hide" "!=" true -}}
82
- {{ end -}}
83
- {{ end -}}
84
- {{ end -}}
85
- {{ $pages := $pages | first 50 -}}
86
- {{ range $pages -}}
87
- {{ if (not (and (eq $s $p.Site.Home) (eq .Params.toc_root true)) ) -}}
88
- {{ $mid := printf "m-%s" (.RelPermalink | anchorize) -}}
89
- {{ $active := eq . $p -}}
90
- {{ $isForeignLanguage := (ne (string .Lang) (string $.currentLang)) -}}
91
- {{ if (and $isForeignLanguage ($p.IsDescendant $s)) -}}
92
- < a class ="td-sidebar-link td-sidebar-link__page {{ if and (not $shouldDelayActive) $active }} active{{ end }} " id ="{{ $mid }} " {{ if $isForeignLanguage }}target ="_blank "{{ end }} href ="{{ .RelPermalink }} ">
93
- {{ .LinkTitle }}{{ if $isForeignLanguage }} < small > ({{ .Lang | upper }})</ small > {{ end -}}
94
- </ a >
95
- {{ else -}}
96
- {{ template "section-tree-nav-section" (dict "page" $p "section" . "currentLang" $.currentLang "shouldDelayActive" $shouldDelayActive "sidebarMenuTruncate" $sidebarMenuTruncate "ulNr" $ulNr "ulShow" $ulShow) }}
97
- {{- end }}
98
- {{- end }}
99
- {{- end }}
100
- </ ul >
69
+ {{ if not $treeRoot }}
70
+ < a href ="{{ $manualLink }} "{{ if ne $s.LinkTitle $manualLinkTitle }} title ="{{ $manualLinkTitle }} "{{ end }}{{ with $s.Params.manualLinkTarget }} target ="{{ . }} "{{ if eq . "_blank" }} rel="noopener "{{ end }}{{ end }} class ="align-left pl-0{{ if $active}} active{{ end }} td-sidebar-link{{ if $s.IsPage }} td-sidebar-link__page{{ else }} td-sidebar-link__section{{ end }}{{ if $treeRoot }} tree-root{{ end }} " id ="{{ $mid }} "> {{ with $s.Params.Icon}}< i class ="{{ . }} "> </ i > {{ end }}< span class ="{{ if $active }}td-sidebar-nav-active-item{{ end }} "> {{ $s.LinkTitle }}</ span > {{ if $isForeignLanguage }} < small title ="{{ T (printf "i18n_language_name_long_%s " $s.Lang ) }}"> ({{ $s.Lang | upper }})</ small > {{ end -}}</ a >
71
+ {{- end }}
72
+ {{- end }}
73
+ {{- if $withChild }}
74
+ {{- $ulNr := add $ulNr 1 }}
75
+ < ul class ="ul-{{ $ulNr }}{{ if (gt $ulNr 1)}} foldable{{end}} ">
76
+ {{ range $pages -}}
77
+ {{ $mid := printf "m-%s" (.RelPermalink | anchorize) -}}
78
+ {{ if (not (and (eq $s $p.Site.Home) (eq .Params.toc_root true))) -}}
79
+ {{ template "section-tree-nav-section" (dict "page" $p "section" . "shouldDelayActive" $shouldDelayActive "sidebarMenuTruncate" $sidebarMenuTruncate "ulNr" $ulNr "ulShow" $ulShow "currentLang" $currentLang) }}
80
+ {{- end }}
81
+ {{- end }}
82
+ </ ul >
101
83
{{- end }}
102
84
</ li >
103
- {{- end }}
85
+ {{- end }}
0 commit comments