Skip to content

Commit 011480a

Browse files
index: add hack to restore docsify behaviour
This attempts to restore the old behaviour of docsify.js, where it uses hash parameters to navigate the site. Since this isn't the case in VitePress, all the old links to the guide broke, so check it on load. This works on a best-effort basis; if the corresponding page exists (such as `#/aroma/getting-started` -> `/aroma/getting-started`), it should navigate properly, but if the corresponding page doesn't exist, it will 404.
1 parent 999a2b1 commit 011480a

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

docs/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ hero:
66
tagline: "A guide collaboration between Nintendo Homebrew's Helpers and Staff, from stock to Aroma custom firmware."
77
image:
88
src: "/assets/img/home-page-feature.jpg"
9+
10+
head: [
11+
['script', {src: '/assets/js/docsify-wrapper.js'}]
12+
]
913
---
1014

1115
::: tip
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Copyright (C) 2024 Nintendo Homebrew
3+
4+
SPDX-License-Identifier: MIT
5+
*/
6+
7+
const map = new WeakMap()
8+
9+
function checkDocsify(callback) {
10+
if (map.has(callback))
11+
return;
12+
map.set(callback, true);
13+
if (document.readyState === 'complete')
14+
callback();
15+
else
16+
window.addEventListener('load', callback, false);
17+
}
18+
19+
checkDocsify(() => {
20+
if(!window.location.hash)
21+
return;
22+
23+
if(window.location.hash[1] == '/') {
24+
path = window.location.hash.substring(1);
25+
window.location.href = path;
26+
}
27+
})

0 commit comments

Comments
 (0)