diff --git a/src/_layouts/default.html b/src/_layouts/default.html index 8585a64ada..11e67d8530 100644 --- a/src/_layouts/default.html +++ b/src/_layouts/default.html @@ -55,6 +55,7 @@
@@ -78,6 +79,7 @@ + diff --git a/src/assets/js/app.js b/src/assets/js/app.js index 90c5f5243f..d766b1b35b 100644 --- a/src/assets/js/app.js +++ b/src/assets/js/app.js @@ -5,15 +5,4 @@ $(() => { // highlight.js hljs.highlightAll(); - - $("#navigation").load(`${config.rootPath}navigation.html`, function() { - $(".sidebar-sticky .icon").on("click", function (e) { - $(this).siblings("ul").toggle(); - this.classList.toggle("icon-opened"); - }); - $(`.sidebar-content a[href='${window.location.pathname}']`) - .attr("class", "active-link") - .parents('ul') - .show(); - }) }); diff --git a/src/assets/js/navigation.js b/src/assets/js/navigation.js new file mode 100644 index 0000000000..9e005037b5 --- /dev/null +++ b/src/assets/js/navigation.js @@ -0,0 +1,16 @@ +$(() => { + $("#navigation").load(`${config.rootPath}navigation.html`, () => { + // Toggle child lists + $(".sidebar-sticky .icon").on("click", function () { + this.classList.toggle("icon-opened"); + // FIXME: use vanilla JS and CSS instead of jQuery + $(this).siblings("ul").toggle(500); + }); + + // Activate current page + $(`.sidebar-content a[href='${window.location.pathname}']`) + .attr("class", "active-link") + .parents('ul') + .show(); + }) +});