The site now exists in German (at the root, with /impressum and /datenschutz) and English (/en). A request without a language follows the visitor's choice from the language switch, then the browser language, then German; the old English legal addresses move to /en for good. All visible texts are data in src/content/de.ts and en.ts, so components hold none of their own. The header carries a DE/EN switch whose bit curtain covers the page while it is swapped and reopens at the same reading position. Title, description, canonical, hreflang, Open Graph, the share image, the sitemap and the structured data are per language. The privacy notice now describes the cookie that remembers the chosen language. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
82 lines
3.0 KiB
TypeScript
82 lines
3.0 KiB
TypeScript
"use client";
|
|
|
|
import * as Sentry from "@sentry/nextjs";
|
|
import { useEffect, useState } from "react";
|
|
import { Inter, Newsreader } from "next/font/google";
|
|
import { contentFor } from "@/src/content";
|
|
import { DEFAULT_LOCALE, type Locale } from "@/src/domain/locale";
|
|
import { localeOfPath } from "@/src/domain/routes";
|
|
import "./globals.css";
|
|
|
|
const inter = Inter({ subsets: ["latin"], variable: "--font-inter" });
|
|
const newsreader = Newsreader({
|
|
subsets: ["latin"],
|
|
variable: "--font-newsreader",
|
|
style: "italic",
|
|
display: "swap",
|
|
});
|
|
|
|
export default function GlobalError({
|
|
error,
|
|
reset,
|
|
}: {
|
|
error: Error & { digest?: string };
|
|
reset: () => void;
|
|
}) {
|
|
// The root layout failed, so the language is read from the address.
|
|
const [locale, setLocale] = useState<Locale>(DEFAULT_LOCALE);
|
|
useEffect(() => setLocale(localeOfPath(window.location.pathname)), []);
|
|
const copy = contentFor(locale).error;
|
|
|
|
useEffect(() => {
|
|
Sentry.captureException(error);
|
|
|
|
// Auto-reload on ChunkLoadError or Server Action errors to fetch the new deployment assets
|
|
const isChunkLoadError =
|
|
error.message &&
|
|
(error.message.includes("ChunkLoadError") ||
|
|
error.message.includes("Loading chunk") ||
|
|
error.message.includes("Failed to find Server Action"));
|
|
|
|
if (isChunkLoadError) {
|
|
const lastReload = sessionStorage.getItem("last-chunk-reload");
|
|
const now = Date.now();
|
|
if (!lastReload || now - parseInt(lastReload) > 10000) {
|
|
sessionStorage.setItem("last-chunk-reload", now.toString());
|
|
window.location.reload();
|
|
}
|
|
}
|
|
}, [error]);
|
|
|
|
return (
|
|
<html lang={locale} className={`${inter.variable} ${newsreader.variable}`}>
|
|
<body className="min-h-screen bg-white font-sans text-slate-900">
|
|
<div className="flex flex-col items-center justify-center min-h-screen px-5 py-20 text-center">
|
|
<div className="space-y-6 max-w-2xl mx-auto">
|
|
<span className="inline-block px-3 py-1 bg-red-50 border border-red-200 rounded text-[10px] font-mono text-red-600 uppercase tracking-widest border-dashed">
|
|
{copy.kicker}
|
|
</span>
|
|
<h1 className="text-4xl md:text-6xl font-black tracking-tighter text-slate-900">
|
|
{copy.title}
|
|
</h1>
|
|
<p className="text-lg md:text-xl text-slate-500 font-serif italic max-w-xl mx-auto">
|
|
{copy.text}
|
|
</p>
|
|
|
|
<div className="pt-8">
|
|
<button
|
|
onClick={() => reset()}
|
|
className="relative inline-flex items-center justify-center gap-3 overflow-hidden rounded-full font-bold uppercase tracking-[0.15em] transition-all duration-300 group cursor-pointer px-8 py-4 text-[10px] bg-slate-900 text-white hover:shadow-xl hover:-translate-y-0.5"
|
|
>
|
|
<span className="relative z-10 flex items-center gap-3">
|
|
{copy.retry}
|
|
</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|