{{- $context := .context -}} {{- $disableSidebar := .disableSidebar | default false -}} {{- $sidebarClass := cond $disableSidebar "md:hidden xl:block" "md:sticky" -}} {{- $navRoot := cond (eq site.Home.Type "docs") site.Home $context.FirstSection -}} {{- $navPages := union $navRoot.RegularPages $navRoot.Sections -}} {{- $pageURL := $context.RelPermalink -}} {{- define "sidebar-main" -}} {{ $context := .context }} {{ $toc := .toc | default false }} {{ $pageURL := .pageURL }} {{ template "sidebar-tree" (dict "context" $context "level" 0 "pageURL" $pageURL "toc" $toc) }} {{- end -}} {{- define "sidebar-tree" -}} {{- if ge .level 4 -}} {{- return -}} {{- end -}} {{- $context := .context -}} {{- $pageURL := .pageURL -}} {{- $level := .level -}} {{- $toc := .toc | default false -}} {{- $items := union .context.RegularPages .context.Sections -}} {{- with $items -}} {{- if eq $level 0 -}} {{- range $items.ByWeight }} {{- $active := eq $pageURL .RelPermalink -}}
  • {{- template "sidebar-item-link" dict "context" . "active" $active "title" .LinkTitle "link" .RelPermalink -}} {{- if and $toc $active -}} {{- template "sidebar-toc" dict "page" . -}} {{- end -}} {{- template "sidebar-tree" dict "context" . "pageURL" $pageURL "level" (add $level 1) -}}
  • {{- end -}} {{- else -}}
    {{- end -}} {{- end }} {{- end -}} {{- define "sidebar-toc" -}} {{ $page := .page }} {{ with $page.Fragments.Headings }} {{ 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-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 -}}