mirror of
https://github.com/imfing/hextra.git
synced 2025-07-01 05:37:18 -04:00
chore: cache tree branch without leaf
This commit is contained in:
@ -0,0 +1,15 @@
|
||||
{{- $entry := . -}}
|
||||
|
||||
<div class="pt-1 ltr:pr-0 overflow-hidden transition-all ease-in-out duration-200">
|
||||
<ul class='relative flex flex-col gap-1 before:absolute before:inset-y-1 before:w-px before:bg-gray-200 before:content-[""] ltr:ml-3 ltr:pl-3 ltr:before:left-0 rtl:mr-3 rtl:pr-3 rtl:before:right-0 dark:before:bg-neutral-800'>
|
||||
{{- range $entry }}
|
||||
{{- $shouldOpen := .open | default false }}
|
||||
<li class="flex flex-col gap-1 {{ if $shouldOpen }}open{{ end }}">
|
||||
{{- template "sidebar-item-link" (dict "context" . "active" false "title" .title "link" .link) -}}
|
||||
{{- if .section -}}
|
||||
{{- partial "sidebar/render-tree-branch-without-leaf" .section -}}
|
||||
{{- end -}}
|
||||
</li>
|
||||
{{- end -}}
|
||||
</ul>
|
||||
</div>
|
@ -3,11 +3,16 @@
|
||||
{{- $pageLink := .page.RelPermalink -}}
|
||||
{{- range .tree -}}
|
||||
{{- $active := eq $pageLink .link -}}
|
||||
{{- $shouldOpen := or (.open) (hasPrefix $pageLink .link) $active | default true }}
|
||||
{{- $containsPage := hasPrefix $pageLink .link -}}
|
||||
{{- $shouldOpen := or (.open) $containsPage $active | default false }}
|
||||
<li class="{{ if $shouldOpen }}open{{ end }}">
|
||||
{{- template "sidebar-item-link" (dict "context" . "active" $active "title" .title "link" .link) -}}
|
||||
{{- if .section -}}
|
||||
{{- if not $containsPage -}}
|
||||
{{- partialCached "sidebar/render-tree-branch-without-leaf" .section .section -}}
|
||||
{{- else -}}
|
||||
{{- partial "sidebar/render-tree-branch" (dict "context" $context "entry" .section "page" $page) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</li>
|
||||
{{ end }}
|
||||
|
Reference in New Issue
Block a user