Skip to content

Commit

Permalink
#90, Move inline scripts to file in assets to allow overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-shpak committed Feb 4, 2020
1 parent 83f6c3d commit c0bd5b5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions assets/menu-reset.js
Original file line number Diff line number Diff line change
@@ -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");
})();
1 change: 1 addition & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions exampleSite/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 4 additions & 9 deletions layouts/partials/docs/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

0 comments on commit c0bd5b5

Please sign in to comment.