feat: add support for sidebar grouping

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2024-11-20 11:31:33 +01:00
parent 0de58f3fe3
commit 1989620ae1
2 changed files with 15 additions and 5 deletions

View File

@ -515,6 +515,7 @@
"transition",
"truncate",
"underline-offset-2",
"uppercase",
"w-2",
"w-8",
"w-[1200px]",

View File

@ -2,7 +2,6 @@
<nav class="md:text-sm flex flex-col">
<div
class="block py-4 md:hidden text-gray-light dark:text-gray-dark">This section</div>
{{/* The current page is in the table of contents */}}
<ul>
{{ template "renderChildren" .FirstSection }}
</ul>
@ -13,16 +12,26 @@
{{- if .Params.sidebar.reverse }}
{{ $pages = .Pages.Reverse }}
{{- end }}
{{- range $pages }}
{{- if eq .Params.sitemap false }}
{{- continue }}
{{- end }}
{{- $pages = where .Pages "Params.sitemap" "ne" "false" }}
{{- $ungrouped := where $pages "Params.sidebar.group" "==" nil }}
{{- range $ungrouped }}
{{- if .IsSection }}
{{- template "renderList" . }}
{{- else }}
{{- template "renderSingle" . }}
{{- end }}
{{- end }}
{{- range .Params.sidebar.groups }}
<li class="px-2 py-2 pb-2 text-gray-light dark:text-gray-dark uppercase
text-xs font-semibold">{{ . }}</li>
{{- range where $pages "Params.sidebar.group" . }}
{{- if .IsSection }}
{{- template "renderList" . }}
{{- else }}
{{- template "renderSingle" . }}
{{- end }}
{{- end }}
{{- end }}
{{ end }}
{{/* Recursive template for sidebar items */}}