blob: 658274e104491ac2a31f67cdab688bc536b17aa5 (
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
|
{{- $currentNode := . }}
{{- if eq .Site.Params.ordersectionsby "title"}}
{{- range .Site.Home.Sections.ByTitle}}
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "level" 0}}
{{- end}}
{{- else}}
{{- range .Site.Home.Sections.ByWeight}}
{{- if not (hasPrefix .Section "_") -}}
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "level" 0}}
{{end}}
{{- end}}
{{- end}}
<!-- templates -->
{{- define "section-tree-nav" }}
{{- $currentNode := .currentnode }}
{{- $level := .level }}
{{- $maxlevel := 99 }}
{{if lt $level $maxlevel }}
{{- with .sect}}
{{- if and .IsSection (or (not .Params.hidden) $.showhidden)}}
{{- $numberOfPages := (len .Sections) }}
{{- $numberOfPages := (len (where .Sections "Params.subpage" "ne" true)) }}
{{- safeHTML .Params.head}}
<li data-nav-id="{{.Permalink}}" class="dd-item
{{- if .IsAncestor $currentNode}} parent{{end}}
{{- if eq .CurrentSection $currentNode.CurrentSection}} active{{end}}
{{- if .Params.alwaysopen}} alwaysopen{{end -}}
{{- if ne $numberOfPages 0 }} haschildren{{end}}
item_level_$level
">
{{$menuTitle := .Title}}
{{if eq $menuTitle ""}}{{$menuTitle = .CurrentSection}}{{end}}
{{if gt $level 0 }}
<a href="{{ .RelPermalink}}">{{safeHTML .Params.Pre}}{{$menuTitle}}{{safeHTML .Params.Post}}</a>
{{end}}
{{- if and (ne $numberOfPages 0) (lt (add $level 1) $maxlevel) }}
{{- if or (.IsAncestor $currentNode) (.Params.alwaysopen) }}
<i class="fas fa-chevron-down ddexp"></i>
{{- else -}}
<i class="fas fa-chevron-right ddexp"></i>
{{- end}}
{{- end}}
{{if eq $level 0 }}
<a href="{{ .RelPermalink}}">{{safeHTML .Params.Pre}}{{$menuTitle}}{{safeHTML .Params.Post}}</a>
{{end}}
{{- if ne $numberOfPages 0 }}
<ul>
{{- .Scratch.Set "pages" .Pages }}
{{- if .Sections}}
{{- .Scratch.Set "pages" (.Pages | union .Sections) }}
{{- end}}
{{- $pages := (.Scratch.Get "pages") }}
{{- if eq .Site.Params.ordersectionsby "title"}}
{{- range $pages.ByTitle }}
{{- if and .Params.hidden (not $.showhidden) }}
{{- else}}
{{ if eq .Kind "section"}}
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "level" (add $level 1)}}
{{- end}}
{{- end}}
{{- end}}
{{- else}}
{{- range $pages.ByWeight }}
{{- if and .Params.hidden (not $.showhidden) }}
{{- else}}
{{ if and (eq .Kind "section") (not .Params.subpage ) }}
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "level" (add $level 1)}}
{{- end}}
{{- end}}
{{- end}}
{{- end}}
</ul>
{{- end}}
</li>
{{- end}}
{{- end}}
{{- end}}
{{- end}}
|