{{/* Parse toc.yaml and store the resulting map to $scratch */}} {{ $scratch := partialCached "utils/tocparser.html" . . }} {{ $ctx := . }} {{/* Get the name of the first section */}} {{ $firstSection := (index ($scratch.GetSortedMapValues "sections") 0).title }} {{/* Render the top-nav in sidebar for small screens */}} {{ if $firstSection }} {{ $allSections := slice }} {{ range $i, $e := ($scratch.GetSortedMapValues "sections") }} {{ $allSections = $allSections | append (index $e "title") }} {{ end }} {{ end }} {{/* Recursive template for sidebar items */}} {{ define "tocRender" }} {{ $ctx := .ctx }} {{ $sections := .sections }} {{ if .entry.sectiontitle }} {{ $expanded := in $sections .entry.sectiontitle }} {{/* .entry is a section */}}
  • {{/* See event handler in assets/js/src/sidebar.js */}}
  • {{ else }} {{/* .entry is a page */}} {{ $isCurrent := eq (urls.Parse $ctx.Permalink).Path .entry.path }} {{ end }} {{ end }}