Skip to content

Commit d621a66

Browse files
authored
Merge pull request #29006 from niteshseram/fix/sidebar
fixing the huge whitespace in sidebar
2 parents 08d92f9 + b1fa203 commit d621a66

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

layouts/partials/sidebar-tree.html

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{{/* 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 -}}
44
<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 -}}
66
<form class="td-sidebar__search d-flex align-items-center">
77
{{ partial "search-input.html" . }}
88
<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">
99
</button>
1010
</form>
11-
{{ else }}
11+
{{ else -}}
1212
<div id="content-mobile">
1313
<form class="td-sidebar__search d-flex align-items-center">
1414
{{ partial "search-input.html" . }}
@@ -17,78 +17,78 @@
1717
</form>
1818
</div>
1919
<div id="content-desktop"></div>
20-
{{ end }}
20+
{{ end -}}
2121
<nav class="collapse td-sidebar-nav{{ if .Site.Params.ui.sidebar_menu_foldable }} foldable-nav{{ end }}" id="td-section-nav">
2222
<!-- {{ if (gt (len .Site.Home.Translations) 0) }}
2323
<div class="nav-item dropdown d-block d-lg-none">
2424
{{ partial "navbar-lang-selector.html" . }}
2525
</div>
2626
{{ end }} -->
2727
<!-- {{ $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 -}}
3232
<ul class="td-sidebar-nav__section pr-md-3 ul-{{ $ulNr }}">
3333
{{ template "section-tree-nav-section" (dict "page" . "section" .FirstSection "shouldDelayActive" $shouldDelayActive "sidebarMenuTruncate" $sidebarMenuTruncate "ulNr" $ulNr "ulShow" (add $ulShow 1) "currentLang" $currentLang) }}
3434
</ul>
3535
</nav>
3636
</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 -}}
5454

5555
<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)) -}}
5757
<input type="checkbox" id="{{ $mid }}-check"{{ if $activePath}} checked{{ end }}/>
5858
<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 -}}
6060
{{ if not $treeRoot }}
6161
<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 -}}
6666
<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 -}}
6969
{{ 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)) -}}
8383
<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 -}}
8585
</a>
86-
{{ else }}
86+
{{ else -}}
8787
{{ 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 }}
9191
</ul>
92-
{{ end }}
92+
{{- end }}
9393
</li>
94-
{{ end }}
94+
{{- end }}

0 commit comments

Comments
 (0)