forked from drowl87/hextra_mirror
chore: basic rendering from data
This commit is contained in:
parent
c62b1fd401
commit
63f153999e
@ -15,4 +15,5 @@
|
|||||||
{{- partialCached "components/sidebar/collapsible-button" . }}
|
{{- partialCached "components/sidebar/collapsible-button" . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
|
{{- with .items }}{{- partialCached "components/sidebar/collapsible-button" site.Home }}{{ end -}}
|
||||||
</a>
|
</a>
|
||||||
|
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 }}
|
20
layouts/partials/components/sidebar/render-items.html
Normal file
20
layouts/partials/components/sidebar/render-items.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{{- $items := .items -}}
|
||||||
|
{{- $pageLink := .link -}}
|
||||||
|
{{ $shouldOpen := true }}
|
||||||
|
|
||||||
|
|
||||||
|
<div class="ltr:hx-pr-0 hx-overflow-hidden">
|
||||||
|
<ul
|
||||||
|
class='hx-relative hx-flex hx-flex-col hx-gap-1 before:hx-absolute before:hx-inset-y-1 before:hx-w-px before:hx-bg-gray-200 before:hx-content-[""] ltr:hx-ml-3 ltr:hx-pl-3 ltr:before:hx-left-0 rtl:hx-mr-3 rtl:hx-pr-3 rtl:before:hx-right-0 dark:before:hx-bg-neutral-800'
|
||||||
|
>
|
||||||
|
{{- range $items }}
|
||||||
|
{{- $active := or (eq $pageLink .link) (eq (strings.TrimSuffix "/" $pageLink) .link) -}}
|
||||||
|
<li class="hx-flex hx-flex-col {{ 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" .link) -}}
|
||||||
|
{{- end -}}
|
||||||
|
</li>
|
||||||
|
{{- end -}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
@ -25,7 +25,7 @@
|
|||||||
<ul class="hx-flex hx-flex-col hx-gap-1 max-md:hx-hidden">
|
<ul class="hx-flex hx-flex-col hx-gap-1 max-md:hx-hidden">
|
||||||
{{ with $data }}
|
{{ with $data }}
|
||||||
{{ warnf "The data file for the sidebar is still unstable. Please use caution when upgrading." }}
|
{{ warnf "The data file for the sidebar is still unstable. Please use caution when upgrading." }}
|
||||||
<pre>{{ . | jsonify (dict "indent" " ") }}</pre>
|
{{ partial "components/sidebar/render-data" (dict "data" . "page" $context) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ partialCached "components/sidebar/footer" $context site.Home }}
|
{{ partialCached "components/sidebar/footer" $context site.Home }}
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user