diff --git a/site/index.html b/site/index.html index 0b7b6d4..2e4e91b 100644 --- a/site/index.html +++ b/site/index.html @@ -10,6 +10,31 @@ /> Coder Skill Scanner + + // GitHub Pages SPA fallback: capture the original path in a query // parameter and bounce to the SPA index, which restores it before - // React Router boots. See site/src/main.tsx for the restore step. + // React Router boots. See site/index.html for the restore step. // // `%BASE_URL%` is substituted at build time by the // `rewrite-public-base-url` Vite plugin (see site/vite.config.ts), diff --git a/site/src/main.tsx b/site/src/main.tsx index 8a71460..3eb3b35 100644 --- a/site/src/main.tsx +++ b/site/src/main.tsx @@ -2,13 +2,8 @@ import { StrictMode } from "react"; import { createRoot } from "react-dom/client"; import { App } from "./App"; -// Restore SPA path captured by public/404.html (GitHub Pages deep-link trick). -const url = new URL(window.location.href); -const original = url.searchParams.get("p"); -if (original) { - url.searchParams.delete("p"); - window.history.replaceState(null, "", original + url.search + url.hash); -} +// Note: the `?p=...` query param emitted by public/404.html is restored +// by the inline script in index.html so the router sees the original path. const appRoot = document.getElementById("root"); if (appRoot === null) { diff --git a/site/src/pages/NotFoundPage.tsx b/site/src/pages/NotFoundPage.tsx index abf0891..7f53ac6 100644 --- a/site/src/pages/NotFoundPage.tsx +++ b/site/src/pages/NotFoundPage.tsx @@ -1,27 +1,48 @@ import type { FC } from "react"; -import { Link } from "react-router-dom"; +import { Link, useLocation } from "react-router-dom"; import { usePageTitle } from "../lib/usePageTitle"; export const NotFoundPage: FC = () => { + const { pathname } = useLocation(); usePageTitle("not found"); return ( -
-
+
+
404
-

- That path doesn't exist in this report. -

-
+
+

+ That page isn't part of this scan report. +

+

+ We couldn't find{" "} + + {pathname} + + . It may have moved, been renamed, or never existed. +

+
+
- Back to the latest scan + Latest scan - - or browse the scan history + + Scan history + + Raw JSON + + + Source +
);