Moves the app to TanStack Start with prerendering
Every page is now built as HTML from sitePages.ts, with a catch-all route for 404.html. Hooks that read the browser during render are safe for prerendering. The script step that keeps the CSP intact follows, so this build still has inline scripts and is not deployable yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import { createFileRoute } from '@tanstack/react-router';
|
||||
import NotFound from '../components/StatusPage/NotFound';
|
||||
|
||||
// Vangt elke onbekende URL op en wordt als 404.html voorgerenderd (BR-404-01).
|
||||
// Geen head() en geen notFound(): Start laat de build falen bij een niet-OK
|
||||
// antwoord, en NotFound zet zelf titel en noindex.
|
||||
export const Route = createFileRoute('/$')({
|
||||
component: NotFound,
|
||||
});
|
||||
@@ -1,10 +1,18 @@
|
||||
import { lazy, Suspense } from 'react';
|
||||
import { createRootRoute, HeadContent } from '@tanstack/react-router';
|
||||
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 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
|
||||
@@ -15,10 +23,24 @@ const RouterDevtools = import.meta.env.DEV
|
||||
)
|
||||
: () => 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 />
|
||||
</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 = () => (
|
||||
<>
|
||||
{/* Titel en meta-tags van de actieve route; React zet ze in <head> */}
|
||||
<HeadContent />
|
||||
<AppShell />
|
||||
<Suspense>
|
||||
<RouterDevtools />
|
||||
@@ -27,7 +49,25 @@ const RootLayout = () => (
|
||||
);
|
||||
|
||||
export const Route = createRootRoute({
|
||||
head: () => siteHead(siteContent),
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user