diff --git a/src/handbook/src/backend/events.ts b/src/handbook/src/backend/events.ts index cf132f197..8904b8c2b 100644 --- a/src/handbook/src/backend/events.ts +++ b/src/handbook/src/backend/events.ts @@ -1,5 +1,7 @@ import { EventEmitter } from "events"; + import type { Page } from "@backend/types"; +import { isPage } from "@backend/types"; const emitter = new EventEmitter(); const navigation = new EventEmitter(); @@ -18,14 +20,14 @@ export function setup(): void { setTimeout(() => { // Check if the window's href is a page. const page = window.location.href.split("/").pop(); - if (page == undefined) return; + if (page == undefined || page == "") 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); + isPage(page) && navigate(pageType, false); }, 3e2); } diff --git a/src/handbook/src/backend/types.ts b/src/handbook/src/backend/types.ts index 0e83545c5..5213fe621 100644 --- a/src/handbook/src/backend/types.ts +++ b/src/handbook/src/backend/types.ts @@ -124,7 +124,7 @@ export enum ItemCategory { * @param page The string to check. */ export function isPage(page: string): page is Page { - return ["Home", "Commands"].includes(page); + return ["Home", "Commands", "Avatars", "Items", "Entities", "Scenes"].includes(page); } /** diff --git a/src/handbook/src/ui/App.tsx b/src/handbook/src/ui/App.tsx index 25f606907..ca7f21787 100644 --- a/src/handbook/src/ui/App.tsx +++ b/src/handbook/src/ui/App.tsx @@ -23,7 +23,9 @@ class App extends React.Component<{}, IState> { // Check if the window's href is a page. let targetPage = null; const page = window.location.href.split("/").pop(); - if (page != undefined) { + console.log(page) + + if (page != undefined && page != "") { // Convert the page to a Page type. const pageName = page.charAt(0).toUpperCase() + page.slice(1); // Check if the page is a valid page.