From c0bd5b5bb899343ef8b18cceec1982ab8980b236 Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Tue, 4 Feb 2020 22:24:36 +0100 Subject: #90, Move inline scripts to file in assets to allow overwrite --- README.md | 1 + assets/menu-reset.js | 7 +++++++ exampleSite/config.toml | 1 + exampleSite/config.yaml | 1 + layouts/partials/docs/menu.html | 13 ++++--------- 5 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 assets/menu-reset.js diff --git a/README.md b/README.md index 1fa1ce8..6ba9670 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,7 @@ disableKinds = ['taxonomy', 'taxonomyTerm'] # (Optional, default true) Enables search function with flexsearch, # Index is built on fly, therefore it might slowdown your website. + # Configuration for indexing can be adjusted in i18n folder per language. BookSearch = true # (Optional, default true) Enables comments template on pages diff --git a/assets/menu-reset.js b/assets/menu-reset.js new file mode 100644 index 0000000..f3b90c5 --- /dev/null +++ b/assets/menu-reset.js @@ -0,0 +1,7 @@ +(function() { + var menu = document.querySelector("aside.book-menu nav"); + addEventListener("beforeunload", function(event) { + localStorage.setItem("menu.scrollTop", menu.scrollTop); + }); + menu.scrollTop = localStorage.getItem("menu.scrollTop"); +})(); diff --git a/exampleSite/config.toml b/exampleSite/config.toml index da06bec..7fe97ac 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -70,6 +70,7 @@ enableGitInfo = true # (Optional, default true) Enables search function with flexsearch, # Index is built on fly, therefore it might slowdown your website. + # Configuration for indexing can be adjusted in i18n folder per language. BookSearch = true # (Optional, default true) Enables comments template on pages diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 0e56f53..889f96b 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -68,6 +68,7 @@ params: # (Optional, default true) Enables search function with flexsearch, # Index is built on fly, therefore it might slowdown your website. + # Configuration for indexing can be adjusted in i18n folder per language. BookSearch: true # (Optional, default true) Enables comments template on pages diff --git a/layouts/partials/docs/menu.html b/layouts/partials/docs/menu.html index 0db676f..a0d3c45 100644 --- a/layouts/partials/docs/menu.html +++ b/layouts/partials/docs/menu.html @@ -13,12 +13,7 @@ - +{{ $script := resources.Get "menu-reset.js" | resources.Minify }} +{{ with $script.Content }} + +{{ end }} -- cgit v1.2.3