diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-07-24 23:46:23 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-07-24 23:46:23 +0200 |
| commit | 283662fb44a19c6ab7a8f14b510506edd8c02950 (patch) | |
| tree | d21090f848ef71c02875dd23bbf4532a2aa074c4 | |
| parent | 07818f368f7a6f1dec65c51e733867c1a5adabb3 (diff) | |
| download | gohugo-theme-ed-283662fb44a19c6ab7a8f14b510506edd8c02950.tar.gz | |
Allow disable hypothesis on custom pages
| -rw-r--r-- | exampleSite/content/contact.md | 1 | ||||
| -rw-r--r-- | exampleSite/content/documentation/index.md | 1 | ||||
| -rw-r--r-- | exampleSite/content/search.md | 1 | ||||
| -rw-r--r-- | exampleSite/content/thanks.md | 1 | ||||
| -rw-r--r-- | layouts/partials/hypothesis.html | 3 | ||||
| -rw-r--r-- | layouts/partials/sidebar-toc.html | 10 | ||||
| -rw-r--r-- | layouts/partials/sidebar.html | 8 | ||||
| -rw-r--r-- | package.json | 2 |
8 files changed, 21 insertions, 6 deletions
diff --git a/exampleSite/content/contact.md b/exampleSite/content/contact.md index 79b6e30..07d33a8 100644 --- a/exampleSite/content/contact.md +++ b/exampleSite/content/contact.md @@ -2,6 +2,7 @@ title: Contact description: We'd love to hear from you semanticType: contact +annotations: false --- This is an example of a custom shortcode that you can put right into your content. diff --git a/exampleSite/content/documentation/index.md b/exampleSite/content/documentation/index.md index a504bdb..7b21bc0 100644 --- a/exampleSite/content/documentation/index.md +++ b/exampleSite/content/documentation/index.md @@ -97,6 +97,7 @@ toc: true # Enable Table of Contents for specific page private: true # Hide text from search engines semanticType: about # Semantic type of the work (used for Schema.org) featuredImage: screenshot-home.png # Featured image of the text +annotations: false # Disable annotation via hypothesis on this page --- ~~~ diff --git a/exampleSite/content/search.md b/exampleSite/content/search.md index 8b7e144..e3c4ea1 100644 --- a/exampleSite/content/search.md +++ b/exampleSite/content/search.md @@ -1,5 +1,6 @@ --- title: Search +annotations: false --- {{< form-search >}} diff --git a/exampleSite/content/thanks.md b/exampleSite/content/thanks.md index 2e5b2ed..7944498 100644 --- a/exampleSite/content/thanks.md +++ b/exampleSite/content/thanks.md @@ -1,6 +1,7 @@ --- title: Thank you private: true +annotations: false --- Your message will be sent within a short time. diff --git a/layouts/partials/hypothesis.html b/layouts/partials/hypothesis.html new file mode 100644 index 0000000..1417ea3 --- /dev/null +++ b/layouts/partials/hypothesis.html @@ -0,0 +1,3 @@ +<span class="hypothesis-container"> + <a class="sidebar-nav-item" id="hypothesis-link" href="#">{{ i18n "annotate" }}</a> +</span> diff --git a/layouts/partials/sidebar-toc.html b/layouts/partials/sidebar-toc.html index 9361aab..a6ac8d3 100644 --- a/layouts/partials/sidebar-toc.html +++ b/layouts/partials/sidebar-toc.html @@ -9,10 +9,20 @@ {{ $toc := .Page.TableOfContents }} {{ $home := printf `<a class="sidebar-nav-item" href="%s">%s</a>` site.Home.RelPermalink (i18n "home") | safeHTML }} + {{ $annotation := "" }} + + {{ if ne .Params.annotations false }} + {{ $annotation = (partial "hypothesis.html" .) }} + {{ end }} {{ $toc = $toc | replaceRE `id="TableOfContents"` `class="sidebar-nav"` | safeHTML }} {{ $toc = $toc | replaceRE "(<[/]?ul>|<[/]?ol>|<[/]?li>)" "" | safeHTML }} {{ $toc = $toc | replaceRE `<a href="(.*)">(.*)</a>` `<a class="sidebar-nav-item sidebar-nav-item-toc" href="$1">$2</a>` | safeHTML }} + + {{ if ne .Params.annotations false }} + {{ $toc = $toc | replaceRE `<nav class="sidebar-nav">` (printf `<nav class="sidebar-nav">%s` $annotation) | safeHTML }} + {{ end }} + {{ $toc = $toc | replaceRE `<nav class="sidebar-nav">` (printf `<nav class="sidebar-nav">%s` $home) | safeHTML }} {{ $toc }} diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html index 7df1a2a..59d2360 100644 --- a/layouts/partials/sidebar.html +++ b/layouts/partials/sidebar.html @@ -22,11 +22,9 @@ </a> {{- end }} - <span class="hypothesis-container"> - <a class="sidebar-nav-item" id="hypothesis-link" href="#"> - {{ i18n "annotate" }} - </a> - </span> + {{- if ne .Params.annotations false }} + {{ partial "hypothesis.html" . }} + {{- end }} {{- with site.Menus.feeds }} <div class="sidebar-nav-item"> diff --git a/package.json b/package.json index bb2b556..9622ee4 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "server": "HUGO_RESOURCEDIR='../resources' HUGO_ENV=development hugo server --verbose --source=exampleSite --buildDrafts --buildFuture --ignoreCache --disableFastRender", "lint": "npm run lint:js && npm run lint:editorconfig", "lint:editorconfig": "editorconfig-checker", - "lint:js": "eslint static/js/*.js assets/js/*.js" + "lint:js": "eslint static/js/* assets/js/*" }, "dependencies": {}, "devDependencies": { |
