Skip to content

Commit 00a0aa6

Browse files
committed
Create navigation.js
1 parent 8af573d commit 00a0aa6

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

src/_layouts/default.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/4.3.0/anchor.min.js"></script>
7979
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/highlight.min.js"></script>
8080
<script src="/assets/js/app.js"></script>
81+
<script src="/assets/js/navigation.js"></script>
8182
<script src="/assets/js/search.js"></script>
8283
</body>
8384
</html>

src/assets/js/app.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,4 @@ $(() => {
55

66
// highlight.js
77
hljs.highlightAll();
8-
9-
$("#navigation").load(`${config.rootPath}navigation.html`, () => {
10-
// Toggle child lists
11-
$(".sidebar-sticky .icon").on("click", function () {
12-
// FIXME: use vanilla JS and CSS instead of jQuery
13-
$(this).siblings("ul").toggle(500);
14-
this.classList.toggle("icon-opened");
15-
});
16-
17-
// Activate current page
18-
$(`.sidebar-content a[href='${window.location.pathname}']`)
19-
.attr("class", "active-link")
20-
.parents('ul')
21-
.show();
22-
})
238
});

src/assets/js/navigation.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
$(() => {
2+
$("#navigation").load(`${config.rootPath}navigation.html`, () => {
3+
// Toggle child lists
4+
$(".sidebar-sticky .icon").on("click", function () {
5+
this.classList.toggle("icon-opened");
6+
// FIXME: use vanilla JS and CSS instead of jQuery
7+
$(this).siblings("ul").toggle(500);
8+
});
9+
10+
// Activate current page
11+
$(`.sidebar-content a[href='${window.location.pathname}']`)
12+
.attr("class", "active-link")
13+
.parents('ul')
14+
.show();
15+
})
16+
});

0 commit comments

Comments
 (0)