perf: cache sidebar footer

This commit is contained in:
Xin 2023-10-21 23:22:45 +01:00
parent 214cb7994f
commit 230cc438b7

View File

@ -19,7 +19,7 @@
<ul class="flex flex-col gap-1 md:hidden"> <ul class="flex flex-col gap-1 md:hidden">
<!-- Nav --> <!-- Nav -->
{{ template "sidebar-main" (dict "context" site.Home "pageURL" $pageURL "page" $context "toc" true) -}} {{ template "sidebar-main" (dict "context" site.Home "pageURL" $pageURL "page" $context "toc" true) -}}
{{ template "sidebar-footer" }} {{ partialCached "sidebar/footer" $context }}
</ul> </ul>
<!-- Sidebar on large screen --> <!-- Sidebar on large screen -->
@ -29,7 +29,7 @@
{{- else -}} {{- else -}}
<ul class="flex flex-col gap-1 max-md:hidden"> <ul class="flex flex-col gap-1 max-md:hidden">
{{ template "sidebar-main" (dict "context" $navRoot "page" $context "pageURL" $pageURL) }} {{ template "sidebar-main" (dict "context" $navRoot "page" $context "pageURL" $pageURL) }}
{{ template "sidebar-footer" }} {{ partialCached "sidebar/footer" $context }}
</ul> </ul>
{{ end -}} {{ end -}}
</div> </div>
@ -122,7 +122,7 @@
{{ end }} {{ end }}
{{- end -}} {{- end -}}
{{- define "sidebar-footer" -}} {{- define "partials/sidebar/footer" -}}
{{- range site.Menus.sidebar -}} {{- range site.Menus.sidebar -}}
{{- $name := or (T .Identifier) .Name -}} {{- $name := or (T .Identifier) .Name -}}
{{ if eq .Params.type "separator" }} {{ if eq .Params.type "separator" }}
@ -150,12 +150,12 @@
> >
{{- .title -}} {{- .title -}}
{{- with .context }} {{- with .context }}
{{- if or .RegularPages .Sections }}{{ partialCached "sidebear-collapsible-button" . }}{{ end -}} {{- if or .RegularPages .Sections }}{{ partialCached "sidebar/collapsible-button" . }}{{ end -}}
{{ end -}} {{ end -}}
</a> </a>
{{- end -}} {{- end -}}
{{- define "partials/sidebear-collapsible-button" -}} {{- define "partials/sidebar/collapsible-button" -}}
<span class="hextra-sidebar-collapsible-button"> <span class="hextra-sidebar-collapsible-button">
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" class="h-[18px] min-w-[18px] rounded-sm p-0.5 hover:bg-gray-800/5 dark:hover:bg-gray-100/5"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" class="origin-center transition-transform rtl:-rotate-180"></path></svg> <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" class="h-[18px] min-w-[18px] rounded-sm p-0.5 hover:bg-gray-800/5 dark:hover:bg-gray-100/5"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" class="origin-center transition-transform rtl:-rotate-180"></path></svg>
</span> </span>