feat: generate sidebar json data for rendering

This commit is contained in:
Xin
2024-04-14 11:31:13 +01:00
parent 63f153999e
commit 33f2cf653b
4 changed files with 58 additions and 4 deletions

View File

@ -4,7 +4,7 @@
{{- range .data -}}
{{- $active := or (eq $pageLink .link) (eq (strings.TrimSuffix "/" $pageLink) .link) -}}
{{- $containsPage := hasPrefix $pageLink .link -}}
{{- $shouldOpen := or (.open) $containsPage $active | default true -}}
{{- $shouldOpen := or (.open) $containsPage $active | default false -}}
<li class="{{ if $shouldOpen }}open{{ end }}">
{{- partial "components/sidebar/item-link" (dict "active" $active "title" .title "link" .link "items" .items) -}}