Created
May 16, 2023 09:24
-
-
Save danielk333/b9e91534692ca1078c8b751df99c2d58 to your computer and use it in GitHub Desktop.
Allow revealjs hash with files in subfolders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const originalReplaceState = history.replaceState; | |
// Run below Reveal.initialize like | |
// enable_hash('/presentations/2023/my-presentation.html'); | |
function enable_hash(path) { | |
history.replaceState = (_a, _b, url) => { | |
url = url.toString(); | |
if (url[0] == '#') { | |
url = path + url; | |
} | |
originalReplaceState.bind(history)(_a, _b, url); | |
}; | |
if (window.location.href.includes('file://')) { | |
Reveal.configure({hash: false}); | |
} | |
else { | |
Reveal.configure({hash: true}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment