1{{- $showhidden := .Get "showhidden"}} 2{{- $container := .Get "container" | default "ol" }} 3{{- $style := .Get "style" | default "li" }} 4{{- $depth := int (.Get "depth" | default "1") }} 5{{- $description := eq (.Get "description" | default "false") "true" }} 6{{- $sortTerm := .Get "sort" | default "Weight" }} 7{{- $categories := cond (ne (.Get "categories") "") (split (.Get "categories") ",") nil }} 8 9{{- .Scratch.Set "current" .Page }} 10 11{{- if (.Get "page")}} 12 {{- with .Site.GetPage "section" (.Get "page") }} 13 {{- $.Scratch.Set "current" . }} 14 {{- end }} 15{{- end }} 16 17{{- $cpage := (.Scratch.Get "current") }} 18 19{{- (printf "<%s class=\"children children-%s\">" $container $style)|safeHTML}} 20 {{- .Scratch.Set "pages" $cpage.Pages }} 21 {{- if $cpage.Sections}} 22 {{- .Scratch.Set "pages" ($cpage.Pages | union $cpage.Sections) }} 23 {{- end}} 24 {{- $pages := (.Scratch.Get "pages") }} 25 26 {{- if eq $sortTerm "Weight"}} 27 {{- 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}} 28 {{- else if eq $sortTerm "Name"}} 29 {{- 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}} 30 {{- else if eq $sortTerm "PublishDate"}} 31 {{- 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}} 32 {{- else if eq $sortTerm "Date"}} 33 {{- 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}} 34 {{- else if eq $sortTerm "Length"}} 35 {{- 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}} 36 {{- else}} 37 {{- template "childs2" dict "menu" $pages "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $description "sortTerm" $sortTerm "container" $container "categories" $categories}} 38 {{end}} 39{{- (printf "</%s>" $container)|safeHTML}} 40 41{{.Inner|safeHTML}} 42 43{{ define "childs2" }} 44 {{- range .menu }} 45 {{- $in_categories := intersect $.categories .Params.categories }} 46 {{- if or (and .Params.hidden (not $.showhidden)) (and $.categories (not $in_categories)) }} 47 {{- else}} 48 49 50{{- if hasPrefix $.style "h"}} 51 {{- $num := sub ( int (trim $.style "h") ) 1 }} 52 {{- $numn := add $num $.count }} 53 54{{- (printf "<h%d>" $numn)|safeHTML}} 55 <a href="{{.URL}}" >{{ .Title | markdownify }}</a> 56 57{{- else}} 58{{- (printf "<%s>" $.style)|safeHTML}} 59 <a href="{{.URL}}" >{{ .Title | markdownify }}</a> 60{{- end}} 61 62 63 64 65 66 {{- if $.description}} 67 {{- if .Description}} 68<p>{{.Description | markdownify}}</p> 69 {{- end}} 70 {{- end}} 71 72 73 74 {{- if lt $.count $.depth}} 75 {{- .Scratch.Set "pages" .Pages }} 76 {{- if .Sections}} 77 {{- .Scratch.Set "pages" (.Pages | union .Sections) }} 78 {{- end}} 79 {{- $pages := (.Scratch.Get "pages") }} 80 {{- if $pages }} 81{{- if or (eq $.style "li") (eq $.style "dt") }} 82{{- (printf "<%s>" $.container)|safeHTML}} 83{{- end}} 84 85 {{- if eq $.sortTerm "Weight"}} 86 {{- 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}} 87 {{- else if eq $.sortTerm "Name"}} 88 {{- 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}} 89 {{- else if eq $.sortTerm "PublishDate"}} 90 {{- 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}} 91 {{- else if eq $.sortTerm "Date"}} 92 {{- 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}} 93 {{- else if eq $.sortTerm "Length"}} 94 {{- 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}} 95 {{- else}} 96 {{- 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}} 97 {{- end}} 98{{- if or (eq $.style "li") (eq $.style "dt") }} 99{{- (printf "</%s>" $.container)|safeHTML}} 100{{- end }} 101 {{- end }} 102 {{- end }} 103 104 {{- end }} 105 {{- end }} 106 107 108{{- if hasPrefix $.style "h"}} 109 {{- $num := sub ( int (trim $.style "h") ) 1 }} 110 {{- $numn := add $num $.count }} 111 {{- (printf "</h%d>" $numn)|safeHTML}} 112{{- else}} 113 {{- (printf "</%s>" $.style)|safeHTML}} 114{{- end}} 115 116{{- end }} 117