From bc7c46da67fb34752bfb9a999b264ba3ec90f66e Mon Sep 17 00:00:00 2001 From: Xin Date: Sat, 11 Nov 2023 00:35:45 +0000 Subject: [PATCH 1/2] feat: support adding pages as separator for sidebar --- layouts/partials/sidebar.html | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html index a47cc403..f98a4a33 100644 --- a/layouts/partials/sidebar.html +++ b/layouts/partials/sidebar.html @@ -70,15 +70,21 @@ {{- with $items := union .context.RegularPages .context.Sections -}} {{- if eq $level 0 -}} {{- range $items.ByWeight }} - {{- $active := eq $pageURL .RelPermalink -}} - {{- $shouldOpen := or (.Params.sidebar.open) (.IsAncestor $page) $active | default true }} -
  • - {{- template "sidebar-item-link" dict "context" . "active" $active "title" .LinkTitle "link" .RelPermalink -}} - {{- if and $toc $active -}} - {{- template "sidebar-toc" dict "page" . -}} - {{- end -}} - {{- template "sidebar-tree" dict "context" . "page" $page "pageURL" $pageURL "level" (add $level 1) "toc" $toc -}} -
  • + {{- if .Params.sidebar.separator -}} +
  • + {{ .LinkTitle }} +
  • + {{- else -}} + {{- $active := eq $pageURL .RelPermalink -}} + {{- $shouldOpen := or (.Params.sidebar.open) (.IsAncestor $page) $active | default true }} +
  • + {{- template "sidebar-item-link" dict "context" . "active" $active "title" .LinkTitle "link" .RelPermalink -}} + {{- if and $toc $active -}} + {{- template "sidebar-toc" dict "page" . -}} + {{- end -}} + {{- template "sidebar-tree" dict "context" . "page" $page "pageURL" $pageURL "level" (add $level 1) "toc" $toc -}} +
  • + {{- end -}} {{- end -}} {{- else -}}
    @@ -160,10 +166,6 @@ {{- end -}} -{{- define "sidebar-separator" -}} -
    -{{- end -}} - {{- define "sidebear-collapsible-button" -}} {{- end -}} From 8d193964abdd4f64a46ac4555ae2ea2d57579f19 Mon Sep 17 00:00:00 2001 From: Xin Date: Sun, 12 Nov 2023 13:56:23 +0000 Subject: [PATCH 2/2] Update sidebar.html --- layouts/partials/sidebar.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html index 6149000c..bdd279bd 100644 --- a/layouts/partials/sidebar.html +++ b/layouts/partials/sidebar.html @@ -166,6 +166,6 @@ {{- end -}} -{{- define "sidebear-collapsible-button" -}} +{{- define "sidebar-collapsible-button" -}} {{- end -}}