From 5df0ba4b3571beef2cf4a7bcb88ef265313a4c6d Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 16 Nov 2020 22:47:50 +0100 Subject: [PATCH 1/4] 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; } From 0880c3809987eb9a5f59a83aca919fa4f74b21a7 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 16 Nov 2020 22:55:50 +0100 Subject: [PATCH 2/4] add missing title to frontmatter --- exampleSite/content/collapse/_index.md | 1 + exampleSite/content/shortcodes/_index.md | 1 + exampleSite/content/usage/_index.md | 1 + 3 files changed, 3 insertions(+) diff --git a/exampleSite/content/collapse/_index.md b/exampleSite/content/collapse/_index.md index 6df4716..db60ade 100644 --- a/exampleSite/content/collapse/_index.md +++ b/exampleSite/content/collapse/_index.md @@ -1,4 +1,5 @@ --- +title: Collapse geekdocCollapseSection: true --- diff --git a/exampleSite/content/shortcodes/_index.md b/exampleSite/content/shortcodes/_index.md index 536a762..c53e91c 100644 --- a/exampleSite/content/shortcodes/_index.md +++ b/exampleSite/content/shortcodes/_index.md @@ -1,3 +1,4 @@ --- +title: Shortcodes weight: -10 --- diff --git a/exampleSite/content/usage/_index.md b/exampleSite/content/usage/_index.md index 3307fa1..64a6d91 100644 --- a/exampleSite/content/usage/_index.md +++ b/exampleSite/content/usage/_index.md @@ -1,3 +1,4 @@ --- +title: Usage weight: -20 --- From 12fe3102a8b9005bb63dd1e92da49228e07b43c3 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 16 Nov 2020 23:06:40 +0100 Subject: [PATCH 3/4] exclude gh edit links from link validator --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index ec74f30..ab66cde 100644 --- a/.drone.yml +++ b/.drone.yml @@ -31,7 +31,7 @@ steps: - name: link-validation image: thegeeklab/link-validator commands: - - link-validator -ro + - link-validator -ro --exclude "https://github.com/thegeeklab/hugo-geekdoc/edit/master/*" environment: LINK_VALIDATOR_BASE_DIR: exampleSite/public @@ -242,6 +242,6 @@ depends_on: --- kind: signature -hmac: 9ffa1706ed0a3368bafa619e2fe5dd07db1813c9c8f9e7b54a3f4e722393ffce +hmac: c9b760d5d37c992b0caba32b3a4cf1933174c63453f263b96abec8387d340dd7 ... From 31e5a32c3418e18bc56b940b787e25a8841210f6 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 16 Nov 2020 23:13:12 +0100 Subject: [PATCH 4/4] fix typo --- exampleSite/content/collapse/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exampleSite/content/collapse/_index.md b/exampleSite/content/collapse/_index.md index db60ade..925425d 100644 --- a/exampleSite/content/collapse/_index.md +++ b/exampleSite/content/collapse/_index.md @@ -3,4 +3,4 @@ title: Collapse geekdocCollapseSection: true --- -Demo foldable menu entries +Demo collapsible menu entries.