diff --git a/assets/js/app.js b/assets/js/app.js index 069b8c2..e69de29 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,14 +0,0 @@ -// Adds scroll position lock for default docs sidebar - -if (document.querySelector('#sidebar-default') !== null) { - let sidebar = document.getElementById('sidebar-default'); - - let pos = sessionStorage.getItem('sidebar-scroll'); - if (pos !== null) { - sidebar.scrollTop = parseInt(pos, 10); - } - - window.addEventListener('beforeunload', () => { - sessionStorage.setItem('sidebar-scroll', sidebar.scrollTop); - }); -} diff --git a/assets/js/scroll-lock.js b/assets/js/scroll-lock.js new file mode 100644 index 0000000..069b8c2 --- /dev/null +++ b/assets/js/scroll-lock.js @@ -0,0 +1,14 @@ +// Adds scroll position lock for default docs sidebar + +if (document.querySelector('#sidebar-default') !== null) { + let sidebar = document.getElementById('sidebar-default'); + + let pos = sessionStorage.getItem('sidebar-scroll'); + if (pos !== null) { + sidebar.scrollTop = parseInt(pos, 10); + } + + window.addEventListener('beforeunload', () => { + sessionStorage.setItem('sidebar-scroll', sidebar.scrollTop); + }); +} diff --git a/layouts/partials/footer/script-footer.html b/layouts/partials/footer/script-footer.html index 9e4104e..c3be2f2 100644 --- a/layouts/partials/footer/script-footer.html +++ b/layouts/partials/footer/script-footer.html @@ -57,6 +57,9 @@ {{ $slice = $slice | append $katexConfig -}} {{ end -}} +{{ $scrollLock := resources.Get "js/scroll-lock.js" | js.Build -}} +{{ $slice = $slice | append $scrollLock -}} + {{ $js := $slice | resources.Concat "main.js" -}} {{ if eq (hugo.Environment) "development" -}}