From a1c7acd6b509795c1b102ab659f659ae23e212f0 Mon Sep 17 00:00:00 2001 From: Xin Date: Sun, 14 Apr 2024 23:53:53 +0100 Subject: [PATCH] feat: add params page.sidebar.source and page.sidebar.cache --- .../sidebar/{footer.html => bottom.html} | 0 layouts/partials/sidebar-ng.html | 27 ++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) rename layouts/partials/components/sidebar/{footer.html => bottom.html} (100%) diff --git a/layouts/partials/components/sidebar/footer.html b/layouts/partials/components/sidebar/bottom.html similarity index 100% rename from layouts/partials/components/sidebar/footer.html rename to layouts/partials/components/sidebar/bottom.html diff --git a/layouts/partials/sidebar-ng.html b/layouts/partials/sidebar-ng.html index 7fb3a71..8e7a6bf 100644 --- a/layouts/partials/sidebar-ng.html +++ b/layouts/partials/sidebar-ng.html @@ -8,9 +8,18 @@ {{- $navRoot := cond (eq site.Home.Type "docs") site.Home $context.FirstSection -}} {{- $pageURL := $context.RelPermalink -}} -{{/* {{ $data := partialCached "components/sidebar/get-section-data" $context $context.Section }} */}} -{{- $data := partial "components/sidebar/generate-section-data" $navRoot | unmarshal -}} -{{- $dataMobile := partial "components/sidebar/generate-section-data" site.Home | unmarshal -}} +{{- $data := slice -}} +{{- $dataMobile := slice -}} + +{{- if (eq site.Params.page.sidebar.source "data") -}} + {{ $data = partialCached "components/sidebar/get-section-data" $context $context.Section }} + {{- $dataMobile = $data -}} +{{- else -}} + {{- $data = (partialCached "components/sidebar/generate-section-data" $navRoot $navRoot) | unmarshal -}} + {{- $dataMobile = (partialCached "components/sidebar/generate-section-data" site.Home site.Home) | unmarshal -}} +{{- end -}} + +{{- $shouldCache := site.Params.page.sidebar.cache | default false -}}
@@ -35,9 +44,13 @@ {{- else -}} {{ end -}} @@ -59,7 +72,9 @@ {{ if or site.IsMultiLingual $displayThemeToggle }}
{{- with site.IsMultiLingual -}}