2
2
{{ $currentPage := .currentPage }}
3
3
{{ $firstSection := .firstSection }}
4
4
{{ $idPrefix := .idPrefix }}
5
-
6
5
{{ with $firstSection }}
7
6
< ul class ="sidebar__ul ">
8
7
{{ $pages := .Pages.ByWeight }}
9
8
{{ range $index, $p := $pages }}
10
9
{{- $onPage := eq $currentUrl $p.Permalink -}}
11
10
{{- $isAncestor := $p.IsAncestor $currentPage -}}
12
11
{{- $shouldExpand := or $onPage $isAncestor -}}
13
- {{/* These variables are used to create a unique id to be attached to every link
14
- that accessibility users can correctly "Skip Table Of Contents" */}}
15
12
{{- $sectionID := printf "%ssection-%s" $idPrefix (urlize $p.Permalink) -}}
16
13
{{- $linkID := printf "%slink-%s" $idPrefix (urlize $p.Permalink) -}}
17
14
{{- $nextIndex := add $index 1 -}}
18
15
{{- $nextLink := index $pages $nextIndex -}}
19
-
20
16
{{ if eq $p.Kind "section" }}
21
17
< li class ="sidebar__section ">
22
18
< button
35
31
class ="sidebar__children "
36
32
{{ if not $shouldExpand }}hidden{{ end }}
37
33
>
34
+ {{ if and .Content (gt (len .Pages) 0) }}
35
+ < ul >
36
+ < li class ="sidebar__page ">
37
+ < a
38
+ href ="{{ $p.Permalink }} "
39
+ class ="sidebar__link {{ if $onPage }}sidebar__link--current{{ end }} "
40
+ {{ if $onPage }}aria-current ="page "{{ end }}
41
+ >
42
+ Overview
43
+ </ a >
44
+ </ li >
45
+ </ ul >
46
+ {{ end }}
47
+
38
48
{{ partial "sidebar-list.html" (dict
39
49
"firstSection" $p
40
50
"currentUrl" $currentUrl
43
53
) }}
44
54
</ div >
45
55
</ li >
46
-
47
56
{{ else if eq $p.Kind "page" }}
48
57
{{- $tocHasItems := (in $p.TableOfContents "< li > ") -}}
49
58
{{- $pageHasTOC := (and $onPage $tocHasItems $p.Params.toc) -}}
82
91
{{ end }}
83
92
</ li >
84
93
{{ end }}
85
-
86
94
{{ end }}
87
95
</ ul >
88
- {{ end }}
89
-
90
- {{/* {{ if gt (.WordCount) 0 }}
91
- < ul >
92
- < li >
93
- < a href ="{{ .Permalink }} " style ="color: purple; {{if $onPage}}font-weight: bold;{{end}} "> {{ .Title }} - Overview</ a >
94
- </ li >
95
- </ ul >
96
- {{ end }} */}}
96
+ {{ end }}
0 commit comments