Welcome to mirror list, hosted at ThFree Co, Russian Federation.

children.html « shortcodes « layouts - github.com/vjeantet/hugo-theme-docport.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f016e2bb20efb4931ecffe880900c702cf10e4b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
{{ $_hugo_config := `{ "version": 1 }` }}
{{- $showhidden := .Get "showhidden"}}
{{- $style :=  .Get "style" | default "li" }}
{{- $depth :=  .Get "depth" | default 1 }}
{{- $withDescription :=  .Get "description" | default false }}
{{- $sortTerm :=  .Get "sort" | default "Weight" }}

{{- .Scratch.Set "current" .Page }}

{{- if (.Get "page")}}
	{{- with .Site.GetPage "section" (.Get "page") }}
		{{- $.Scratch.Set "current" . }}
	{{- end }}
{{- end }}

{{- $cpage := (.Scratch.Get "current") }}



<ul class="children children-{{$style}}">
	{{- .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 "childs" dict "menu" $pages.ByWeight "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
	{{- else if eq $sortTerm "Name"}}
		{{- template "childs" dict "menu" $pages.ByTitle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
	{{- else if eq $sortTerm "PublishDate"}}
		{{- template "childs" dict "menu" $pages.ByPublishDate "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
	{{- else if eq $sortTerm "Date"}}
		{{- template "childs" dict "menu" $pages.ByDate "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
	{{- else if eq $sortTerm "Length"}}
		{{- template "childs" dict "menu" $pages.ByLength "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
	{{- else}}
		{{- template "childs" dict "menu" $pages "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
	{{end}}
</ul>

{{.Inner|safeHTML}}

{{ define "childs" }}
	{{- range .menu }}
		{{- if and .Params.hidden (not $.showhidden) }}
		{{- else}}

<span>
{{- if hasPrefix $.style "h"}}
	{{- $num := sub ( int (trim $.style "h") ) 1 }}
	{{- $numn := add $num $.count }}

	{{- (printf "<h%d>" $numn)|safeHTML}}
		<a href="{{.RelPermalink}}" >{{ .Title }}</a>
	{{- (printf "</h%d>" $numn)|safeHTML}}
{{- else}}
	{{- (printf "<%s>" $.style)|safeHTML}}
		<a href="{{.RelPermalink}}" >{{ .Title }}</a>
	{{- (printf "</%s>" $.style)|safeHTML}}
{{- end}}





			{{- if $.description}}
				{{- if .Description}}
<p>{{.Description}}</p>
				{{- else}}
<p>{{.Summary}}</p>
				{{- end}}
			{{- end}}
</span>


			{{- if lt $.count $.depth}}
{{- if eq $.style "li" }}
<ul>
{{- end}}
	{{- .Scratch.Set "pages" .Pages }}
    {{- if .Sections}}
	    {{- .Scratch.Set "pages" (.Pages | union .Sections) }}
    {{- end}}
    {{- $pages := (.Scratch.Get "pages") }}

	{{- if eq $.sortTerm "Weight"}}
		{{- template "childs" dict "menu" $pages.ByWeight  "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
	{{- else if eq $.sortTerm "Name"}}
		{{- template "childs" dict "menu" $pages.ByTitle  "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
	{{- else if eq $.sortTerm "PublishDate"}}
		{{- template "childs" dict "menu" $pages.ByPublishDate  "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
	{{- else if eq $.sortTerm "Date"}}
		{{- template "childs" dict "menu" $pages.ByDate  "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
	{{- else if eq $.sortTerm "Length"}}
		{{- template "childs" dict "menu" $pages.ByLength  "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
	{{- else}}
		{{- template "childs" dict "menu" $pages  "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
	{{- end}}
{{- if eq $.style "li"}}
</ul>
{{- end }}
			{{- end }}

		{{- end }}
	{{- end }}
{{- end }}