From 5df0ba4b3571beef2cf4a7bcb88ef265313a4c6d Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 16 Nov 2020 22:47:50 +0100 Subject: [PATCH] add new page parameter GeekdocCollapseSection --- exampleSite/content/collapse/_index.md | 5 +++ .../content/collapse/level-1/_index.md | 7 ++++ .../content/collapse/level-1/level-1-1.md | 5 +++ .../content/collapse/level-1/level-1-2.md | 5 +++ .../content/collapse/level-2/_index.md | 5 +++ .../content/collapse/level-2/level-2-1.md | 5 +++ .../content/collapse/level-2/level-2-2.md | 5 +++ exampleSite/content/shortcodes/_index.md | 3 ++ exampleSite/content/usage/_index.md | 3 +- exampleSite/content/usage/configuration.md | 6 +++ layouts/partials/menu-filetree.html | 19 +++++++++- src/sass/_base.scss | 38 ++++++++++++++++++- 12 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 exampleSite/content/collapse/_index.md create mode 100644 exampleSite/content/collapse/level-1/_index.md create mode 100644 exampleSite/content/collapse/level-1/level-1-1.md create mode 100644 exampleSite/content/collapse/level-1/level-1-2.md create mode 100644 exampleSite/content/collapse/level-2/_index.md create mode 100644 exampleSite/content/collapse/level-2/level-2-1.md create mode 100644 exampleSite/content/collapse/level-2/level-2-2.md create mode 100644 exampleSite/content/shortcodes/_index.md diff --git a/exampleSite/content/collapse/_index.md b/exampleSite/content/collapse/_index.md new file mode 100644 index 0000000..6df4716 --- /dev/null +++ b/exampleSite/content/collapse/_index.md @@ -0,0 +1,5 @@ +--- +geekdocCollapseSection: true +--- + +Demo foldable menu entries diff --git a/exampleSite/content/collapse/level-1/_index.md b/exampleSite/content/collapse/level-1/_index.md new file mode 100644 index 0000000..acab06a --- /dev/null +++ b/exampleSite/content/collapse/level-1/_index.md @@ -0,0 +1,7 @@ +Level 1 + + + +{{< toc-tree >}} + + diff --git a/exampleSite/content/collapse/level-1/level-1-1.md b/exampleSite/content/collapse/level-1/level-1-1.md new file mode 100644 index 0000000..bf6896c --- /dev/null +++ b/exampleSite/content/collapse/level-1/level-1-1.md @@ -0,0 +1,5 @@ +--- +title: Level 1.1 +--- + +Level 1.1 diff --git a/exampleSite/content/collapse/level-1/level-1-2.md b/exampleSite/content/collapse/level-1/level-1-2.md new file mode 100644 index 0000000..317b0fe --- /dev/null +++ b/exampleSite/content/collapse/level-1/level-1-2.md @@ -0,0 +1,5 @@ +--- +title: Level 1.2 +--- + +Level 1.2 diff --git a/exampleSite/content/collapse/level-2/_index.md b/exampleSite/content/collapse/level-2/_index.md new file mode 100644 index 0000000..1671355 --- /dev/null +++ b/exampleSite/content/collapse/level-2/_index.md @@ -0,0 +1,5 @@ +--- +geekdocCollapseSection: true +--- + +Level-2 diff --git a/exampleSite/content/collapse/level-2/level-2-1.md b/exampleSite/content/collapse/level-2/level-2-1.md new file mode 100644 index 0000000..3b29aab --- /dev/null +++ b/exampleSite/content/collapse/level-2/level-2-1.md @@ -0,0 +1,5 @@ +--- +title: Level 2.1 +--- + +Level 2.1 diff --git a/exampleSite/content/collapse/level-2/level-2-2.md b/exampleSite/content/collapse/level-2/level-2-2.md new file mode 100644 index 0000000..ca0a397 --- /dev/null +++ b/exampleSite/content/collapse/level-2/level-2-2.md @@ -0,0 +1,5 @@ +--- +title: Level 2.2 +--- + +Level 2.2 diff --git a/exampleSite/content/shortcodes/_index.md b/exampleSite/content/shortcodes/_index.md new file mode 100644 index 0000000..536a762 --- /dev/null +++ b/exampleSite/content/shortcodes/_index.md @@ -0,0 +1,3 @@ +--- +weight: -10 +--- diff --git a/exampleSite/content/usage/_index.md b/exampleSite/content/usage/_index.md index eab4aee..3307fa1 100644 --- a/exampleSite/content/usage/_index.md +++ b/exampleSite/content/usage/_index.md @@ -1,4 +1,3 @@ --- -title: Usage -weight: -10 +weight: -20 --- diff --git a/exampleSite/content/usage/configuration.md b/exampleSite/content/usage/configuration.md index 8cf9418..0d2386d 100644 --- a/exampleSite/content/usage/configuration.md +++ b/exampleSite/content/usage/configuration.md @@ -207,6 +207,9 @@ geekdocHidden = true # NOTE: Only applies when 'geekdocHidden = true'. geekdocHiddenTocTree = true +# Set to true to make a section foldable in side menu (file-tree menu only) +geekdocCollapseSection = true + # Add an anchor link to headlines geekdocAnchor = true ``` @@ -251,6 +254,9 @@ geekdocHidden: true # NOTE: Only applies when 'geekdocHidden: true'. geekdocHiddenTocTree: true +# Set to true to make a section foldable in side menu (file-tree menu only) +geekdocCollapseSection: true + # Add an anchor link to headlines geekdocAnchor: true ``` diff --git a/layouts/partials/menu-filetree.html b/layouts/partials/menu-filetree.html index 2ccfd06..10ec7ae 100644 --- a/layouts/partials/menu-filetree.html +++ b/layouts/partials/menu-filetree.html @@ -9,7 +9,18 @@ {{ range .sect.GroupBy "Weight" }} {{ range .ByTitle }} {{ if not .Params.GeekdocHidden }} + + {{ $numberOfPages := (add (len .Pages) (len .Sections)) }} + {{ $isParent := and (ne $numberOfPages 0) (not .Params.GeekdocFlatSection) }} + {{ $isCurrent := eq $current . }} + {{ $isAncestor := .IsAncestor $current }} + {{ $id := substr (sha1 .Permalink) 0 8 }} +
  • + {{ if and $isParent .Params.GeekdocCollapseSection }} + + + {{ end }} - {{ $numberOfPages := (add (len .Pages) (len .Sections)) }} - {{ if and (ne $numberOfPages 0) (not .Params.GeekdocFlatSection) }} + {{ if $isParent }} {{ template "tree-nav" dict "sect" .Pages "current" $current}} {{ end }}
  • diff --git a/src/sass/_base.scss b/src/sass/_base.scss index 5ab6b31..f50e252 100644 --- a/src/sass/_base.scss +++ b/src/sass/_base.scss @@ -155,6 +155,7 @@ img { margin: 0; padding: 0; list-style: none; + user-select: none; ul { padding-left: $padding-16; @@ -169,6 +170,39 @@ img { } } + &__toggle { + display: none; + + & ~ label { + cursor: pointer; + + .icon { + font-size: 0.7rem; + } + } + + &:not(:checked) { + & ~ ul, + & ~ label .icon.keyborad_arrow_down { + display: none; + } + & ~ label .icon.keyborad_arrow_left { + display: block; + } + } + + &:checked { + & ~ ul, + & ~ label .icon.keyborad_arrow_down { + display: block; + } + + & ~ label .icon.keyborad_arrow_left { + display: none; + } + } + } + &__entry { flex: 1; color: $body-font-color; @@ -185,7 +219,9 @@ img { } &--main > ul > li > span, - &--main > ul > li > span > a { + &--main > ul > li > span > a, + &--main > ul > li > label, + &--main > ul > li > label > a { font-weight: bold; }