|
5 | 5 | - Dynamically applies current page highlighting and expanded states. |
6 | 6 | - Handles external links via `Params.sidebar.goto` in `renderSingle`. |
7 | 7 | - Requires `Params.sitemap` and `Params.sidebar` for filtering and behavior. |
8 | | - */ |
9 | | --}} |
| 8 | +*/ -}} |
10 | 9 | <!-- section tree --> |
11 | 10 | <nav class="navbar-font flex flex-col"> |
12 | 11 | <div class="block py-4 text-gray-200 md:hidden dark:text-gray-200"> |
13 | 12 | This section |
14 | 13 | </div> |
15 | | - <ul> |
16 | | - {{ template "renderChildren" .FirstSection }} |
17 | | - </ul> |
| 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" . }} |
| 27 | + {{- 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 | + {{- end }} |
| 36 | + {{- end }} |
| 37 | + {{- end }} |
| 38 | + {{- else }} |
| 39 | + {{/* 3) Everywhere else → normal recursive nav */}} |
| 40 | + {{ template "renderChildren" $first }} |
| 41 | + {{- end }} |
| 42 | +</ul> |
18 | 43 | </nav> |
19 | 44 |
|
20 | 45 | {{ define "renderChildren" }} |
|
45 | 70 | {{- end }} |
46 | 71 | </div> |
47 | 72 | {{- end }} |
48 | | - |
49 | 73 | {{ end }} |
50 | 74 |
|
51 | 75 | {{/* Recursive template for sidebar items */}} |
|
60 | 84 | > |
61 | 85 | <div class="navbar-entry-margin w-full truncate"> |
62 | 86 | {{- if .Permalink }} |
63 | | - {{/* If the link is not empty, use it */}} |
64 | 87 | <!-- Sections that have children and linking to a page --> |
65 | 88 | <a |
66 | 89 | {{ if $isCurrent }} |
|
72 | 95 | {{ template "renderTitle" . }} |
73 | 96 | </a> |
74 | 97 | {{- else }} |
75 | | - {{/* Otherwise, just expand the section */}} |
76 | 98 | <!-- Sections that have children and do not link to a page --> |
77 | 99 | <button |
78 | 100 | @click="expanded = !expanded" |
|
82 | 104 | </button> |
83 | 105 | {{- end }} |
84 | 106 | </div> |
85 | | - <!-- Expand group button --> |
| 107 | + <!-- Expand/collapse button --> |
86 | 108 | <button |
87 | 109 | @click="expanded = !expanded" |
88 | 110 | class="rounded-sm hover:bg-gray-200 hover:dark:bg-gray-800" |
|
0 commit comments