63cbc7c910
The match was against the page title, which isn't as stable as the filename of the page. Switch to matching by filename.
64 lines
3.0 KiB
HTML
64 lines
3.0 KiB
HTML
{{/* We cache this partial for bigger sites and set the active class client side. */}}
|
|
{{ $shouldDelayActive := ge (len .Site.Pages) 2000 }}
|
|
<div id="td-sidebar-menu" class="td-sidebar__inner{{ if $shouldDelayActive }} d-none{{ end }}">
|
|
{{ if not .Site.Params.ui.sidebar_search_disable }}
|
|
<form class="td-sidebar__search d-flex align-items-center">
|
|
{{ partial "search-input.html" . }}
|
|
<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">
|
|
</button>
|
|
</form>
|
|
{{ end }}
|
|
<nav class="collapse td-sidebar-nav" id="td-section-nav">
|
|
<!-- {{ if (gt (len .Site.Home.Translations) 0) }}
|
|
<div class="nav-item dropdown d-block d-lg-none">
|
|
{{ partial "navbar-lang-selector.html" . }}
|
|
</div>
|
|
{{ end }} -->
|
|
{{ $currentLang := .Site.Language }}
|
|
{{ template "section-tree-nav-section" (dict "page" . "section" .FirstSection "delayActive" $shouldDelayActive "currentLang" $currentLang) }}
|
|
</nav>
|
|
</div>
|
|
{{ define "section-tree-nav-section" }}
|
|
{{ $s := .section }}
|
|
{{ $p := .page }}
|
|
{{ $shouldDelayActive := .delayActive }}
|
|
{{ $active := eq $p.CurrentSection $s }}
|
|
{{ $show := or (eq $s $p.FirstSection) (and (not $p.Site.Params.ui.sidebar_menu_compact) ($p.IsDescendant $s)) }}
|
|
{{ $sid := $s.RelPermalink | anchorize }}
|
|
<ul class="td-sidebar-nav__section pr-md-3">
|
|
{{ if (ne $s.File.Path "docs/_index.md") }}
|
|
<li class="td-sidebar-nav__section-title">
|
|
<a href="{{ $s.RelPermalink }}" class="align-left pl-0 pr-2{{ if not $show }} collapsed{{ end }}{{ if $active}} active{{ end }} td-sidebar-link td-sidebar-link__section">
|
|
{{ $s.LinkTitle }}
|
|
</a>
|
|
</li>
|
|
{{ end }}
|
|
<ul>
|
|
<li class="collapse {{ if $show }}show{{ end }}" id="{{ $sid }}">
|
|
{{ $pages := where (union $s.Pages $s.Sections).ByWeight ".Params.toc_hide" "!=" true }}
|
|
{{ with site.Params.language_alternatives }}
|
|
{{ range . }}
|
|
{{ with (where $.section.Translations ".Lang" . ) }}
|
|
{{ $p := index . 0 }}
|
|
{{ $pages = $pages | lang.Merge (union $p.Pages $p.Sections) }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ $pages := $pages | first 50 }}
|
|
{{ range $pages }}
|
|
{{ if .IsPage }}
|
|
{{ $mid := printf "m-%s" (.RelPermalink | anchorize) }}
|
|
{{ $active := eq . $p }}
|
|
{{ $isForeignLanguage := (ne (string .Lang) (string $.currentLang)) }}
|
|
<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 }}">
|
|
{{ .LinkTitle }}{{ if $isForeignLanguage }} <small>({{ .Lang | upper }})</small>{{ end }}
|
|
</a>
|
|
{{ else }}
|
|
{{ template "section-tree-nav-section" (dict "page" $p "section" . "currentLang" $.currentLang) }}
|
|
{{ end }}
|
|
{{ end }}
|
|
</li>
|
|
</ul>
|
|
</ul>
|
|
{{ end }}
|