From efe54a25e59280cabf290970c271408789c12bda Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 27 Feb 2020 09:49:46 +0100 Subject: [PATCH 1/4] add some demo text --- exampleSite/content/shortcodes/toc.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/exampleSite/content/shortcodes/toc.md b/exampleSite/content/shortcodes/toc.md index 8932fe0..db7ffc4 100644 --- a/exampleSite/content/shortcodes/toc.md +++ b/exampleSite/content/shortcodes/toc.md @@ -8,10 +8,22 @@ Simple wrapper to generate a page Table of Content from a shortcode. ## Level 1 +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. + ## Level 2 +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. + ### Level 2.1 +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren. + +#### Level 2.1.1 + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. + ### Level 2.2 +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren. +no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. From f9db0acd6353cf93c5fdb5e409b174dcbf247e34 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 27 Feb 2020 09:50:11 +0100 Subject: [PATCH 2/4] add option to move anchor links in front of headlines --- layouts/partials/content.html | 7 +++++-- src/sass/_base.scss | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/layouts/partials/content.html b/layouts/partials/content.html index 6d93e3f..1ca0cb3 100644 --- a/layouts/partials/content.html +++ b/layouts/partials/content.html @@ -1,8 +1,11 @@ {{ $showAnchor := (and (default true .Page.Params.GeekdocAnchor) (default true .Site.Params.GeekdocAnchor)) }} +{{ $anchorLeft := (default false .Site.Params.GeekdocAnchorLeft) }} {{ $.Scratch.Set "content" (.Content | replaceRE `` `` | safeHTML) }} -{{ if $showAnchor }} - {{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "()" `${1}  ${3}` | safeHTML) }} +{{ if and $showAnchor $anchorLeft }} + {{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(]*>)(.*?)()" `${1}${3}${4}` | safeHTML) }} +{{ else if and $showAnchor (not $anchorLeft) }} + {{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(]*>)(.*?)()" `${1}${3}${4}` | safeHTML) }} {{ end }} {{ $.Scratch.Get "content" }} diff --git a/src/sass/_base.scss b/src/sass/_base.scss index d4d778a..1aff497 100644 --- a/src/sass/_base.scss +++ b/src/sass/_base.scss @@ -222,8 +222,19 @@ img { } } - &__anchor .icon { - color: $gray-400; + &__anchor{ + &--left { + min-width: 35px; + text-align: left; + } + + &--right { + margin-left: 0.5em; + } + + .icon { + color: $gray-400; + } } } From 1af85da831f79dca1faf1c19c0d1871c400d2044 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 27 Feb 2020 09:50:25 +0100 Subject: [PATCH 3/4] add documentation --- exampleSite/content/usage/configuration.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/exampleSite/content/usage/configuration.md b/exampleSite/content/usage/configuration.md index 53ad7d6..87cbc28 100644 --- a/exampleSite/content/usage/configuration.md +++ b/exampleSite/content/usage/configuration.md @@ -52,6 +52,9 @@ # (Optional, default true) Add an anchor link to headlines. geekdocAnchor = true + + # (Optional, default false) Move anchor link to the left side of headlines. + geekdocAnchorLeft = false ``` {{< /tab >}} @@ -107,6 +110,9 @@ params: # (Optional, default true) Add an anchor link to headlines. geekdocAnchor: true + + # (Optional, default false) Move anchor link to the left side of headlines. + geekdocAnchorLeft: false ``` {{< /tab >}} From 4ab876bd8aa5ca641a7e0dba19d1c855165bdd7b Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 27 Feb 2020 09:51:55 +0100 Subject: [PATCH 4/4] add changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08738f3..3e7c4c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,2 @@ * FEATURE - * Add anchor links for headlines + * Add option to move anchor links to the left site of headlines