Skip to content

Commit 1989620

Browse files
committed
feat: add support for sidebar grouping
Signed-off-by: David Karlsson <[email protected]>
1 parent 0de58f3 commit 1989620

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

hugo_stats.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@
515515
"transition",
516516
"truncate",
517517
"underline-offset-2",
518+
"uppercase",
518519
"w-2",
519520
"w-8",
520521
"w-[1200px]",

layouts/partials/sidebar/sections.html

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<nav class="md:text-sm flex flex-col">
33
<div
44
class="block py-4 md:hidden text-gray-light dark:text-gray-dark">This section</div>
5-
{{/* The current page is in the table of contents */}}
65
<ul>
76
{{ template "renderChildren" .FirstSection }}
87
</ul>
@@ -13,16 +12,26 @@
1312
{{- if .Params.sidebar.reverse }}
1413
{{ $pages = .Pages.Reverse }}
1514
{{- end }}
16-
{{- range $pages }}
17-
{{- if eq .Params.sitemap false }}
18-
{{- continue }}
19-
{{- end }}
15+
{{- $pages = where .Pages "Params.sitemap" "ne" "false" }}
16+
{{- $ungrouped := where $pages "Params.sidebar.group" "==" nil }}
17+
{{- range $ungrouped }}
2018
{{- if .IsSection }}
2119
{{- template "renderList" . }}
2220
{{- else }}
2321
{{- template "renderSingle" . }}
2422
{{- end }}
2523
{{- end }}
24+
{{- range .Params.sidebar.groups }}
25+
<li class="px-2 py-2 pb-2 text-gray-light dark:text-gray-dark uppercase
26+
text-xs font-semibold">{{ . }}</li>
27+
{{- range where $pages "Params.sidebar.group" . }}
28+
{{- if .IsSection }}
29+
{{- template "renderList" . }}
30+
{{- else }}
31+
{{- template "renderSingle" . }}
32+
{{- end }}
33+
{{- end }}
34+
{{- end }}
2635
{{ end }}
2736

2837
{{/* Recursive template for sidebar items */}}

0 commit comments

Comments
 (0)