{{ $isChapter := or (eq .Kind "section") (.Params.chapter)}} {{ if $isChapter }} {{ end }} {{ if $.Site.Params.autoNav }} {{ $.Scratch.Set "_sectionpages" (slice) }} {{ if $.Site.Params.menu }} {{ range $sname := $.Site.Params.menu }} {{ $.Scratch.Add "_sectionpages" ($.Site.GetPage "section" $sname) }} {{ end }} {{ else }} {{ range $sname, $spages := .Site.Sections }} {{ $.Scratch.Add "_sectionpages" ($.Site.GetPage "section" $sname) }} {{ end }} {{ $.Scratch.Set "_sectionpages" (sort ($.Scratch.Get "_sectionpages") "Weight") }} {{ end }} {{ $.Scratch.Set "_allpages" (slice) }} {{ range $.Scratch.Get "_sectionpages" }} {{ if .Content }} {{ $.Scratch.Add "_allpages" . }} {{ end }} {{ range index $.Site.Sections .Section }} {{ $.Scratch.Add "_allpages" .Page }} {{ end }} {{ end }} {{ end }}