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 }}
43< div id ="td-sidebar-menu " class ="td-sidebar__inner{{ if $shouldDelayActive }} d-none{{ end }} ">
54 {{ if not .Site.Params.ui.sidebar_search_disable -}}
65 < form class ="td-sidebar__search d-flex align-items-center ">
76 {{ 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 ">
98 </ button >
109 </ form >
1110 {{ else -}}
1211 < div id ="content-mobile ">
1312 < form class ="td-sidebar__search d-flex align-items-center ">
1413 {{ 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 ">
1615 </ button >
1716 </ form >
1817 </ div >
1918 < div id ="content-desktop "> </ div >
2019 {{ end -}}
2120 < 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) ) - }}
2322 < div class ="nav-item dropdown d-block d-lg-none ">
2423 {{ partial "navbar-lang-selector.html" . }}
2524 </ 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 -}}
2827 {{ $ulNr := 0 -}}
2928 {{ $ulShow := cond (isset .Site.Params.ui "ul_show") .Site.Params.ui.ul_show 1 -}}
3029 {{ $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 -}}
3231 < 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) }}
3433 </ ul >
3534 </ nav >
3635</ div >
4241 {{ $treeRoot := cond (eq .ulNr 0) true false -}}
4342 {{ $ulNr := .ulNr -}}
4443 {{ $ulShow := .ulShow -}}
44+ {{ $currentLang := .currentLang -}}
4545 {{ $active := and (not $shouldDelayActive) (eq $s $p) -}}
4646 {{ $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 -}}
4848 {{ $mid := printf "m-%s" ($s.RelPermalink | anchorize) -}}
4949 {{ $pages_tmp := where (union $s.Pages $s.Sections).ByWeight ".Params.toc_hide" "!=" true -}}
5050 {{/* We get untranslated subpages below to make sure we build all levels of the sidenav in localizationed docs sets */}}
6060 {{ $withChild := gt (len $pages) 0 -}}
6161 {{ $manualLink := cond (isset $s.Params "manuallink") $s.Params.manualLink ( cond (isset $s.Params "manuallinkrelref") (relref $s $s.Params.manualLinkRelref) $s.RelPermalink) -}}
6262 {{ $manualLinkTitle := cond (isset $s.Params "manuallinktitle") $s.Params.manualLinkTitle $s.Title -}}
63-
63+ {{ $isForeignLanguage := (ne (string $s.Lang) ($.currentLang)) -}}
6464 < 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 ">
6565 {{ 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 >
6868 {{ 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 >
10183 {{- end }}
10284 </ li >
103- {{- end }}
85+ {{- end }}
0 commit comments