Skip to content

Commit 9cdcbc2

Browse files
committed
Set page title
1 parent ac3e961 commit 9cdcbc2

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { HashRouter, Navigate, Route, Routes, useParams } from "react-router-dom
44
import { styled } from "@linaria/react";
55
import { AppContext } from "./components/AppContext";
66
import { Declaration } from "./components/Docs/api";
7-
import { isGameId, GameId, GAMES } from "./games";
7+
import { isGameId, GameId, GAMES, getGame } from "./games";
88
import { loadGameSchemas, type SchemaMetadata } from "./components/data";
99
import DeclarationsPage from "./components/DeclarationsPage";
1010
import "./global.css";
@@ -23,7 +23,7 @@ const EMPTY_DECLARATIONS: Declaration[] = [];
2323
const EMPTY_OTHER_GAMES = new Map<GameId, Declaration[]>();
2424

2525
function SchemasPage() {
26-
const { game } = useParams<{ game: string }>();
26+
const { game, module, scope } = useParams<{ game: string; module: string; scope: string }>();
2727
const [declarations, setDeclarations] = useState<Declaration[] | null>(null);
2828
const [metadata, setMetadata] = useState<SchemaMetadata>({
2929
revision: 0,
@@ -68,6 +68,12 @@ function SchemasPage() {
6868
};
6969
}, [validGame]);
7070

71+
useEffect(() => {
72+
const gameName = validGame ? getGame(validGame)?.name : null;
73+
const parts = [scope, module, gameName, "Source 2 Schema Explorer"].filter(Boolean);
74+
document.title = parts.join(" - ");
75+
}, [validGame, module, scope]);
76+
7177
const resolvedDeclarations = declarations ?? EMPTY_DECLARATIONS;
7278
const loading = !declarations && !error;
7379

0 commit comments

Comments
 (0)