Skip to content

Commit 3bc454b

Browse files
KStockyimfing
andauthored
feat: support hiding the main sidebar in desktop site (#778)
* feat: Remove the main sidebar entirely to free up more space for the main content of the page * fix: ensure that the footer switches are still visible when the main sidebar has been disabled * refactor: Repurpose Params.sidebar.hide to disable the main sidebar and disable the placeholder rather than adding a new front matter parameter * fix: change wording from "disable" to "hide" in the documentation for hiding the sidebar * fix: using incorrect hidden class in sidebar.html broke mobile navigation. Fixed this --------- Co-authored-by: Xin <[email protected]>
1 parent 1b536e2 commit 3bc454b

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

docs/content/docs/guide/configuration.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,21 @@ menu:
164164
weight: 3
165165
```
166166

167+
### Hiding
168+
169+
Hiding the sidebar can be done using front matter:
170+
171+
```yaml {filename="content/docs/guide/configuration.md"}
172+
---
173+
title: Configuration
174+
sidebar:
175+
hide: true
176+
---
177+
```
178+
179+
This will hide the main sidebar from the page, freeing up space for the main content of the page.
180+
181+
167182
## Right Sidebar
168183

169184
### Table of Contents

layouts/_partials/sidebar.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
{{- $disableSidebar := .disableSidebar | default false -}}
44
{{- $displayPlaceholder := .displayPlaceholder | default false -}}
55

6-
{{- $sidebarClass := cond $disableSidebar (cond $displayPlaceholder "hx:md:hidden hx:xl:block" "hx:md:hidden") "hx:md:sticky" -}}
7-
86
{{- $navRoot := cond (eq site.Home.Type "docs") site.Home $context.FirstSection -}}
97
{{- $pageURL := $context.RelPermalink -}}
108

11-
{{/* EXPERIMENTAL */}}
129
{{- if .context.Params.sidebar.hide -}}
1310
{{- $disableSidebar = true -}}
14-
{{- $displayPlaceholder = true -}}
11+
{{- $displayPlaceholder = false -}}
1512
{{- end -}}
1613

14+
{{- $sidebarClass := "hx:md:sticky" -}}
15+
{{- if $disableSidebar -}}
16+
{{- if $displayPlaceholder -}}
17+
{{- $sidebarClass = "hx:md:hidden hx:xl:block" -}}
18+
{{- else -}}
19+
{{- $sidebarClass = "hx:md:hidden" -}}
20+
{{- end -}}
21+
{{- end -}}
1722

1823
<aside class="hextra-sidebar-container hx:flex hx:flex-col hx:print:hidden hx:md:top-16 hx:md:shrink-0 hx:md:w-64 hx:md:self-start hx:max-md:[transform:translate3d(0,-100%,0)] {{ $sidebarClass }}">
1924
<!-- Search bar on small screen -->

0 commit comments

Comments
 (0)