{{- $context := .context -}} {{- $disableSidebar := .disableSidebar | default false -}} {{- $displayPlaceholder := .displayPlaceholder | default false -}} {{- $navRoot := cond (eq site.Home.Type "docs") site.Home $context.FirstSection -}} {{- $pageURL := $context.RelPermalink -}} {{- if .context.Params.sidebar.hide -}} {{- $disableSidebar = true -}} {{- $displayPlaceholder = false -}} {{- end -}} {{- $sidebarClass := "hx:md:sticky" -}} {{- if $disableSidebar -}} {{- if $displayPlaceholder -}} {{- $sidebarClass = "hx:md:hidden hx:xl:block" -}} {{- else -}} {{- $sidebarClass = "hx:md:hidden" -}} {{- end -}} {{- end -}} {{- define "sidebar-main" -}} {{ template "sidebar-tree" (dict "context" .context "level" 0 "page" .page "pageURL" .pageURL "toc" (.toc | default false)) }} {{- end -}} {{- define "sidebar-tree" -}} {{- if ge .level 4 -}} {{- return -}} {{- end -}} {{- $context := .context -}} {{- $page := .page }} {{- $pageURL := .page.RelPermalink -}} {{- $level := .level -}} {{- $toc := .toc | default false -}} {{- $useMainMenu := and (eq $level 0) $toc -}} {{- $menuNamesByPath := dict -}} {{- $items := where (union .context.RegularPages .context.Sections) "Params.sidebar.exclude" "!=" true -}} {{- if $useMainMenu -}} {{- $items = slice -}} {{- range $menuItem := site.Menus.main -}} {{- with $menuItem.Page -}} {{- if ne .Params.sidebar.exclude true -}} {{- $items = $items | append . -}} {{- $menuNamesByPath = merge $menuNamesByPath (dict .Path (or (T $menuItem.Identifier) $menuItem.Name)) -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- if gt (len $items) 0 -}} {{- if eq $level 0 -}} {{- $topLevelItems := cond $useMainMenu $items $items.ByWeight -}} {{- range $topLevelItems }} {{- if .Params.sidebar.separator -}}
  • {{ partial "utils/title" . }}
  • {{- else -}} {{- $active := eq $pageURL .RelPermalink -}} {{- $shouldOpen := or (.Params.sidebar.open) (.IsAncestor $page) $active | default true }}
  • {{- $linkTitle := partial "utils/title" . -}} {{- if $useMainMenu -}} {{- with index $menuNamesByPath .Path -}} {{- $linkTitle = . -}} {{- end -}} {{- end -}} {{- template "sidebar-item-link" dict "context" . "active" $active "open" $shouldOpen "title" $linkTitle "link" .RelPermalink -}} {{- if and $toc $active (ne .Params.toc false) -}} {{- template "sidebar-toc" dict "page" . -}} {{- end -}} {{- template "sidebar-tree" dict "context" . "page" $page "pageURL" $pageURL "level" (add $level 1) "toc" $toc -}}
  • {{- end -}} {{- end -}} {{- else -}}
    {{- end -}} {{- end -}} {{- end -}} {{- define "sidebar-toc" -}} {{ $page := .page }} {{ with $page.Fragments.Headings }} {{ end }} {{- end -}} {{- define "sidebar-footer" -}} {{- range site.Menus.sidebar -}} {{- $name := or (T .Identifier) .Name -}} {{ if eq .Params.type "separator" }}
  • {{ $name }}
  • {{ else }} {{- $link := .URL -}} {{- with .PageRef -}} {{- if hasPrefix . "/" -}} {{- $link = relLangURL (strings.TrimPrefix "/" .) -}} {{- end -}} {{- end -}}
  • {{ template "sidebar-item-link" dict "active" false "open" false "title" $name "link" $link }}
  • {{ end }} {{- end -}} {{- end -}} {{- define "sidebar-item-link" -}} {{- $external := strings.HasPrefix .link "http" -}} {{- $open := .open | default true -}} {{- $hasChildren := false -}} {{- with .context }}{{ if or .RegularPages .Sections }}{{ $hasChildren = true }}{{ end }}{{ end -}}
    {{- .title -}} {{- if $hasChildren }} {{- end }}
    {{- end -}} {{- define "sidebar-collapsible-button" -}} {{- end -}}