| 1 |
{{- $showhidden := .Get "showhidden"}} |
| 2 |
{{- $style := .Get "style" | default "li" }} |
| 3 |
{{- $depth := .Get "depth" | default 1 }} |
| 4 |
{{- $withDescription := .Get "description" | default false }} |
| 5 |
{{- $sortTerm := .Get "sort" | default "Weight" }} |
| 6 |
|
| 7 |
{{- .Scratch.Set "current" .Page }} |
| 8 |
|
| 9 |
{{- if (.Get "page")}} |
| 10 |
{{- with .Site.GetPage "section" (.Get "page") }} |
| 11 |
{{- $.Scratch.Set "current" . }} |
| 12 |
{{- end }} |
| 13 |
{{- end }} |
| 14 |
|
| 15 |
{{- $cpage := (.Scratch.Get "current") }} |
| 16 |
|
| 17 |
<ul class="children children-{{$style}}"> |
| 18 |
{{- .Scratch.Set "pages" $cpage.Pages }} |
| 19 |
{{- if $cpage.Sections}} |
| 20 |
{{- .Scratch.Set "pages" ($cpage.Pages | union $cpage.Sections) }} |
| 21 |
{{- end}} |
| 22 |
{{- $pages := (.Scratch.Get "pages") }} |
| 23 |
|
| 24 |
{{- if eq $sortTerm "Weight"}} |
| 25 |
{{- template "childs" dict "menu" $pages.ByWeight "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "withDescription" $withDescription "sortTerm" $sortTerm}} |
| 26 |
{{- else if eq $sortTerm "Name"}} |
| 27 |
{{- template "childs" dict "menu" $pages.ByTitle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "withDescription" $withDescription "sortTerm" $sortTerm}} |
| 28 |
{{- else if eq $sortTerm "PublishDate"}} |
| 29 |
{{- template "childs" dict "menu" $pages.ByPublishDate "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "withDescription" $withDescription "sortTerm" $sortTerm}} |
| 30 |
{{- else if eq $sortTerm "Date"}} |
| 31 |
{{- template "childs" dict "menu" $pages.ByDate "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "withDescription" $withDescription "sortTerm" $sortTerm}} |
| 32 |
{{- else if eq $sortTerm "Length"}} |
| 33 |
{{- template "childs" dict "menu" $pages.ByLength "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "withDescription" $withDescription "sortTerm" $sortTerm}} |
| 34 |
{{- else}} |
| 35 |
{{- template "childs" dict "menu" $pages "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "withDescription" $withDescription "sortTerm" $sortTerm}} |
| 36 |
{{end}} |
| 37 |
</ul> |
| 38 |
|
| 39 |
{{- define "childs" }} |
| 40 |
{{- range .menu }} |
| 41 |
{{- if and .Params.hidden (not $.showhidden) }} |
| 42 |
{{- else}} |
| 43 |
<span> |
| 44 |
{{- if hasPrefix $.style "h"}} |
| 45 |
{{- $num := sub ( int (trim $.style "h") ) 1 }} |
| 46 |
{{- $numn := add $num $.count }} |
| 47 |
{{- (printf "<h%d>" $numn)|safeHTML}} |
| 48 |
<a href="{{.Permalink}}">{{ .Title }}</a> |
| 49 |
{{- (printf "</h%d>" $numn)|safeHTML}} |
| 50 |
{{- else}} |
| 51 |
{{- (printf "<%s>" $.style)|safeHTML}} |
| 52 |
<a href="{{.Permalink}}">{{ .Title }}</a> |
| 53 |
{{- (printf "</%s>" $.style)|safeHTML}} |
| 54 |
{{- end}} |
| 55 |
|
| 56 |
{{- if $.withDescription}} |
| 57 |
{{- if .Description}} |
| 58 |
<p>{{.Description}}</p> |
| 59 |
{{- else}} |
| 60 |
<p>{{.Summary}}</p> |
| 61 |
{{- end}} |
| 62 |
{{- end}} |
| 63 |
</span> |
| 64 |
{{- if lt $.count $.depth}} |
| 65 |
{{- if eq $.style "li" }} |
| 66 |
<ul> |
| 67 |
{{- end}} |
| 68 |
{{- .Scratch.Set "pages" .Pages }} |
| 69 |
{{- if .Sections}} |
| 70 |
{{- .Scratch.Set "pages" (.Pages | union .Sections) }} |
| 71 |
{{- end}} |
| 72 |
{{- $pages := (.Scratch.Get "pages") }} |
| 73 |
|
| 74 |
{{- if eq $.sortTerm "Weight"}} |
| 75 |
{{- template "childs" dict "menu" $pages.ByWeight "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "withDescription" $.withDescription "sortTerm" $.sortTerm}} |
| 76 |
{{- else if eq $.sortTerm "Name"}} |
| 77 |
{{- template "childs" dict "menu" $pages.ByTitle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "withDescription" $.withDescription "sortTerm" $.sortTerm}} |
| 78 |
{{- else if eq $.sortTerm "PublishDate"}} |
| 79 |
{{- template "childs" dict "menu" $pages.ByPublishDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "withDescription" $.withDescription "sortTerm" $.sortTerm}} |
| 80 |
{{- else if eq $.sortTerm "Date"}} |
| 81 |
{{- template "childs" dict "menu" $pages.ByDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "withDescription" $.withDescription "sortTerm" $.sortTerm}} |
| 82 |
{{- else if eq $.sortTerm "Length"}} |
| 83 |
{{- template "childs" dict "menu" $pages.ByLength "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "withDescription" $.withDescription "sortTerm" $.sortTerm}} |
| 84 |
{{- else}} |
| 85 |
{{- template "childs" dict "menu" $pages "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "withDescription" $.withDescription "sortTerm" $.sortTerm}} |
| 86 |
{{- end}} |
| 87 |
{{- if eq $.style "li"}} |
| 88 |
</ul> |
| 89 |
{{- end }} |
| 90 |
{{- end }} |
| 91 |
{{- end }} |
| 92 |
{{- end }} |
| 93 |
{{- end }} |