mirror of
https://github.com/imfing/hextra.git
synced 2025-07-02 02:08:20 -04:00
chore: basic rendering from data
This commit is contained in:
15
layouts/partials/components/sidebar/render-data.html
Normal file
15
layouts/partials/components/sidebar/render-data.html
Normal file
@ -0,0 +1,15 @@
|
||||
{{- $page := .page -}}
|
||||
{{- $pageLink := $page.RelPermalink -}}
|
||||
|
||||
{{- range .data -}}
|
||||
{{- $active := or (eq $pageLink .link) (eq (strings.TrimSuffix "/" $pageLink) .link) -}}
|
||||
{{- $containsPage := hasPrefix $pageLink .link -}}
|
||||
{{- $shouldOpen := or (.open) $containsPage $active | default true -}}
|
||||
|
||||
<li class="{{ if $shouldOpen }}open{{ end }}">
|
||||
{{- partial "components/sidebar/item-link" (dict "active" $active "title" .title "link" .link "items" .items) -}}
|
||||
{{- if .items -}}
|
||||
{{- partial "components/sidebar/render-items" (dict "items" .items "link" $pageLink) -}}
|
||||
{{- end -}}
|
||||
</li>
|
||||
{{ end }}
|
Reference in New Issue
Block a user