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:
@@ -2,22 +2,38 @@ import { ChakraProvider } from '@chakra-ui/react';
|
||||
import {
|
||||
createMemoryHistory,
|
||||
createRouter,
|
||||
HeadContent,
|
||||
RouterProvider,
|
||||
rootRouteId,
|
||||
} from '@tanstack/react-router';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import type { ReactNode } from 'react';
|
||||
import { expect } from 'vitest';
|
||||
import ErrorPage from '../components/StatusPage/ErrorPage';
|
||||
import { routeTree } from '../routeTree.gen';
|
||||
import { routerOptions } from '../router';
|
||||
import system from '../theme';
|
||||
|
||||
// De echte app: route tree, router-opties en thema zoals in main.tsx
|
||||
// De root route rendert in de browser het hele document (<html>, <body>). Dat
|
||||
// past niet in de testcontainer: React zou <html lang> op het testdocument
|
||||
// zetten en het thema twee keer wikkelen. Tests krijgen daarom een shell met
|
||||
// alleen de head-tags; verder is het dezelfde route tree (V2, D12).
|
||||
const TestShell = ({ children }: { children: ReactNode }) => (
|
||||
<>
|
||||
<HeadContent />
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
|
||||
// De echte app: route tree en router-opties uit router.tsx, thema zoals in de
|
||||
// shell van __root.tsx
|
||||
export async function renderApp(path: string) {
|
||||
const router = createRouter({
|
||||
routeTree,
|
||||
...routerOptions(),
|
||||
history: createMemoryHistory({ initialEntries: [path] }),
|
||||
scrollRestoration: true,
|
||||
defaultErrorComponent: ErrorPage,
|
||||
});
|
||||
const rootOptions = router.routesById[rootRouteId].options as {
|
||||
shellComponent?: typeof TestShell;
|
||||
};
|
||||
rootOptions.shellComponent = TestShell;
|
||||
await router.load();
|
||||
const result = render(
|
||||
<ChakraProvider value={system}>
|
||||
|
||||
Reference in New Issue
Block a user