#90, Move inline scripts to file in assets to allow overwrite

This commit is contained in:
Alex Shpak 2020-02-04 22:24:36 +01:00
parent 83f6c3d475
commit c0bd5b5bb8
5 changed files with 14 additions and 9 deletions

View File

@ -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

7
assets/menu-reset.js Normal file
View File

@ -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");
})();

View File

@ -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

View File

@ -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

View File

@ -13,12 +13,7 @@
</nav>
<!-- Restore menu position as soon as possible to avoid flickering -->
<script>
(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");
})();
</script>
{{ $script := resources.Get "menu-reset.js" | resources.Minify }}
{{ with $script.Content }}
<script>{{ . | safeJS }}</script>
{{ end }}