Skip to content

Commit 8903ee9

Browse files
committed
fix version switching
1 parent 680667d commit 8903ee9

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

site/static/js/bookwyrm.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ document.addEventListener('DOMContentLoaded', () => {
3434
var arr = current_location.split("/")
3535
var regx = /\/v[0-9\.]+/
3636
if (regx.test(current_location)) {
37-
window.location = window.location.href.replace(regx,`${target_version}`)
37+
window.location = window.location.href.replace(regx,`/${target_version}`)
3838
} else {
3939
window.location = `/${target_version}${current_location}`
4040
}
@@ -63,11 +63,13 @@ document.addEventListener('DOMContentLoaded', () => {
6363

6464
// Table of contents
6565
const $tocController = document.getElementById("toc");
66-
$tocController.addEventListener('click', () => {
67-
$tocController.classList.toggle('is-active');
68-
const target = $tocController.dataset.target;
69-
const $target = document.getElementById(target);
70-
$target.classList.toggle('is-hidden-touch');
71-
})
66+
if ($tocController) {
67+
$tocController.addEventListener('click', () => {
68+
$tocController.classList.toggle('is-active');
69+
const target = $tocController.dataset.target;
70+
const $target = document.getElementById(target);
71+
$target.classList.toggle('is-hidden-touch');
72+
})
73+
}
7274

7375
});

0 commit comments

Comments
 (0)