The build still bakes the current packages and the active banner into the HTML. After hydration the page asks /api/v1/offerings and /api/v1/offerings/banner once and replaces what differs; errors and time-outs keep what was baked, and a 204 from the banner route hides the banner. The banner is now the OfferingBanner contract (title, text, optional link) instead of layout=banner. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
80 lines
2.7 KiB
TypeScript
80 lines
2.7 KiB
TypeScript
import { lazy, Suspense } from 'react';
|
|
import type { ReactNode } from 'react';
|
|
import { createRootRoute, HeadContent, Scripts } from '@tanstack/react-router';
|
|
import { ChakraProvider } from '@chakra-ui/react';
|
|
import AppShell from '../components/AppShell';
|
|
import PackagesProvider from '../components/PackagesProvider/PackagesProvider';
|
|
import NoScriptStyles from '../components/NoScript/NoScriptStyles';
|
|
import ErrorPage from '../components/StatusPage/ErrorPage';
|
|
import NotFound from '../components/StatusPage/NotFound';
|
|
import siteContent from '../content/siteContent';
|
|
import { siteHead } from '../seo';
|
|
import system from '../theme';
|
|
|
|
import '@fontsource/jost/300.css';
|
|
import '@fontsource/jost/400.css';
|
|
import '@fontsource/jost/500.css';
|
|
import '@fontsource/marcellus/400.css';
|
|
|
|
// Devtools alleen tijdens het ontwikkelen; ze komen niet in de productiebuild
|
|
const RouterDevtools = import.meta.env.DEV
|
|
? lazy(() =>
|
|
import('@tanstack/react-router-devtools').then((module) => ({
|
|
default: module.TanStackRouterDevtools,
|
|
})),
|
|
)
|
|
: () => null;
|
|
|
|
// Het hele document: Start rendert dit op de server en hydrateert het in de
|
|
// browser. Titel en meta-tags van de actieve route komen via HeadContent.
|
|
const RootDocument = ({ children }: { children: ReactNode }) => (
|
|
<html lang="nl">
|
|
<head>
|
|
<HeadContent />
|
|
<NoScriptStyles />
|
|
</head>
|
|
<body>
|
|
{/* De site is alleen licht; de _dark-waarden in het thema blijven
|
|
staan voor een eventuele donkere modus later */}
|
|
<ChakraProvider value={system}>{children}</ChakraProvider>
|
|
<Scripts />
|
|
</body>
|
|
</html>
|
|
);
|
|
|
|
const RootLayout = () => (
|
|
<PackagesProvider>
|
|
<AppShell />
|
|
<Suspense>
|
|
<RouterDevtools />
|
|
</Suspense>
|
|
</PackagesProvider>
|
|
);
|
|
|
|
export const Route = createRootRoute({
|
|
head: () => {
|
|
const { meta, scripts } = siteHead(siteContent);
|
|
return {
|
|
meta: [
|
|
{ charSet: 'utf-8' },
|
|
{
|
|
name: 'viewport',
|
|
content: 'width=device-width, initial-scale=1.0',
|
|
},
|
|
...meta,
|
|
],
|
|
links: [
|
|
{ rel: 'icon', type: 'image/png', href: '/favicon.png' },
|
|
{ rel: 'apple-touch-icon', href: '/favicon.png' },
|
|
],
|
|
scripts,
|
|
};
|
|
},
|
|
shellComponent: RootDocument,
|
|
component: RootLayout,
|
|
// Onbekende URL: 404 binnen de shell (FR-09)
|
|
notFoundComponent: NotFound,
|
|
// Fout in de shell zelf: foutpagina zonder shell, als vangnet (FR-10)
|
|
errorComponent: ErrorPage,
|
|
});
|