Skip to content

Commit bbe6bc4

Browse files
drilldown experiment
Signed-off-by: Craig <[email protected]>
1 parent 4ab3804 commit bbe6bc4

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

layouts/partials/sidebar/sections.html

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,41 @@
55
- Dynamically applies current page highlighting and expanded states.
66
- Handles external links via `Params.sidebar.goto` in `renderSingle`.
77
- Requires `Params.sitemap` and `Params.sidebar` for filtering and behavior.
8-
*/
9-
-}}
8+
*/ -}}
109
<!-- section tree -->
1110
<nav class="navbar-font flex flex-col">
1211
<div class="block py-4 text-gray-200 md:hidden dark:text-gray-200">
1312
This section
1413
</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>
1843
</nav>
1944

2045
{{ define "renderChildren" }}
@@ -45,7 +70,6 @@
4570
{{- end }}
4671
</div>
4772
{{- end }}
48-
4973
{{ end }}
5074

5175
{{/* Recursive template for sidebar items */}}
@@ -60,7 +84,6 @@
6084
>
6185
<div class="navbar-entry-margin w-full truncate">
6286
{{- if .Permalink }}
63-
{{/* If the link is not empty, use it */}}
6487
<!-- Sections that have children and linking to a page -->
6588
<a
6689
{{ if $isCurrent }}
@@ -72,7 +95,6 @@
7295
{{ template "renderTitle" . }}
7396
</a>
7497
{{- else }}
75-
{{/* Otherwise, just expand the section */}}
7698
<!-- Sections that have children and do not link to a page -->
7799
<button
78100
@click="expanded = !expanded"
@@ -82,7 +104,7 @@
82104
</button>
83105
{{- end }}
84106
</div>
85-
<!-- Expand group button -->
107+
<!-- Expand/collapse button -->
86108
<button
87109
@click="expanded = !expanded"
88110
class="rounded-sm hover:bg-gray-200 hover:dark:bg-gray-800"

0 commit comments

Comments
 (0)