Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ jobs:

- run: npm run build

# GitHub Pages serves a root-level 404.html for unknown URLs. React Router
# prerenders the route to 404/index.html, so copy it to the flat filename.
- name: Add 404 page for GitHub Pages
run: cp build/client/404/index.html build/client/404.html

- name: Upload artifact
# Only upload after merge to main, not on pull request builds.
if: github.event_name == 'push'
Expand Down
52 changes: 52 additions & 0 deletions src/app/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -824,3 +824,55 @@ p{
.lang .lang-right{
border-radius: 0 8px 8px 0;
}

.notfound{
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
gap: 12px;
padding: 32px 20px;
background-color: var(--body-background);
color: var(--body-text-color);
}

.notfound-code{
font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
font-variation-settings: "wght" 600, "opsz" 144, "SOFT" 0, "WONK" 1;
font-size: 120pt;
line-height: 1;
margin: 0;
color: var(--accent);
letter-spacing: -2px;
}

.notfound-title{
font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
font-size: 28pt;
font-weight: 600;
margin: 0;
}

.notfound-text{
margin: 0;
color: var(--muted-text);
font-size: 13pt;
line-height: 1.4;
}

.notfound-text-de{
font-size: 11pt;
opacity: 0.75;
}

.notfound-actions{
margin-top: 12px;
}

@media (max-width: 600px){
.notfound-code{
font-size: 84pt;
}
}
17 changes: 17 additions & 0 deletions src/app/not-found/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export function NotFound() {
return (
<main className="notfound">
<p className="notfound-code">404</p>
<h1 className="notfound-title">Page not found</h1>
<p className="notfound-text">
The page you were looking for doesn&rsquo;t exist or has moved.
</p>
<p className="notfound-text notfound-text-de" lang="de">
Diese Seite existiert nicht oder wurde verschoben.
</p>
<p className="notfound-actions">
<a className="btn btn-primary" href="/">Back home</a>
</p>
</main>
);
}
16 changes: 10 additions & 6 deletions src/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {

import type { Route } from "./+types/root";
import stylesheet from "./app.css?url";
import { NotFound } from "./not-found/not-found";

export const links: Route.LinksFunction = () => [
{ rel: "icon", href: "/favicon.svg", type: "image/svg+xml" },
Expand All @@ -21,7 +22,7 @@ export const links: Route.LinksFunction = () => [

export function Layout({ children }: { children: React.ReactNode }) {
var matches = useMatches();
var is_de = matches[matches.length - 1].id.endsWith("-de");
var is_de = matches[matches.length - 1]?.id.endsWith("-de") ?? false;
return (
<html lang={is_de ? "de" : "en"}>
<head>
Expand All @@ -44,16 +45,19 @@ export default function App() {
}

export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
// An unknown URL (e.g. GitHub Pages serving 404.html for /foo) boots the app
// with no matching route, landing here with a 404 — show the styled page.
if (isRouteErrorResponse(error) && error.status === 404) {
return <NotFound />;
}

let message = "Oops!";
let details = "An unexpected error occurred.";
let stack: string | undefined;

if (isRouteErrorResponse(error)) {
message = error.status === 404 ? "404" : "Error";
details =
error.status === 404
? "The requested page could not be found."
: error.statusText || details;
message = "Error";
details = error.statusText || details;
} else if (import.meta.env.DEV && error && error instanceof Error) {
details = error.message;
stack = error.stack;
Expand Down
1 change: 1 addition & 0 deletions src/app/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default [

route("/Project-Quick-Open/datenschutz.html", "routes/project-quick-privacy.tsx"),
route("/SWR3App/datenschutz.html", "routes/swr3-app-privacy.tsx"),
route("404", "routes/not-found.tsx", { "index": true}),
layout("routes/layout.tsx", [
index("routes/home.tsx"),
...prefix("en", [
Expand Down
13 changes: 13 additions & 0 deletions src/app/routes/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Route } from "./+types/not-found";
import { NotFound } from "../not-found/not-found";
import "../app.css";

export function meta({}: Route.MetaArgs) {
return [
{ title: "404 — Page not found | Marvin Rühe" },
];
}

export default function NotFoundRoute() {
return <NotFound />;
}