summaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
authornanxiaobei <nanxiaobei@gmail.com>2019-06-10 06:44:46 +0800
committernanxiaobei <nanxiaobei@gmail.com>2019-06-10 06:44:46 +0800
commitdaef16b004177d055f9f1cef111b628b4a8edc84 (patch)
treec0a2e8efa89d988ab9acd30ffb6e9072c281d500 /layouts
parent67767c62c241c20f563801f1d49979645d61ef8b (diff)
Change `.Site.BaseURL` to `absURL`, refine js code
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/footer.html28
1 files changed, 15 insertions, 13 deletions
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 1db984a..05f67d7 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -6,27 +6,29 @@
<span>&middot;</span>
<span>Theme️ <a href="https://github.com/nanxiaobei/hugo-paper" rel="noopener" target="_blank">Paper</a></span>
</footer>
-<script src="{{.Site.BaseURL}}js/instantclick.min.js" data-no-instant></script>
+<script src="{{ "js/instantclick.min.js" | absURL }}" data-no-instant></script>
<script data-no-instant>InstantClick.init();</script>
-<script src="{{.Site.BaseURL}}js/highlight.min.js" data-no-instant></script>
+<script src="{{ "js/highlight.min.js" | absURL }}" data-no-instant></script>
<script data-no-instant>
+ let body;
+ function menuToggleListener() {
+ body.classList.toggle('no-scroll');
+ }
+ function setMenuToggleListener() {
+ const menuToggle = document.querySelector('.menu-toggle');
+ body = document.querySelector('body');
+ menuToggle.addEventListener('click', menuToggleListener);
+ }
+
hljs.initHighlightingOnLoad();
- setMenuListener();
+ setMenuToggleListener();
- InstantClick.on('change', function() {
+ InstantClick.on('change', function () {
document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightBlock(block);
});
- setMenuListener();
+ setMenuToggleListener();
});
-
- function setMenuListener() {
- var menuToggle = document.querySelector('.menu-toggle');
- var body = document.querySelector('body');
- menuToggle.addEventListener('click', function() {
- body.classList.toggle('no-scroll');
- }, false);
- }
</script>
</body>
</html>