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
+43
View File
@@ -0,0 +1,43 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { backToTopThreshold } from './backToTopThreshold';
describe('backToTopThreshold', () => {
it('is 60% van de viewporthoogte', () => {
expect(backToTopThreshold(1000)).toBe(600);
});
it('geeft 0 bij ongeldige hoogtes', () => {
for (const h of [0, -10, NaN, Infinity, -Infinity]) {
expect(backToTopThreshold(h)).toBe(0);
}
});
it('ligt altijd tussen 0 en de hoogte (invariant)', () => {
fc.assert(
fc.property(fc.double({ min: 0, max: 1e7, noNaN: true }), (h) => {
const t = backToTopThreshold(h);
return t >= 0 && t <= h;
}),
);
});
it('stijgt mee met de hoogte bij eindige waarden (monotoon)', () => {
const finite = fc.double({ noNaN: true, noDefaultInfinity: true });
fc.assert(
fc.property(finite, finite, (a, b) => {
const [lo, hi] = a <= b ? [a, b] : [b, a];
return backToTopThreshold(lo) <= backToTopThreshold(hi);
}),
);
});
it('volgt het model 0.6 × max(0, h) (oracle)', () => {
fc.assert(
fc.property(fc.double(), (h) => {
const model = Number.isFinite(h) ? 0.6 * Math.max(0, h) : 0;
expect(backToTopThreshold(h)).toBe(model);
}),
);
});
});
+8
View File
@@ -0,0 +1,8 @@
// Vanaf hoeveel pixels scrollen de to-top-knop verschijnt: 60% van de
// viewporthoogte (BR-TOP-01). Ongeldige of negatieve hoogtes tellen als 0.
export function backToTopThreshold(viewportHeight: number): number {
if (!Number.isFinite(viewportHeight) || viewportHeight <= 0) {
return 0;
}
return 0.6 * viewportHeight;
}
+30
View File
@@ -0,0 +1,30 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { copyrightLine } from './copyrightLine';
describe('copyrightLine', () => {
it('heeft de vaste vorm', () => {
expect(copyrightLine(2026)).toBe('© 2026 Andrea Slop Fotografie');
});
it('het jaartal is er weer uit te halen (round-trip)', () => {
fc.assert(
fc.property(fc.integer({ min: 0, max: 9999 }), (year) => {
const match = copyrightLine(year).match(/^© (\d+) /);
return match !== null && Number(match[1]) === year;
}),
);
});
it('begint met © en eindigt met de bedrijfsnaam (invariant)', () => {
fc.assert(
fc.property(fc.integer(), (year) => {
const line = copyrightLine(year);
return (
line.startsWith('©') &&
line.endsWith('Andrea Slop Fotografie')
);
}),
);
});
});
+4
View File
@@ -0,0 +1,4 @@
// Copyrightregel in de onderste footerbalk (BR-FOOT-02)
export function copyrightLine(year: number): string {
return `© ${year} Andrea Slop Fotografie`;
}
+48
View File
@@ -0,0 +1,48 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { anyEmail, validEmail } from '../test/arbitraries';
import { emailAddress } from './emailAddress';
describe('emailAddress', () => {
it('voegt geldige delen samen', () => {
expect(emailAddress({ user: 'info', domain: 'andreaslop.nl' })).toBe(
'info@andreaslop.nl',
);
});
it('geeft null bij ongeldige delen', () => {
for (const parts of [
{ user: '', domain: 'andreaslop.nl' },
{ user: 'info', domain: '' },
{ user: 'in fo', domain: 'andreaslop.nl' },
{ user: 'info@x', domain: 'andreaslop.nl' },
{ user: 'info', domain: 'andreaslop' },
{ user: 'info', domain: 'andrea@slop.nl' },
]) {
expect(emailAddress(parts)).toBeNull();
}
});
it('splitsen bij @ geeft de delen terug (round-trip)', () => {
fc.assert(
fc.property(validEmail, (parts) => {
const address = emailAddress(parts);
expect(address).not.toBeNull();
const [user, domain] = address!.split('@');
expect({ user, domain }).toEqual(parts);
}),
);
});
it('is null of bevat precies één @ en geen witruimte (invariant)', () => {
fc.assert(
fc.property(anyEmail, (parts) => {
const address = emailAddress(parts);
return (
address === null ||
(address.split('@').length === 2 && !/\s/.test(address))
);
}),
);
});
});
+12
View File
@@ -0,0 +1,12 @@
import type { EmailAddress } from '../content/types';
const invalidPart = (part: string) => part === '' || /[\s@]/.test(part);
// Voegt het e-mailadres pas in de browser samen (BR-EMAIL-01). Geeft null bij
// ongeldige delen, zodat de footer de Contact-kolom kan weglaten (BR-EMAIL-02).
export function emailAddress({ user, domain }: EmailAddress): string | null {
if (invalidPart(user) || invalidPart(domain) || !domain.includes('.')) {
return null;
}
return `${user}@${domain}`;
}
+56
View File
@@ -0,0 +1,56 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { slidesToLoad } from './slidesToLoad';
describe('slidesToLoad', () => {
it('laadt de actieve, de volgende en de vorige slide', () => {
expect(slidesToLoad(3, 8)).toEqual([3, 4, 2]);
});
it('loopt rond: vanaf de eerste is de vorige de laatste', () => {
expect(slidesToLoad(0, 8)).toEqual([0, 1, 7]);
expect(slidesToLoad(7, 8)).toEqual([7, 0, 6]);
});
it('werkt met weinig of geen slides', () => {
expect(slidesToLoad(0, 1)).toEqual([0]);
expect(slidesToLoad(0, 2)).toEqual([0, 1]);
expect(slidesToLoad(0, 0)).toEqual([]);
expect(slidesToLoad(0, 2.5)).toEqual([]);
});
it('geeft unieke geldige indexen, de actieve voorop (invariant)', () => {
fc.assert(
fc.property(
fc.integer({ min: 1, max: 50 }),
fc.integer({ min: -100, max: 100 }),
(count, active) => {
const result = slidesToLoad(active, count);
expect(new Set(result).size).toBe(result.length);
expect(result).toHaveLength(Math.min(count, 3));
expect(result.every((i) => i >= 0 && i < count)).toBe(true);
expect(result[0]).toBe(((active % count) + count) % count);
},
),
);
});
it('elke buurslide ligt een stap voor of achter de actieve (oracle)', () => {
fc.assert(
fc.property(
fc.integer({ min: 1, max: 50 }),
fc.nat(),
(count, active) => {
const current = active % count;
for (const i of slidesToLoad(active, count)) {
const distance = Math.min(
(i - current + count) % count,
(current - i + count) % count,
);
expect(distance).toBeLessThanOrEqual(1);
}
},
),
);
});
});
+15
View File
@@ -0,0 +1,15 @@
// Welke hero-slides geladen moeten zijn: de actieve en zijn buren, rondlopend.
// Vanaf de eerste slide is de vorige de laatste (BR-HERO-01).
export function slidesToLoad(active: number, count: number): number[] {
if (!Number.isInteger(count) || count <= 0) {
return [];
}
const current = ((active % count) + count) % count;
return [
...new Set([
current,
(current + 1) % count,
(current - 1 + count) % count,
]),
];
}
+59
View File
@@ -0,0 +1,59 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { socialLink } from '../test/arbitraries';
import { visibleSocials } from './visibleSocials';
const isHttps = (href: string) => {
try {
return new URL(href).protocol === 'https:';
} catch {
return false;
}
};
describe('visibleSocials', () => {
it('laat alleen geldige https-links door', () => {
const result = visibleSocials([
{ platform: 'facebook', href: 'https://facebook.com/x' },
{ platform: 'instagram', href: '' },
{ platform: 'instagram', href: 'http://instagram.com/x' },
{ platform: 'facebook', href: 'javascript:alert(1)' },
]);
expect(result).toEqual([
{ platform: 'facebook', href: 'https://facebook.com/x' },
]);
});
it('is idempotent', () => {
fc.assert(
fc.property(fc.array(socialLink), (socials) => {
const once = visibleSocials(socials);
expect(visibleSocials(once)).toEqual(once);
}),
);
});
it('is een deelreeks van de invoer in dezelfde volgorde (invariant)', () => {
fc.assert(
fc.property(fc.array(socialLink), (socials) => {
const result = visibleSocials(socials);
let i = 0;
for (const item of socials) {
if (item === result[i]) i++;
}
return i === result.length;
}),
);
});
it('houdt precies de https-links over (oracle)', () => {
fc.assert(
fc.property(fc.array(socialLink), (socials) => {
expect(visibleSocials(socials)).toEqual(
socials.filter((s) => isHttps(s.href)),
);
return visibleSocials(socials).every((s) => isHttps(s.href));
}),
);
});
});
+16
View File
@@ -0,0 +1,16 @@
import type { SocialLink } from '../content/types.ts';
function isHttpsUrl(href: string): boolean {
try {
return new URL(href).protocol === 'https:';
} catch {
return false;
}
}
// Alleen links met een geldige https-URL (BR-SOC-01). Leeg, http:,
// javascript: of iets onleesbaars uit het CMS wordt overgeslagen; de
// volgorde blijft gelijk (BR-SOC-02).
export function visibleSocials(socials: readonly SocialLink[]): SocialLink[] {
return socials.filter((social) => isHttpsUrl(social.href));
}