{{ $context := .context }} {{ $disableSidebar := .disableSidebar | default false }} {{ $navRoot := cond (eq site.Home.Type "docs") site.Home $context.FirstSection }} {{ $navPages := union $navRoot.RegularPages $navRoot.Sections }} {{ $pageURL := $context.RelPermalink }} {{- define "sidebar-main" -}} {{ $pages := .pages }} {{ $toc := .toc | default false }} {{ $pageURL := .pageURL }} {{- with $pages -}} {{- range .ByWeight -}} {{ template "sidebar-item" (dict "item" . "pageURL" $pageURL "toc" $toc) }} {{ template "sidebar-tree" (dict "context" . "level" 1 "pageURL" $pageURL "toc" $toc) }} {{- end -}} {{ end }} {{- end -}} {{- define "sidebar-footer" -}} {{- range site.Menus.sidebar -}} {{ if eq .Params.type "separator" }}
  • {{ .Name }}
  • {{ else }}
  • {{ template "sidebar-item-link" dict "active" false "title" .Name "link" .URL }}
  • {{ end }} {{- end -}} {{- end -}} {{- define "sidebar-tree" -}} {{ $pageURL := .pageURL }} {{ $level := .level }} {{ $toc := .toc | default false }} {{ if ge $level 4 }} {{ return }} {{ end }} {{ $items := union .context.RegularPages .context.Sections }} {{ with $items }}
    {{ end }} {{- end -}} {{- define "sidebar-toc" -}} {{ $page := .page }} {{ with $page.Fragments.Headings }} {{ end }} {{- end -}} {{- define "sidebar-item" }} {{- $active := eq .pageURL .item.RelPermalink -}} {{- $title := .item.LinkTitle | default .item.File.BaseFileName -}} {{- $link := .item.RelPermalink -}} {{- $toc := .toc | default false -}}
  • {{ template "sidebar-item-link" dict "active" $active "title" $title "link" $link }} {{ if and $toc $active }} {{ template "sidebar-toc" dict "page" .item }} {{ end }}
  • {{- end -}} {{- define "sidebar-item-link" -}} {{ $external := strings.HasPrefix .link "http" }} {{- .title -}} {{- end -}} {{- define "sidebar-separator" -}}
    {{- end -}} {{- define "theme-switch" -}} {{- $class := .class -}}
    {{ partial "theme-toggle" }}
    {{- end -}}