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:
2026-10-18 17:05:02 +02:00
co-authored by Claude Opus 5.5
parent b5b7f3b3db
commit 4d6408b607
99 changed files with 7883 additions and 414 deletions
+124
View File
@@ -0,0 +1,124 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import siteContent from './content/siteContent';
import {
canonicalUrl,
jsonLdScript,
pageHead,
professionalService,
siteHead,
siteUrl,
} from './seo';
import { routePath } from './test/arbitraries';
const meta = (head: ReturnType<typeof pageHead>, key: string) =>
head.meta.find(
(m) =>
('name' in m && m.name === key) ||
('property' in m && m.property === key),
);
describe('canonicalUrl', () => {
it('maakt een absolute URL zonder slash, query of hash', () => {
expect(canonicalUrl('/')).toBe(`${siteUrl}/`);
expect(canonicalUrl('')).toBe(`${siteUrl}/`);
expect(canonicalUrl('/portfolio/')).toBe(`${siteUrl}/portfolio`);
expect(canonicalUrl('/contact?x=1#top')).toBe(`${siteUrl}/contact`);
expect(canonicalUrl('portfolio')).toBe(`${siteUrl}/portfolio`);
});
it('is idempotent', () => {
fc.assert(
fc.property(
routePath,
fc.constantFrom('', '/', '?a=1', '#x'),
(path, suffix) => {
const once = canonicalUrl(path + suffix);
expect(canonicalUrl(once.slice(siteUrl.length))).toBe(once);
},
),
);
});
it('begint met siteUrl en eindigt alleen bij de root op een slash (invariant)', () => {
fc.assert(
fc.property(fc.string(), (path) => {
const url = canonicalUrl(path);
const rest = url.slice(siteUrl.length);
return (
url.startsWith(siteUrl + '/') &&
!/[?#]/.test(rest) &&
(rest === '/' || !rest.endsWith('/'))
);
}),
);
});
});
describe('pageHead', () => {
it('zet titel, canonical en preview voor de homepage, zonder robots-tag', () => {
const head = pageHead('/');
expect(head.meta[0]).toEqual({
title: 'Lifestyle fotograaf in Huizen | Andrea Slop Fotografie',
});
expect(head.links).toEqual([{ rel: 'canonical', href: `${siteUrl}/` }]);
expect(meta(head, 'og:url')).toMatchObject({ content: `${siteUrl}/` });
expect(meta(head, 'og:image')).toMatchObject({
content: `${siteUrl}/og-image.jpg`,
});
expect(meta(head, 'robots')).toBeUndefined();
});
it('zet noindex op een placeholder', () => {
const head = pageHead('/portfolio');
expect(meta(head, 'robots')).toMatchObject({ content: 'noindex' });
expect(head.links[0].href).toBe(`${siteUrl}/portfolio`);
});
});
describe('jsonLdScript', () => {
it('geeft na parsen dezelfde data terug (round-trip)', () => {
fc.assert(
fc.property(fc.jsonValue(), (value) => {
expect(JSON.parse(jsonLdScript(value))).toEqual(
JSON.parse(JSON.stringify(value)),
);
}),
);
});
it('bevat nooit < of >, dus nooit een sluitende script-tag (invariant)', () => {
fc.assert(
fc.property(fc.jsonValue(), fc.string(), (value, text) => {
const out = jsonLdScript({ value, text: text + '</script>' });
return !/[<>]/.test(out);
}),
);
});
});
describe('professionalService en siteHead', () => {
it('beschrijft de fotograaf zonder e-mailadres', () => {
const data = professionalService(siteContent);
expect(data['@type']).toBe('ProfessionalService');
expect(data.address.addressLocality).toBe('Huizen');
expect(data.sameAs).toEqual(siteContent.socials.map((s) => s.href));
expect(JSON.stringify(data)).not.toContain('@andreaslop');
});
it('laat ongeldige socials weg uit sameAs', () => {
const data = professionalService({
...siteContent,
socials: [{ platform: 'facebook', href: 'http://onveilig.nl' }],
});
expect(data.sameAs).toEqual([]);
});
it('zet de gestructureerde data als ld+json-script', () => {
const head = siteHead(siteContent);
expect(head.scripts[0].type).toBe('application/ld+json');
expect(JSON.parse(head.scripts[0].children)['@type']).toBe(
'ProfessionalService',
);
});
});