{{- $showhidden := .Get "showhidden"}} {{- $container := .Get "container" | default "ol" }} {{- $style := .Get "style" | default "li" }} {{- $depth := int (.Get "depth" | default "1") }} {{- $description := eq (.Get "description" | default "false") "true" }} {{- $sortTerm := .Get "sort" | default "Weight" }} {{- $categories := cond (ne (.Get "categories") "") (split (.Get "categories") ",") nil }} {{- .Scratch.Set "current" .Page }} {{- if (.Get "page")}} {{- with .Site.GetPage "section" (.Get "page") }} {{- $.Scratch.Set "current" . }} {{- end }} {{- end }} {{- $cpage := (.Scratch.Get "current") }} {{- (printf "<%s class=\"children children-%s\">" $container $style)|safeHTML}} {{- .Scratch.Set "pages" $cpage.Pages }} {{- if $cpage.Sections}} {{- .Scratch.Set "pages" ($cpage.Pages | union $cpage.Sections) }} {{- end}} {{- $pages := (.Scratch.Get "pages") }} {{- if eq $sortTerm "Weight"}} {{- template "childs2" dict "menu" $pages.ByWeight "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $description "sortTerm" $sortTerm "container" $container "categories" $categories}} {{- else if eq $sortTerm "Name"}} {{- template "childs2" dict "menu" $pages.ByTitle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $description "sortTerm" $sortTerm "container" $container "categories" $categories}} {{- else if eq $sortTerm "PublishDate"}} {{- template "childs2" dict "menu" $pages.ByPublishDate "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $description "sortTerm" $sortTerm "container" $container "categories" $categories}} {{- else if eq $sortTerm "Date"}} {{- template "childs2" dict "menu" $pages.ByDate "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $description "sortTerm" $sortTerm "container" $container "categories" $categories}} {{- else if eq $sortTerm "Length"}} {{- template "childs2" dict "menu" $pages.ByLength "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $description "sortTerm" $sortTerm "container" $container "categories" $categories}} {{- else}} {{- template "childs2" dict "menu" $pages "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $description "sortTerm" $sortTerm "container" $container "categories" $categories}} {{end}} {{- (printf "" $container)|safeHTML}} {{.Inner|safeHTML}} {{ define "childs2" }} {{- range .menu }} {{- $in_categories := intersect $.categories .Params.categories }} {{- if or (and .Params.hidden (not $.showhidden)) (and $.categories (not $in_categories)) }} {{- else}} {{- if hasPrefix $.style "h"}} {{- $num := sub ( int (trim $.style "h") ) 1 }} {{- $numn := add $num $.count }} {{- (printf "" $numn)|safeHTML}} {{ .Title | markdownify }} {{- else}} {{- (printf "<%s>" $.style)|safeHTML}} {{ .Title | markdownify }} {{- end}} {{- if $.description}} {{- if .Description}}

{{.Description | markdownify}}

{{- end}} {{- end}} {{- if lt $.count $.depth}} {{- .Scratch.Set "pages" .Pages }} {{- if .Sections}} {{- .Scratch.Set "pages" (.Pages | union .Sections) }} {{- end}} {{- $pages := (.Scratch.Get "pages") }} {{- if $pages }} {{- if or (eq $.style "li") (eq $.style "dt") }} {{- (printf "<%s>" $.container)|safeHTML}} {{- end}} {{- if eq $.sortTerm "Weight"}} {{- template "childs2" dict "menu" $pages.ByWeight "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "container" $.container "categories" $.categories}} {{- else if eq $.sortTerm "Name"}} {{- template "childs2" dict "menu" $pages.ByTitle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "container" $.container "categories" $.categories}} {{- else if eq $.sortTerm "PublishDate"}} {{- template "childs2" dict "menu" $pages.ByPublishDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "container" $.container "categories" $.categories}} {{- else if eq $.sortTerm "Date"}} {{- template "childs2" dict "menu" $pages.ByDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "container" $.container "categories" $.categories}} {{- else if eq $.sortTerm "Length"}} {{- template "childs2" dict "menu" $pages.ByLength "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "container" $.container "categories" $.categories}} {{- else}} {{- template "childs2" dict "menu" $pages "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "container" $.container "categories" $.categories}} {{- end}} {{- if or (eq $.style "li") (eq $.style "dt") }} {{- (printf "" $.container)|safeHTML}} {{- end }} {{- end }} {{- end }} {{- end }} {{- end }} {{- if hasPrefix $.style "h"}} {{- $num := sub ( int (trim $.style "h") ) 1 }} {{- $numn := add $num $.count }} {{- (printf "
" $numn)|safeHTML}} {{- else}} {{- (printf "" $.style)|safeHTML}} {{- end}} {{- end }}