From d58a8b5469983fd233e40c6c3934021b092591d0 Mon Sep 17 00:00:00 2001 From: Xin Date: Fri, 17 Nov 2023 18:00:05 -0500 Subject: [PATCH] feat: exclude page from sidebar (#209) * feat: allow excluding page from sidebar * chore: tidy up * docs: add instruction for excluding a page from sidebar * feat: allow hiding sidebar for pages * chore: add comment --- exampleSite/content/docs/guide/configuration.md | 10 ++++++++++ layouts/partials/sidebar.html | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/exampleSite/content/docs/guide/configuration.md b/exampleSite/content/docs/guide/configuration.md index 25e70009..f4ddd67d 100644 --- a/exampleSite/content/docs/guide/configuration.md +++ b/exampleSite/content/docs/guide/configuration.md @@ -90,6 +90,16 @@ params: For the main sidebar, it is automatically generated from the structure of the content directory. See the [Organize Files](/docs/guide/organize-files) page for more details. +To exclude a single page from the left sidebar, set the `sidebar.exclude` parameter in the front matter of the page: + +```yaml {filename="content/docs/guide/configuration.md"} +--- +title: Configuration +sidebar: + exclude: true +--- +``` + ### Extra Links Sidebar extra links are defined under the `menu.sidebar` section in the config file: diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html index bdd279bd..efc85260 100644 --- a/layouts/partials/sidebar.html +++ b/layouts/partials/sidebar.html @@ -6,9 +6,14 @@ {{- $sidebarClass := cond $disableSidebar (cond $displayPlaceholder "md:hidden xl:block" "md:hidden") "md:sticky" -}} {{- $navRoot := cond (eq site.Home.Type "docs") site.Home $context.FirstSection -}} -{{- $navPages := union $navRoot.RegularPages $navRoot.Sections -}} {{- $pageURL := $context.RelPermalink -}} +{{/* EXPERIMENTAL */}} +{{- if .context.Params.sidebar.hide -}} + {{- $disableSidebar = true -}} + {{- $displayPlaceholder = true -}} +{{- end -}} +