{{- $docsRoot := .Site.GetPage "/docs" }} {{- range $docsRoot.Sections.ByWeight }} {{- template "tree" (dict "page" $ "section" .) }} {{- end }} {{- range $docsRoot.Pages.ByWeight }} {{- if .IsPage }} {{- end }} {{- end }} {{- define "tree" }} {{- $section := .section }} {{- $page := .page }} {{- $permalink := $page.RelPermalink }} {{- $isTopLevel := partial "is-top-level.html" $section.Parent }}
{{ if $isTopLevel }}{{ else }}{{ end }} {{- if eq $section.RelPermalink $permalink }} {{- $scratch := .page.Content -}} {{- if ne (print .page.TableOfContents) "" }} {{ $toc_id := printf "toc-%s" (replace (urlize .page.Title) "." "-") }} {{- safeHTML (replace .page.TableOfContents "TableOfContents" $toc_id) }} {{- end }} {{- end }} {{- $pages := $section.Pages }} {{- with $pages }}
{{- range . }} {{- if .IsPage }} {{- $parentIsTopLevel := partial "is-top-level.html" .Parent.Parent }} {{- if $parentIsTopLevel }} {{- else }} {{- end }} {{- if eq .RelPermalink $permalink }} {{ $toc_id := printf "toc-%s" (replace (urlize .Title) "." "-") }} {{- if ne (print .TableOfContents) "" }} {{- safeHTML (replace .TableOfContents "TableOfContents" $toc_id) }} {{- end }} {{- end }} {{- else }} {{- template "tree" (dict "page" $page "section" .) }} {{- end }} {{- end }}
{{- end }}
{{- end }}