From a1d90162cbf73d0d4d6000ffc404d7d8c7a170ed Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 27 Feb 2020 13:16:08 +0100 Subject: [PATCH 1/5] move script loads to end of body --- layouts/_default/baseof.html | 1 + layouts/partials/head.html | 8 -------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index caa456d6..cecbbdb1 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -27,4 +27,5 @@ +{{ partial "foot" . }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 43b8e3fc..2d10cde3 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -9,14 +9,6 @@ -{{ if default true .Site.Params.GeekdocSearch }} - {{ .Scratch.Set "geekdocSearchConfig" .Site.Params.GeekdocSearchConfig }} - - {{ $searchJSFile := printf "js/%s.search.js" .Language.Lang }} - {{ $searchJS := resources.Get "js/search.js" | resources.ExecuteAsTemplate $searchJSFile . | resources.Minify }} - -{{ end }} - {{ with .OutputFormats.Get "rss" -}} {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} From fa3803fe00e0beacd27e800ad8827708007532d3 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 27 Feb 2020 13:16:37 +0100 Subject: [PATCH 2/5] set data attribute to copy anchor url --- layouts/partials/content.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/content.html b/layouts/partials/content.html index 1ca0cb31..73bc6fbe 100644 --- a/layouts/partials/content.html +++ b/layouts/partials/content.html @@ -3,9 +3,9 @@ {{ $.Scratch.Set "content" (.Content | replaceRE `` `` | safeHTML) }} {{ if and $showAnchor $anchorLeft }} - {{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(]*>)(.*?)()" `${1}${3}${4}` | safeHTML) }} + {{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(]*>)(.*?)()" (printf `%s%s%s` `${1}` (absURL (printf "%s#%s" .Permalink `${2}`)) `${2}` `${3}` `${4}`) | safeHTML) }} {{ else if and $showAnchor (not $anchorLeft) }} - {{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(]*>)(.*?)()" `${1}${3}${4}` | safeHTML) }} + {{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(]*>)(.*?)()" (printf `%s%s%s` `${1}` `${3}` (absURL (printf "%s#%s" .Permalink `${2}`)) `${2}` `${4}`) | safeHTML) }} {{ end }} {{ $.Scratch.Get "content" }} From d6cb3393dbb4b4d39b05a712a9a4b7718e862d19 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 27 Feb 2020 13:17:05 +0100 Subject: [PATCH 3/5] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e7c4c96..8b6efad0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,3 @@ * FEATURE * Add option to move anchor links to the left site of headlines + * add optional clipboard.js to copy anchor links on click From 5865097e571ca7a52e786200b3baa107b2ada6f6 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 27 Feb 2020 13:17:21 +0100 Subject: [PATCH 4/5] add clipboard.js --- layouts/partials/foot.html | 14 ++++++++++++++ static/js/clipboard.min.js | 7 +++++++ 2 files changed, 21 insertions(+) create mode 100644 layouts/partials/foot.html create mode 100644 static/js/clipboard.min.js diff --git a/layouts/partials/foot.html b/layouts/partials/foot.html new file mode 100644 index 00000000..cc5506bc --- /dev/null +++ b/layouts/partials/foot.html @@ -0,0 +1,14 @@ +{{ if default true .Site.Params.GeekdocSearch }} +{{ .Scratch.Set "geekdocSearchConfig" .Site.Params.GeekdocSearchConfig }} + +{{ $searchJSFile := printf "js/%s.search.js" .Language.Lang }} +{{ $searchJS := resources.Get "js/search.js" | resources.ExecuteAsTemplate $searchJSFile . | resources.Minify }} + +{{ end }} + +{{ if default true .Site.Params.GeekdocAnchorCopy }} + + +{{ end }} diff --git a/static/js/clipboard.min.js b/static/js/clipboard.min.js new file mode 100644 index 00000000..02c549e3 --- /dev/null +++ b/static/js/clipboard.min.js @@ -0,0 +1,7 @@ +/*! + * clipboard.js v2.0.4 + * https://zenorocha.github.io/clipboard.js + * + * Licensed MIT © Zeno Rocha + */ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return function(n){var o={};function r(t){if(o[t])return o[t].exports;var e=o[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,r),e.l=!0,e.exports}return r.m=n,r.c=o,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=function(){function o(t,e){for(var n=0;n Date: Thu, 27 Feb 2020 13:38:26 +0100 Subject: [PATCH 5/5] add new geekdocAnchorCopy param do docs --- 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 87cbc283..edd0fa55 100644 --- a/exampleSite/content/usage/configuration.md +++ b/exampleSite/content/usage/configuration.md @@ -55,6 +55,9 @@ # (Optional, default false) Move anchor link to the left side of headlines. geekdocAnchorLeft = false + + # (Optional, default true) Copy anchor url to clipboard on click. + geekdocAnchorCopy = true ``` {{< /tab >}} @@ -113,6 +116,9 @@ params: # (Optional, default false) Move anchor link to the left side of headlines. geekdocAnchorLeft: false + + # (Optional, default true) Copy anchor url to clipboard on click. + geekdocAnchorCopy: true ``` {{< /tab >}}