From 14567a6df4a3265bf54fb8b4a2aad52c69a38397 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 26 Feb 2020 23:59:30 +0100 Subject: [PATCH] add anchor links for headlines --- CHANGELOG.md | 4 ++-- layouts/_default/list.html | 2 +- layouts/_default/single.html | 2 +- layouts/partials/content.html | 8 ++++++++ layouts/partials/svg-icon-symbols.html | 2 +- layouts/posts/single.html | 2 +- src/icons/link.svg | 4 ++++ src/sass/_base.scss | 10 +++++++++- src/sass/_shortcodes.scss | 4 ++++ 9 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 layouts/partials/content.html create mode 100644 src/icons/link.svg diff --git a/CHANGELOG.md b/CHANGELOG.md index 862a1a4..08738f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,2 @@ -* BUGFIX - * remove mobile menu button on error page +* FEATURE + * Add anchor links for headlines diff --git a/layouts/_default/list.html b/layouts/_default/list.html index c50900e..a9c05e6 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -2,6 +2,6 @@ {{ partial "page-header" . }}

{{ partial "title" . }}

- {{ .Content }} + {{ partial "content" . }}
{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 725e4a3..33d452c 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -3,6 +3,6 @@

{{ partial "title" . }}

- {{ .Content | replaceRE `` `` | safeHTML }} + {{ partial "content" . }}
{{ end }} diff --git a/layouts/partials/content.html b/layouts/partials/content.html new file mode 100644 index 0000000..587552d --- /dev/null +++ b/layouts/partials/content.html @@ -0,0 +1,8 @@ +{{ $showAnchor := (and (default true .Page.Params.geekdocAnchor) (default true .Site.Params.geekdocAnchor)) }} + +{{ $.Scratch.Set "content" (.Content | replaceRE `` `` | safeHTML) }} +{{ if $showAnchor }} + {{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "()" `${1}  ${3}` | safeHTML) }} +{{ end }} + +{{ $.Scratch.Get "content" }} diff --git a/layouts/partials/svg-icon-symbols.html b/layouts/partials/svg-icon-symbols.html index b202713..3ed75df 100644 --- a/layouts/partials/svg-icon-symbols.html +++ b/layouts/partials/svg-icon-symbols.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/layouts/posts/single.html b/layouts/posts/single.html index e73f5e8..e4e390e 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -5,6 +5,6 @@
{{ .Date.Format $dateFormat }}
- {{ .Content }} + {{ partial "content" . }} {{ end }} diff --git a/src/icons/link.svg b/src/icons/link.svg new file mode 100644 index 0000000..7be47ee --- /dev/null +++ b/src/icons/link.svg @@ -0,0 +1,4 @@ + + +link + diff --git a/src/sass/_base.scss b/src/sass/_base.scss index c5b15ce..d4d778a 100644 --- a/src/sass/_base.scss +++ b/src/sass/_base.scss @@ -30,8 +30,12 @@ h1, h2, h3, h4, -h5 { +h5, +h6 { font-weight: $body-font-weight; + display: flex; + align-items: center; + text-align: center; } a { @@ -217,6 +221,10 @@ img { content: "\1f82a"; } } + + &__anchor .icon { + color: $gray-400; + } } .gdoc-post { diff --git a/src/sass/_shortcodes.scss b/src/sass/_shortcodes.scss index a97566b..1d7b821 100644 --- a/src/sass/_shortcodes.scss +++ b/src/sass/_shortcodes.scss @@ -70,6 +70,10 @@ min-width: $body-min-width * 0.66; padding: 0 $padding-16; } + + .gdoc-page__anchor { + display: none; + } } // {{< button >}}