From cd0cfe37ae42539a0a5f59f7d50be0ec69476643 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 18 May 2021 23:10:42 +0200 Subject: [PATCH] feat: add page parameter geekdocNav to disable navigation sidebar (#129) --- .dictionary | 2 + assets/js/search.js | 6 ++- exampleSite/content/_index.md | 48 +++++++++++++++++++--- exampleSite/content/shortcodes/buttons.md | 4 -- exampleSite/content/usage/configuration.md | 8 ++++ layouts/_default/baseof.html | 7 +++- 6 files changed, 61 insertions(+), 14 deletions(-) diff --git a/.dictionary b/.dictionary index 971906c..c0b0826 100644 --- a/.dictionary +++ b/.dictionary @@ -22,3 +22,5 @@ prebuilt (S|s)ubdirector(ies|y) (M|m)inify whitespace +relref +href diff --git a/assets/js/search.js b/assets/js/search.js index 0ebccda..037bf9b 100644 --- a/assets/js/search.js +++ b/assets/js/search.js @@ -8,8 +8,10 @@ const results = document.querySelector('#gdoc-search-results'); let showParent = {{ if .Site.Params.GeekdocSearchShowParent }}true{{ else }}false{{ end }} - input.addEventListener('focus', init); - input.addEventListener('keyup', search); + if (input) { + input.addEventListener('focus', init); + input.addEventListener('keyup', search); + } function init() { input.removeEventListener('focus', init); // init once diff --git a/exampleSite/content/_index.md b/exampleSite/content/_index.md index fbf9f3c..0184754 100644 --- a/exampleSite/content/_index.md +++ b/exampleSite/content/_index.md @@ -1,6 +1,7 @@ --- title: Documentation description: Geekdoc is a simple Hugo theme for documentations. It is intentionally designed as a fast and lean theme and may not fit the requirements of complex projects. If a more feature-complete theme is required there are a lot of got alternatives out there. +geekdocNav: false --- @@ -16,11 +17,46 @@ description: Geekdoc is a simple Hugo theme for documentations. It is intentiona Geekdoc is a simple Hugo theme for documentations. It is intentionally designed as a fast and lean theme and may not fit the requirements of complex projects. If a more feature-complete theme is required there are a lot of got alternatives out there. +{{< button relref="usage/getting-started/" >}}Explore Documentation{{< /button >}} + ## Features -- Clean and simple design -- Light and mobile-friendly -- Easy customization -- Zero initial configuration -- Handy shortcodes -- Dark mode +{{< columns >}} + +### Clean and simple design + +Stay focused on exploring the content and don't get overwhelmed by a complex design. + +<---> + +### Light and mobile-friendly + +The theme is powered by less than 1 MB and looks impressive on mobile devices as well as on a regular Desktop. + +<---> + +### Easy customization + +The look and feel can be easily customized by CSS custom properties (variables), features can be adjusted by Hugo parameters. + +{{< /columns >}} + +{{< columns >}} + +### Zero initial configuration + +Getting started in minutes. The theme is shipped with a default configuration and works out of the box. + +<---> + +### Handy shortcodes + +We included some (hopefully) useful custom shortcodes so you don't have to and can focus on writing amazing docs. + +<---> + +### Dark mode + +Powerful dark mode that detects your system preferences or can be controlled by a toggle switch. + +{{< /columns >}} diff --git a/exampleSite/content/shortcodes/buttons.md b/exampleSite/content/shortcodes/buttons.md index 47f5b0a..655eb55 100644 --- a/exampleSite/content/shortcodes/buttons.md +++ b/exampleSite/content/shortcodes/buttons.md @@ -7,9 +7,5 @@ Buttons are styled links that can lead to local page or external link. ## Example - - {{< button relref="/" >}}Get Home{{< /button >}} {{< button href="https://github.com/thegeeklab/hugo-geekdoc" >}}Contribute{{< /button >}} - - diff --git a/exampleSite/content/usage/configuration.md b/exampleSite/content/usage/configuration.md index 2264703..36350e6 100644 --- a/exampleSite/content/usage/configuration.md +++ b/exampleSite/content/usage/configuration.md @@ -209,6 +209,10 @@ geekdocToC = 3 # Set a description for the current page. This will be shown in toc-trees objects. geekdocDescription = +# Set false to hide the whole left navigation sidebar. Beware that it will make +# navigation pretty hard without adding some kind of on-page navigation. +geekdocNav = true + # Show a breadcrumb navigation bar at the top of each docs page. geekdocBreadcrumb = false @@ -262,6 +266,10 @@ geekdocToC: 3 # Set a description for the current page. This will be shown in toc-trees objects. geekdocDescription: +# Set false to hide the whole left navigation sidebar. Beware that it will make +# navigation pretty hard without adding some kind of on-page navigation. +geekdocNav: true + # Show a breadcrumb navigation bar at the top of each docs page. geekdocBreadcrumb: false diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index d700646..a5a9f8f 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -12,14 +12,17 @@ {{ partial "svg-icon-symbols" . }} -
+
- {{ partial "site-header" (dict "Root" . "MenuEnabled" true) }} + {{ $navEnabled := default true .Page.Params.GeekdocNav }} + {{ partial "site-header" (dict "Root" . "MenuEnabled" $navEnabled) }}
+ {{ if $navEnabled }} + {{ end }}
{{ template "main" . }}