Skip to content

Instantly share code, notes, and snippets.

@danielk333
Created May 16, 2023 09:24
Show Gist options
  • Save danielk333/b9e91534692ca1078c8b751df99c2d58 to your computer and use it in GitHub Desktop.
Save danielk333/b9e91534692ca1078c8b751df99c2d58 to your computer and use it in GitHub Desktop.
Allow revealjs hash with files in subfolders
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