mirror of
https://github.com/thegeeklab/hugo-geekdoc.git
synced 2024-11-21 20:30:39 +00:00
commit
e081e04981
@ -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
|
||||
|
@ -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 >}}
|
||||
|
@ -27,4 +27,5 @@
|
||||
</div>
|
||||
</body>
|
||||
|
||||
{{ partial "foot" . }}
|
||||
</html>
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
{{ $.Scratch.Set "content" (.Content | replaceRE `<nav id="TableOfContents">\s*<ul>\s*<li>\s*<ul>` `<nav id="TableOfContents"><ul>` | replaceRE `</ul>\s*</li>\s*</ul>\s*</nav>` `</ul></nav>` | safeHTML) }}
|
||||
{{ if and $showAnchor $anchorLeft }}
|
||||
{{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(<h[2-9] id=\"([^\"]+)\"[^>]*>)(.*?)(</h[2-9]+>)" `${1}<a class="gdoc-page__anchor gdoc-page__anchor--left" href="#${2}"><svg class="icon link"><use xlink:href="#link"></use></svg></a>${3}${4}` | safeHTML) }}
|
||||
{{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(<h[2-9] id=\"([^\"]+)\"[^>]*>)(.*?)(</h[2-9]+>)" (printf `%s<a data-clipboard-text="%s" class="gdoc-page__anchor gdoc-page__anchor--left clip" href="#%s"><svg class="icon link"><use xlink:href="#link"></use></svg></a>%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 "(<h[2-9] id=\"([^\"]+)\"[^>]*>)(.*?)(</h[2-9]+>)" `${1}${3}<a class="gdoc-page__anchor gdoc-page__anchor--right" href="#${2}"><svg class="icon link"><use xlink:href="#link"></use></svg></a>${4}` | safeHTML) }}
|
||||
{{ $.Scratch.Set "content" ($.Scratch.Get "content" | replaceRE "(<h[2-9] id=\"([^\"]+)\"[^>]*>)(.*?)(</h[2-9]+>)" (printf `%s%s<a data-clipboard-text="%s" class="gdoc-page__anchor gdoc-page__anchor--right clip" href="#%s"><svg class="icon link"><use xlink:href="#link"></use></svg></a>%s` `${1}` `${3}` (absURL (printf "%s#%s" .Permalink `${2}`)) `${2}` `${4}`) | safeHTML) }}
|
||||
{{ end }}
|
||||
|
||||
{{ $.Scratch.Get "content" }}
|
||||
|
14
layouts/partials/foot.html
Normal file
14
layouts/partials/foot.html
Normal file
@ -0,0 +1,14 @@
|
||||
{{ if default true .Site.Params.GeekdocSearch }}
|
||||
{{ .Scratch.Set "geekdocSearchConfig" .Site.Params.GeekdocSearchConfig }}
|
||||
<!-- Remove after https://github.com/gohugoio/hugo/issues/6331 -->
|
||||
{{ $searchJSFile := printf "js/%s.search.js" .Language.Lang }}
|
||||
{{ $searchJS := resources.Get "js/search.js" | resources.ExecuteAsTemplate $searchJSFile . | resources.Minify }}
|
||||
<script defer src="{{ $searchJS.RelPermalink }}"></script>
|
||||
{{ end }}
|
||||
|
||||
{{ if default true .Site.Params.GeekdocAnchorCopy }}
|
||||
<script src="{{ "js/clipboard.min.js" | relURL }}"></script>
|
||||
<script>
|
||||
var clipboard = new ClipboardJS('.clip');
|
||||
</script>
|
||||
{{ end }}
|
@ -9,14 +9,6 @@
|
||||
<!-- Theme stylesheet, you can customize css by creating static/custom.css` in your website -->
|
||||
<link rel="stylesheet" href="{{ "custom.css" | relURL }}">
|
||||
|
||||
{{ if default true .Site.Params.GeekdocSearch }}
|
||||
{{ .Scratch.Set "geekdocSearchConfig" .Site.Params.GeekdocSearchConfig }}
|
||||
<!-- Remove after https://github.com/gohugoio/hugo/issues/6331 -->
|
||||
{{ $searchJSFile := printf "js/%s.search.js" .Language.Lang }}
|
||||
{{ $searchJS := resources.Get "js/search.js" | resources.ExecuteAsTemplate $searchJSFile . | resources.Minify }}
|
||||
<script defer src="{{ $searchJS.RelPermalink }}"></script>
|
||||
{{ end }}
|
||||
|
||||
<!-- RSS -->
|
||||
{{ with .OutputFormats.Get "rss" -}}
|
||||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
|
||||
|
7
static/js/clipboard.min.js
vendored
Normal file
7
static/js/clipboard.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user