Completes the front-end shell with footer, status pages and SEO
Adds the footer, back-to-top button, skip link, placeholder routes, 404 and error pages inside the shell, plus per-page SEO from a single page registry (canonical URLs, Open Graph image, JSON-LD, generated sitemap.xml and robots.txt). Theme tokens and recipes replace repeated styling, the hero loads only the active and neighbouring slides, and the e-mail address is joined in the browser to keep it out of the HTML and bundle. Adds Vitest with property-based (fast-check) and axe tests, ESLint, security headers for dev and preview, Lighthouse CI and a `pnpm check` script that runs all quality gates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { act } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { renderWithProviders } from '../test/renderWithProviders';
|
||||
import useRouteFocus from './useRouteFocus';
|
||||
|
||||
function Harness() {
|
||||
useRouteFocus();
|
||||
return (
|
||||
<main id="main" tabIndex={-1}>
|
||||
inhoud
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
describe('useRouteFocus', () => {
|
||||
it('zet de focus niet bij de eerste keer laden', async () => {
|
||||
await renderWithProviders(<Harness />, { path: '/' });
|
||||
expect(document.activeElement).toBe(document.body);
|
||||
});
|
||||
|
||||
it('zet de focus op main na een paginawissel', async () => {
|
||||
const { router } = await renderWithProviders(<Harness />, {
|
||||
path: '/',
|
||||
});
|
||||
await act(() => router.navigate({ to: '/portfolio' }));
|
||||
expect(document.activeElement).toBe(document.getElementById('main'));
|
||||
});
|
||||
|
||||
it('zet de focus niet als alleen de hash verandert', async () => {
|
||||
const { router } = await renderWithProviders(<Harness />, {
|
||||
path: '/portfolio',
|
||||
});
|
||||
await act(() => router.navigate({ to: '/portfolio', hash: 'top' }));
|
||||
expect(document.activeElement).toBe(document.body);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useRouter } from '@tanstack/react-router';
|
||||
|
||||
// Na een paginawissel krijgt de inhoud (main#main) de focus, zodat een
|
||||
// schermlezer de nieuwe pagina voorleest (BR-A11Y-01). Niet bij de eerste
|
||||
// keer laden, en niet als alleen query of hash verandert. Scrollen blijft
|
||||
// aan de scroll restoration van de router.
|
||||
export default function useRouteFocus() {
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
router.subscribe('onResolved', ({ fromLocation, pathChanged }) => {
|
||||
if (!fromLocation || !pathChanged) return;
|
||||
document.getElementById('main')?.focus({ preventScroll: true });
|
||||
}),
|
||||
[router],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user