Fix route -> page binding

This commit is contained in:
KingRainbow44 2023-04-08 23:52:39 -04:00
parent 8f74168a23
commit 4231b26eea
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE

View File

@ -14,6 +14,19 @@ export function setup(): void {
window.onpopstate = (event) => {
navigate(event.state, false);
};
setTimeout(() => {
// Check if the window's href is a page.
const page = window.location.href.split("/").pop();
if (page == undefined) return;
// Convert the page to a Page type.
const pageName = page.charAt(0).toUpperCase() + page.slice(1);
const pageType = pageName as Page;
// Navigate to the page.
navigate(pageType, false);
}, 3e2);
}
/**