Skip to content

Commit

Permalink
index: add hack to restore docsify behaviour
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lifehackerhansol committed Nov 20, 2024
1 parent 999a2b1 commit 011480a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ hero:
tagline: "A guide collaboration between Nintendo Homebrew's Helpers and Staff, from stock to Aroma custom firmware."
image:
src: "/assets/img/home-page-feature.jpg"

head: [
['script', {src: '/assets/js/docsify-wrapper.js'}]
]
---

::: tip
Expand Down
27 changes: 27 additions & 0 deletions docs/public/assets/js/docsify-wrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Copyright (C) 2024 Nintendo Homebrew
SPDX-License-Identifier: MIT
*/

const map = new WeakMap()

function checkDocsify(callback) {
if (map.has(callback))
return;
map.set(callback, true);
if (document.readyState === 'complete')
callback();
else
window.addEventListener('load', callback, false);
}

checkDocsify(() => {
if(!window.location.hash)
return;

if(window.location.hash[1] == '/') {
path = window.location.hash.substring(1);
window.location.href = path;
}
})

0 comments on commit 011480a

Please sign in to comment.