|
1 | 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 }} |
| 2 | +{{ $sidebarCacheLimit := cond (isset .Site.Params.ui "sidebar_cache_limit") .Site.Params.ui.sidebar_cache_limit 2000 -}} |
| 3 | +{{ $shouldDelayActive := ge (len .Site.Pages) $sidebarCacheLimit -}} |
4 | 4 | <div id="td-sidebar-menu" class="td-sidebar__inner{{ if $shouldDelayActive }} d-none{{ end }}">
|
5 |
| - {{ if not .Site.Params.ui.sidebar_search_disable }} |
| 5 | + {{ if not .Site.Params.ui.sidebar_search_disable -}} |
6 | 6 | <form class="td-sidebar__search d-flex align-items-center">
|
7 | 7 | {{ partial "search-input.html" . }}
|
8 | 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">
|
9 | 9 | </button>
|
10 | 10 | </form>
|
11 |
| - {{ else }} |
| 11 | + {{ else -}} |
12 | 12 | <div id="content-mobile">
|
13 | 13 | <form class="td-sidebar__search d-flex align-items-center">
|
14 | 14 | {{ partial "search-input.html" . }}
|
|
17 | 17 | </form>
|
18 | 18 | </div>
|
19 | 19 | <div id="content-desktop"></div>
|
20 |
| - {{ end }} |
| 20 | + {{ end -}} |
21 | 21 | <nav class="collapse td-sidebar-nav{{ if .Site.Params.ui.sidebar_menu_foldable }} foldable-nav{{ end }}" id="td-section-nav">
|
22 | 22 | <!-- {{ if (gt (len .Site.Home.Translations) 0) }}
|
23 | 23 | <div class="nav-item dropdown d-block d-lg-none">
|
24 | 24 | {{ partial "navbar-lang-selector.html" . }}
|
25 | 25 | </div>
|
26 | 26 | {{ end }} -->
|
27 | 27 | <!-- {{ $navRoot := cond (and (ne .Params.toc_root true) (eq .Site.Home.Type "docs")) .Site.Home .FirstSection }} -->
|
28 |
| - {{ $ulNr := 0 }} |
29 |
| - {{ $ulShow := cond (isset .Site.Params.ui "ul_show") .Site.Params.ui.ul_show 1 }} |
30 |
| - {{ $sidebarMenuTruncate := cond (isset .Site.Params.ui "sidebar_menu_truncate") .Site.Params.ui.sidebar_menu_truncate 50 }} |
31 |
| - {{ $currentLang := .Site.Language }} |
| 28 | + {{ $ulNr := 0 -}} |
| 29 | + {{ $ulShow := cond (isset .Site.Params.ui "ul_show") .Site.Params.ui.ul_show 1 -}} |
| 30 | + {{ $sidebarMenuTruncate := cond (isset .Site.Params.ui "sidebar_menu_truncate") .Site.Params.ui.sidebar_menu_truncate 50 -}} |
| 31 | + {{ $currentLang := .Site.Language -}} |
32 | 32 | <ul class="td-sidebar-nav__section pr-md-3 ul-{{ $ulNr }}">
|
33 | 33 | {{ template "section-tree-nav-section" (dict "page" . "section" .FirstSection "shouldDelayActive" $shouldDelayActive "sidebarMenuTruncate" $sidebarMenuTruncate "ulNr" $ulNr "ulShow" (add $ulShow 1) "currentLang" $currentLang) }}
|
34 | 34 | </ul>
|
35 | 35 | </nav>
|
36 | 36 | </div>
|
37 |
| -{{ define "section-tree-nav-section" }} |
38 |
| - {{ $s := .section }} |
39 |
| - {{ $p := .page }} |
40 |
| - {{ $shouldDelayActive := .shouldDelayActive }} |
41 |
| - {{ $sidebarMenuTruncate := .sidebarMenuTruncate }} |
42 |
| - {{ $treeRoot := cond (eq .ulNr 0) true false }} |
43 |
| - {{ $ulNr := .ulNr }} |
44 |
| - {{ $ulShow := .ulShow }} |
45 |
| - {{ $active := and (not $shouldDelayActive) (eq $s $p) }} |
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 }} |
48 |
| - {{ $mid := printf "m-%s" ($s.RelPermalink | anchorize) }} |
49 |
| - {{ $pages_tmp := where (union $s.Pages $s.Sections).ByWeight ".Params.toc_hide" "!=" true }} |
50 |
| - {{ $pages := $pages_tmp | first $sidebarMenuTruncate }} |
51 |
| - {{ $withChild := gt (len $pages) 0 }} |
52 |
| - {{ $manualLink := cond (isset $s.Params "manuallink") $s.Params.manualLink ( cond (isset $s.Params "manuallinkrelref") (relref $s $s.Params.manualLinkRelref) $s.RelPermalink) }} |
53 |
| - {{ $manualLinkTitle := cond (isset $s.Params "manuallinktitle") $s.Params.manualLinkTitle $s.Title }} |
| 37 | +{{ define "section-tree-nav-section" -}} |
| 38 | + {{ $s := .section -}} |
| 39 | + {{ $p := .page -}} |
| 40 | + {{ $shouldDelayActive := .shouldDelayActive -}} |
| 41 | + {{ $sidebarMenuTruncate := .sidebarMenuTruncate -}} |
| 42 | + {{ $treeRoot := cond (eq .ulNr 0) true false -}} |
| 43 | + {{ $ulNr := .ulNr -}} |
| 44 | + {{ $ulShow := .ulShow -}} |
| 45 | + {{ $active := and (not $shouldDelayActive) (eq $s $p) -}} |
| 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 -}} |
| 48 | + {{ $mid := printf "m-%s" ($s.RelPermalink | anchorize) -}} |
| 49 | + {{ $pages_tmp := where (union $s.Pages $s.Sections).ByWeight ".Params.toc_hide" "!=" true -}} |
| 50 | + {{ $pages := $pages_tmp | first $sidebarMenuTruncate -}} |
| 51 | + {{ $withChild := gt (len $pages) 0 -}} |
| 52 | + {{ $manualLink := cond (isset $s.Params "manuallink") $s.Params.manualLink ( cond (isset $s.Params "manuallinkrelref") (relref $s $s.Params.manualLinkRelref) $s.RelPermalink) -}} |
| 53 | + {{ $manualLinkTitle := cond (isset $s.Params "manuallinktitle") $s.Params.manualLinkTitle $s.Title -}} |
54 | 54 |
|
55 | 55 | <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">
|
56 |
| - {{ if (and $p.Site.Params.ui.sidebar_menu_foldable (ge $ulNr 1)) }} |
| 56 | + {{ if (and $p.Site.Params.ui.sidebar_menu_foldable (ge $ulNr 1)) -}} |
57 | 57 | <input type="checkbox" id="{{ $mid }}-check"{{ if $activePath}} checked{{ end }}/>
|
58 | 58 | <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>
|
59 |
| - {{ else }} |
| 59 | + {{ else -}} |
60 | 60 | {{ if not $treeRoot }}
|
61 | 61 | <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>
|
62 |
| - {{ end }} |
63 |
| - {{ end }} |
64 |
| - {{if $withChild }} |
65 |
| - {{ $ulNr := add $ulNr 1 }} |
| 62 | + {{ end -}} |
| 63 | + {{ end -}} |
| 64 | + {{ if $withChild -}} |
| 65 | + {{ $ulNr := add $ulNr 1 -}} |
66 | 66 | <ul class="ul-{{ $ulNr }}{{ if (gt $ulNr 1)}} foldable{{end}}">
|
67 |
| - {{ $pages := where (union $s.Pages $s.Sections).ByWeight ".Params.toc_hide" "!=" true }} |
68 |
| - {{ with site.Params.language_alternatives }} |
| 67 | + {{ $pages := where (union $s.Pages $s.Sections).ByWeight ".Params.toc_hide" "!=" true -}} |
| 68 | + {{ with site.Params.language_alternatives -}} |
69 | 69 | {{ range . }}
|
70 |
| - {{ with (where $.section.Translations ".Lang" . ) }} |
71 |
| - {{ $p := index . 0 }} |
72 |
| - {{ $pages = $pages | lang.Merge (union $p.Pages $p.Sections) }} |
73 |
| - {{ end }} |
74 |
| - {{ end }} |
75 |
| - {{ end }} |
76 |
| - {{ $pages := $pages | first 50 }} |
77 |
| - {{ range $pages }} |
78 |
| - {{ if (not (and (eq $s $p.Site.Home) (eq .Params.toc_root true)) ) }} |
79 |
| - {{ $mid := printf "m-%s" (.RelPermalink | anchorize) }} |
80 |
| - {{ $active := eq . $p }} |
81 |
| - {{ $isForeignLanguage := (ne (string .Lang) (string $.currentLang)) }} |
82 |
| - {{ if (and $isForeignLanguage ($p.IsDescendant $s)) }} |
| 70 | + {{ with (where $.section.Translations ".Lang" . ) -}} |
| 71 | + {{ $p := index . 0 -}} |
| 72 | + {{ $pages = $pages | lang.Merge (union $p.Pages $p.Sections) -}} |
| 73 | + {{ end -}} |
| 74 | + {{ end -}} |
| 75 | + {{ end -}} |
| 76 | + {{ $pages := $pages | first 50 -}} |
| 77 | + {{ range $pages -}} |
| 78 | + {{ if (not (and (eq $s $p.Site.Home) (eq .Params.toc_root true)) ) -}} |
| 79 | + {{ $mid := printf "m-%s" (.RelPermalink | anchorize) -}} |
| 80 | + {{ $active := eq . $p -}} |
| 81 | + {{ $isForeignLanguage := (ne (string .Lang) (string $.currentLang)) -}} |
| 82 | + {{ if (and $isForeignLanguage ($p.IsDescendant $s)) -}} |
83 | 83 | <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 }}">
|
84 |
| - {{ .LinkTitle }}{{ if $isForeignLanguage }} <small>({{ .Lang | upper }})</small>{{ end }} |
| 84 | + {{ .LinkTitle }}{{ if $isForeignLanguage }} <small>({{ .Lang | upper }})</small>{{ end -}} |
85 | 85 | </a>
|
86 |
| - {{ else }} |
| 86 | + {{ else -}} |
87 | 87 | {{ template "section-tree-nav-section" (dict "page" $p "section" . "currentLang" $.currentLang "shouldDelayActive" $shouldDelayActive "sidebarMenuTruncate" $sidebarMenuTruncate "ulNr" $ulNr "ulShow" $ulShow) }}
|
88 |
| - {{ end }} |
89 |
| - {{ end }} |
90 |
| - {{ end }} |
| 88 | + {{- end }} |
| 89 | + {{- end }} |
| 90 | + {{- end }} |
91 | 91 | </ul>
|
92 |
| - {{ end }} |
| 92 | + {{- end }} |
93 | 93 | </li>
|
94 |
| -{{ end }} |
| 94 | +{{- end }} |
0 commit comments