Skip to content

Commit 39b7da1

Browse files
committed
github pages grr cloudflare pages better
1 parent dd18677 commit 39b7da1

4 files changed

Lines changed: 78 additions & 2 deletions

File tree

404.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!-- This is for when GitHub pages is stupid -->
2+
<!doctype html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta http-equiv="refresh" content="0; url=/?redirect=%2F" />
7+
<script>
8+
const redirect = window.location.pathname;
9+
const search = window.location.search;
10+
const hash = window.location.hash;
11+
12+
const newUrl =
13+
"/" + "?redirect=" + encodeURIComponent(redirect + search + hash);
14+
15+
window.location.replace(newUrl);
16+
</script>
17+
<title>Redirecting…</title>
18+
</head>
19+
<body></body>
20+
</html>

src/layout.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { Outlet } from "react-router-dom";
2-
import SetColor from "./components/SetColor";
32
import SwitcherLink from "./components/SwitcherLink";
43

54
export default function Layout() {
65
return (
76
<body className="antialiased flex flex-col min-h-screen align-middle">
87
<div className="flex flex-col min-h-dvh">
9-
<SetColor />
108
<header className="backdrop-blur-3xl border-b sticky top-0 min-w-full z-100">
119
<nav className="flex gap-10 h-10 justify-center">
1210
<SwitcherLink to="" name="Home"></SwitcherLink>

src/main.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import { StrictMode } from "react";
22
import { createRoot } from "react-dom/client";
33
import { createBrowserRouter, RouterProvider } from "react-router-dom";
4+
import SetColor from "./components/SetColor";
45
import "./index.css";
56
import Layout from "./layout";
67
import Home from "./pages";
78
import About from "./pages/about";
89
import ActualAbout from "./pages/aboutActual";
10+
import ErrorPage from "./pages/error";
911
import Games from "./pages/games";
1012

1113
const routes = [
1214
{
1315
path: "/",
1416
element: <Layout />,
17+
errorElement: <ErrorPage />,
1518
children: [
1619
{
1720
index: true,
@@ -38,6 +41,7 @@ const router = createBrowserRouter(routes, {
3841

3942
createRoot(document.getElementById("root")!).render(
4043
<StrictMode>
44+
<SetColor />
4145
<RouterProvider router={router} />
4246
</StrictMode>,
4347
);

src/pages/error.tsx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { isRouteErrorResponse, useRouteError } from "react-router";
2+
3+
const ErrorPage = () => {
4+
const error = useRouteError();
5+
6+
if (isRouteErrorResponse(error)) {
7+
return (
8+
<div className="flex flex-col items-center gap-5 h-dvh place-content-center">
9+
<h1 className="justify-center text-7xl w-fit text-primary overflow-hidden font-fancy">
10+
{error.status} {error.statusText}
11+
</h1>
12+
<h2 className="justify-center text-3xl w-fit text-secondary overflow-clip font-semifancy">
13+
Uh oh!
14+
</h2>
15+
<h2 className="justify-center text-3xl w-fit text-secondary overflow-clip font-semifancy">
16+
Developer info: {error.data}
17+
</h2>
18+
</div>
19+
);
20+
} else if (error instanceof Error) {
21+
return (
22+
<div className="flex flex-col items-center gap-5 h-dvh place-content-center">
23+
<h1 className="justify-center text-7xl w-fit text-primary overflow-hidden font-fancy">
24+
Error!
25+
</h1>
26+
<h2 className="justify-center text-3xl w-fit text-secondary overflow-clip font-semifancy">
27+
Uh oh!
28+
</h2>
29+
<h2 className="justify-center text-3xl w-fit text-secondary overflow-clip font-semifancy">
30+
{error.message}
31+
</h2>
32+
<br />
33+
34+
<h2 className="justify-center text-3xl w-fit text-secondary overflow-clip font-semifancy">
35+
Developer info:
36+
</h2>
37+
<pre>{error.stack}</pre>
38+
</div>
39+
);
40+
} else {
41+
return (
42+
<div className="flex flex-col items-center gap-5 h-dvh place-content-center">
43+
<h1 className="justify-center text-7xl w-fit text-primary overflow-hidden font-fancy">
44+
Unknown error!
45+
</h1>
46+
<h2 className="justify-center text-3xl w-fit text-secondary overflow-clip font-semifancy">
47+
Uh oh!
48+
</h2>
49+
</div>
50+
);
51+
}
52+
};
53+
54+
export default ErrorPage;

0 commit comments

Comments
 (0)