|
11 | 11 | <div class="block py-4 text-gray-200 md:hidden dark:text-gray-200"> |
12 | 12 | This section |
13 | 13 | </div> |
14 | | -<ul> |
15 | | - {{- $first := .FirstSection }} |
16 | | - {{- if eq $first.Title "Manuals" }} |
17 | | - {{- if eq page $first }} |
18 | | - {{/* 1) On /manuals/ → grouped flat list (unchanged) */}} |
19 | | - {{- $sections := $first.Sections }} |
20 | | - {{- $ungrouped := where $sections "Params.sidebar.group" "==" nil }} |
21 | | - {{- range $ungrouped }}{{ template "renderSingle" . }}{{- end }} |
22 | | - {{- range $first.Params.sidebar.groups }} |
23 | | - <div class="navbar-group"> |
24 | | - <li class="navbar-group-font-title">{{ . }}</li> |
25 | | - {{- range where $sections "Params.sidebar.group" . }} |
26 | | - {{ template "renderSingle" . }} |
| 14 | + <ul> |
| 15 | + {{- $first := .FirstSection }} |
| 16 | + {{- if eq $first.Title "Manuals" }} |
| 17 | + {{- if eq page $first }} |
| 18 | + {{/* 1) On /manuals/ → list all manuals, grouped by Params.sidebar.groups (multi-group supported) */}} |
| 19 | + {{- $sections := $first.Sections }} |
| 20 | + {{- /* Manuals without any group */}} |
| 21 | + {{- $ungrouped := where $sections "Params.sidebar.group" "==" nil }} |
| 22 | + {{- range $ungrouped }} |
| 23 | + {{ template "renderSingle" . }} |
| 24 | + {{- end }} |
| 25 | + {{- /* Then each declared group, allowing multiple groups per manual */}} |
| 26 | + {{- range $group := $first.Params.sidebar.groups }} |
| 27 | + <div class="navbar-group"> |
| 28 | + <li class="navbar-group-font-title">{{ $group }}</li> |
| 29 | + {{- range $sections }} |
| 30 | + {{- if in .Params.sidebar.group $group }} |
| 31 | + {{ template "renderSingle" . }} |
| 32 | + {{- end }} |
| 33 | + {{- end }} |
| 34 | + </div> |
| 35 | + {{- end }} |
| 36 | + {{- else }} |
| 37 | + {{/* 2) Under a specific manual → render that manual’s full collapsible tree */}} |
| 38 | + {{- range $first.Sections }} |
| 39 | + {{- if or (eq page .) (page.IsDescendant .) }} |
| 40 | + {{ template "renderList" . }} |
27 | 41 | {{- end }} |
28 | | - </div> |
29 | | - {{- end }} |
30 | | - {{- else }} |
31 | | - {{/* 2) Under a manual → show that manual’s entire tree */}} |
32 | | - {{- range $first.Sections }} |
33 | | - {{- if or (eq page .) (page.IsDescendant .) }} |
34 | | - {{ template "renderList" . }} |
35 | 42 | {{- end }} |
36 | 43 | {{- end }} |
| 44 | + {{- else }} |
| 45 | + {{/* 3) Everywhere else → normal recursive nav of FirstSection */}} |
| 46 | + {{ template "renderChildren" $first }} |
37 | 47 | {{- end }} |
38 | | - {{- else }} |
39 | | - {{/* 3) Everywhere else → normal recursive nav */}} |
40 | | - {{ template "renderChildren" $first }} |
41 | | - {{- end }} |
42 | | -</ul> |
| 48 | + </ul> |
43 | 49 | </nav> |
44 | 50 |
|
45 | 51 | {{ define "renderChildren" }} |
|
55 | 61 | {{- template "renderSingle" . }} |
56 | 62 | {{- end }} |
57 | 63 | {{- end }} |
58 | | - {{- range .Params.sidebar.groups }} |
59 | | - <!-- Main titles --> |
| 64 | + {{- /* grouping, allowing multiple groups per page */}} |
| 65 | + {{- range $group := .Params.sidebar.groups }} |
60 | 66 | <div class="navbar-group"> |
61 | | - <li class="navbar-group-font-title"> |
62 | | - {{ . }} |
63 | | - </li> |
64 | | - {{- range where $pages "Params.sidebar.group" . }} |
65 | | - {{- if .IsSection }} |
66 | | - {{- template "renderList" . }} |
67 | | - {{- else }} |
68 | | - {{- template "renderSingle" . }} |
| 67 | + <li class="navbar-group-font-title">{{ $group }}</li> |
| 68 | + {{- range $pages }} |
| 69 | + {{- if in .Params.sidebar.group $group }} |
| 70 | + {{- if .IsSection }} |
| 71 | + {{- template "renderList" . }} |
| 72 | + {{- else }} |
| 73 | + {{- template "renderSingle" . }} |
| 74 | + {{- end }} |
69 | 75 | {{- end }} |
70 | 76 | {{- end }} |
71 | 77 | </div> |
|
76 | 82 | {{ define "renderList" }} |
77 | 83 | {{ $isCurrent := eq page . }} |
78 | 84 | {{ $expanded := or $isCurrent (page.IsDescendant .) }} |
79 | | - <li class="" x-data="{ expanded: {{ $expanded }} }"> |
80 | | - <div |
81 | | - class="{{ if $isCurrent }} |
82 | | - navbar-entry-background-current |
83 | | - {{ end }} flex w-full items-center justify-between rounded-sm" |
84 | | - > |
| 85 | + <li x-data="{ expanded: {{ $expanded }} }"> |
| 86 | + <div class="{{ if $isCurrent }}navbar-entry-background-current{{ end }} |
| 87 | + flex w-full items-center justify-between rounded-sm"> |
85 | 88 | <div class="navbar-entry-margin w-full truncate"> |
86 | 89 | {{- if .Permalink }} |
87 | | - <!-- Sections that have children and linking to a page --> |
88 | 90 | <a |
89 | | - {{ if $isCurrent }} |
90 | | - aria-current="page" id="sidebar-current-page" |
91 | | - {{ end }} |
| 91 | + {{ if $isCurrent }}aria-current="page" id="sidebar-current-page"{{ end }} |
92 | 92 | class="hover:text-blue block select-none hover:dark:text-blue-400" |
93 | 93 | href="{{ .Permalink }}" |
94 | 94 | > |
95 | 95 | {{ template "renderTitle" . }} |
96 | 96 | </a> |
97 | 97 | {{- else }} |
98 | | - <!-- Sections that have children and do not link to a page --> |
99 | 98 | <button |
100 | 99 | @click="expanded = !expanded" |
101 | 100 | class="hover:text-blue w-full text-left select-none hover:dark:text-blue-400" |
|
104 | 103 | </button> |
105 | 104 | {{- end }} |
106 | 105 | </div> |
107 | | - <!-- Expand/collapse button --> |
108 | | - <button |
109 | | - @click="expanded = !expanded" |
110 | | - class="rounded-sm hover:bg-gray-200 hover:dark:bg-gray-800" |
111 | | - > |
112 | | - <span |
113 | | - :class="{ 'hidden' : expanded }" |
114 | | - class="icon-svg {{ if $expanded }}hidden{{ end }}" |
115 | | - > |
| 106 | + <button @click="expanded = !expanded" |
| 107 | + class="rounded-sm hover:bg-gray-200 hover:dark:bg-gray-800"> |
| 108 | + <span :class="{ 'hidden': expanded }" |
| 109 | + class="icon-svg {{ if $expanded }}hidden{{ end }}"> |
116 | 110 | {{ partialCached "icon" "arrow_drop_down" "arrow_drop_down" }} |
117 | 111 | </span> |
118 | | - <span |
119 | | - :class="{ 'hidden' : !expanded }" |
120 | | - class="icon-svg {{ if not $expanded }}hidden{{ end }}" |
121 | | - > |
| 112 | + <span :class="{ 'hidden': !expanded }" |
| 113 | + class="icon-svg {{ if not $expanded }}hidden{{ end }}"> |
122 | 114 | {{ partialCached "icon" "arrow_drop_up" "arrow_drop_up" }} |
123 | 115 | </span> |
124 | 116 | </button> |
125 | 117 | </div> |
126 | | - <ul |
127 | | - :class="{ 'hidden' : !expanded }" |
128 | | - class="{{ if not $expanded }}hidden{{ end }} ml-3" |
129 | | - > |
| 118 | + <ul :class="{ 'hidden': !expanded }" |
| 119 | + class="{{ if not $expanded }}hidden{{ end }} ml-3"> |
130 | 120 | {{ template "renderChildren" . }} |
131 | 121 | </ul> |
132 | 122 | </li> |
|
145 | 135 | </li> |
146 | 136 | {{- else }} |
147 | 137 | {{ $isCurrent := eq page . }} |
148 | | - <li |
149 | | - class="navbar-entry-margin hover:text-blue {{ if $isCurrent }} |
150 | | - navbar-entry-background-current |
151 | | - {{ end }} rounded-sm hover:dark:text-blue-400" |
152 | | - > |
| 138 | + <li class="navbar-entry-margin hover:text-blue {{ if $isCurrent }}navbar-entry-background-current{{ end }} rounded-sm hover:dark:text-blue-400"> |
153 | 139 | <a |
154 | | - {{ if $isCurrent }} |
155 | | - aria-current="page" id="sidebar-current-page" |
156 | | - {{ end }} |
| 140 | + {{ if $isCurrent }}aria-current="page" id="sidebar-current-page"{{ end }} |
157 | 141 | class="block w-full truncate" |
158 | 142 | href="{{ .Permalink }}" |
159 | 143 | title="{{ .LinkTitle }}" |
|
168 | 152 | {{ .LinkTitle }} |
169 | 153 | {{- with .Params.sidebar.badge }} |
170 | 154 | <span> |
171 | | - {{- partial "components/badge.html" (dict "color" .color "content" .text) }} |
| 155 | + {{ partial "components/badge.html" (dict "color" .color "content" .text) }} |
172 | 156 | </span> |
173 | 157 | {{- end }} |
174 | 158 | {{ end }} |
0 commit comments