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
+67
View File
@@ -0,0 +1,67 @@
import { fireEvent, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { describe, expect, it } from 'vitest';
import heroContent from '@/content/heroContent';
import siteContent from '@/content/siteContent';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import Hero from './Hero';
describe('Hero', () => {
it('toont alleen geldige socials, met melding over het nieuwe tabblad', async () => {
const { container } = await renderWithProviders(
<Hero
content={heroContent}
socials={[
...siteContent.socials,
{ platform: 'facebook', href: 'javascript:alert(1)' },
]}
/>,
);
const links = screen.getAllByRole('link', {
name: /opent in nieuw tabblad/,
});
expect(links).toHaveLength(2);
expect(links[0]).toHaveAccessibleName(
'Facebook (opent in nieuw tabblad)',
);
expect(links[0]).toHaveAttribute('rel', 'noopener noreferrer');
expect(await axeResults(container)).toHaveNoViolations();
});
it('laadt eerst de eerste foto, daarna alleen de volgende en vorige', async () => {
const { container } = await renderWithProviders(
<Hero content={heroContent} socials={siteContent.socials} />,
);
const sources = () =>
[...container.querySelectorAll('img')].map((img) =>
img.getAttribute('src'),
);
const slide = (i: number) => heroContent.slides[i].src;
const last = heroContent.slides.length - 1;
expect(sources()).toEqual([slide(0)]);
fireEvent.load(container.querySelector('img')!);
// Vanaf de eerste foto is de vorige de laatste
await waitFor(() =>
expect(sources()).toEqual([slide(0), slide(1), slide(last)]),
);
await userEvent.click(
screen.getByRole('button', { name: 'Volgende foto' }),
);
expect(sources()).toEqual([slide(0), slide(1), slide(2)]);
});
it('heeft pijlen met een toegankelijke naam', async () => {
await renderWithProviders(
<Hero content={heroContent} socials={siteContent.socials} />,
);
expect(
screen.getByRole('button', { name: 'Vorige foto' }),
).toBeInTheDocument();
expect(
screen.getByRole('button', { name: 'Volgende foto' }),
).toBeInTheDocument();
});
});
+40 -18
View File
@@ -1,20 +1,35 @@
import { useState } from 'react';
import { Box, chakra, Container, Heading, Image } from '@chakra-ui/react';
import LinkButton from '../LinkButton';
import HeroArrows from './HeroArrows';
import HeroSocials from './HeroSocials';
import useHeroSlider from './useHeroSlider';
import type { HeroContent } from './types';
import type { HeroContent, SocialLink } from '@/content/types';
import { slidesToLoad } from '@/lib/slidesToLoad';
const SLIDE_DURATION = '6s';
type HeroProps = {
content: HeroContent;
socials: SocialLink[];
};
export default function Hero({ content }: HeroProps) {
const { title, tagline, cta, slides, socials } = content;
export default function Hero({ content, socials }: HeroProps) {
const { title, tagline, cta, slides } = content;
const { active, reducedMotion, autoplay, paused, next, prev, handlers } =
useHeroSlider(slides.length);
// De slides liggen op elkaar in beeld, dus loading="lazy" stelt niets uit.
// Eerst alleen de actieve foto; zodra die binnen en getekend is (twee
// frames later, dus na de eerste paint) ook de volgende en de vorige.
// Verder weg laden we pas als de slider in de buurt komt (BR-HERO-01).
const [firstPainted, setFirstPainted] = useState(false);
const onFirstLoaded = () =>
requestAnimationFrame(() =>
requestAnimationFrame(() => setFirstPainted(true)),
);
const loaded = firstPainted
? slidesToLoad(active, slides.length)
: [active];
return (
<Box
@@ -48,21 +63,28 @@ export default function Hero({ content }: HeroProps) {
transitionDuration="fade"
transitionTimingFunction="smooth"
>
<Image
src={slide.src}
alt={slide.alt}
fetchPriority={i === 0 ? 'high' : undefined}
loading={i === 0 ? undefined : 'lazy'}
w="100%"
h="100%"
objectFit="cover"
transform={
reducedMotion || i === active
? 'scale(1)'
: 'scale(1.06)'
}
transition="transform 9s linear"
/>
{loaded.includes(i) && (
<Image
src={slide.src}
alt={slide.alt}
fetchPriority={i === 0 ? 'high' : undefined}
onLoad={
firstPainted ? undefined : onFirstLoaded
}
onError={
firstPainted ? undefined : onFirstLoaded
}
w="100%"
h="100%"
objectFit="cover"
transform={
reducedMotion || i === active
? 'scale(1)'
: 'scale(1.06)'
}
transition="transform 9s linear"
/>
)}
</Box>
))}
</Box>
+17 -13
View File
@@ -1,4 +1,4 @@
import { chakra } from '@chakra-ui/react';
import { chakra, useRecipe } from '@chakra-ui/react';
import { Icon } from '@iconify/react/offline';
import leftOutlined from '@iconify-icons/ant-design/left-outlined';
import rightOutlined from '@iconify-icons/ant-design/right-outlined';
@@ -12,10 +12,20 @@ type HeroArrowsProps = {
export default function HeroArrows({ onPrev, onNext }: HeroArrowsProps) {
return (
<>
<ArrowButton side="left" aria-label="Vorige foto" onClick={onPrev}>
<ArrowButton
side="left"
aria-label="Vorige foto"
data-testid="hero-prev-button"
onClick={onPrev}
>
<Icon icon={leftOutlined} aria-hidden />
</ArrowButton>
<ArrowButton side="right" aria-label="Volgende foto" onClick={onNext}>
<ArrowButton
side="right"
aria-label="Volgende foto"
data-testid="hero-next-button"
onClick={onNext}
>
<Icon icon={rightOutlined} aria-hidden />
</ArrowButton>
</>
@@ -29,26 +39,20 @@ type ArrowButtonProps = React.ComponentProps<typeof chakra.button> & {
const ARROW_OFFSET = 'clamp(0.5rem, 3vw, 2.5rem)';
function ArrowButton({ side, ...props }: ArrowButtonProps) {
// Doorzichtigheid, hover en witte focusring komen uit de iconControl-recipe
const iconControl = useRecipe({ key: 'iconControl' });
return (
<chakra.button
type="button"
css={iconControl()}
position="absolute"
top="50%"
left={side === 'left' ? ARROW_OFFSET : undefined}
right={side === 'right' ? ARROW_OFFSET : undefined}
zIndex={2}
transform="translateY(-50%)"
display="flex"
p={2}
color="white"
fontSize={{ base: '1.5rem', md: '2rem' }}
cursor="pointer"
opacity={0.6}
transitionProperty="opacity"
transitionDuration="interaction"
transitionTimingFunction="smooth"
_hover={{ opacity: 1 }}
_focusVisible={{ opacity: 1, outline: '1px solid white', outlineOffset: '2px' }}
{...props}
/>
);
+24 -29
View File
@@ -1,48 +1,43 @@
import { chakra, HStack } from '@chakra-ui/react';
import { chakra, HStack, useRecipe } from '@chakra-ui/react';
import { Icon } from '@iconify/react/offline';
import socialPlatforms from './socialPlatforms';
import type { HeroSocial } from './types';
import socialPlatforms from '@/content/socialPlatforms';
import type { SocialLink } from '@/content/types';
import { visibleSocials } from '@/lib/visibleSocials';
type HeroSocialsProps = {
socials: HeroSocial[];
socials: SocialLink[];
};
// Socials linksonder, naast elkaar
export default function HeroSocials({ socials }: HeroSocialsProps) {
const iconControl = useRecipe({ key: 'iconControl' });
return (
<HStack
position="absolute"
left="gutter"
bottom={{ base: 6, md: 10 }}
zIndex={2}
gap={5}
color="white"
gap={2}
fontSize="1.5rem"
>
{socials
.filter((social) => social.href)
.map((social) => {
const { name, icon } = socialPlatforms[social.platform];
{visibleSocials(socials).map((social) => {
const { name, icon } = socialPlatforms[social.platform];
return (
<chakra.a
key={social.platform}
href={social.href}
target="_blank"
rel="noopener noreferrer"
aria-label={name}
display="flex"
opacity={0.6}
transitionProperty="opacity"
transitionDuration="interaction"
transitionTimingFunction="smooth"
_hover={{ opacity: 1 }}
_focusVisible={{ opacity: 1 }}
>
<Icon icon={icon} aria-hidden />
</chakra.a>
);
})}
return (
<chakra.a
key={social.platform}
href={social.href}
target="_blank"
rel="noopener noreferrer"
aria-label={`${name} (opent in nieuw tabblad)`}
data-testid={`hero-social-${social.platform}`}
css={iconControl()}
>
<Icon icon={icon} aria-hidden />
</chakra.a>
);
})}
</HStack>
);
}
-36
View File
@@ -1,36 +0,0 @@
import type { HeroContent } from './types';
// Images
import hero1 from '../../assets/hero-1.jpg';
import hero2 from '../../assets/hero-2.jpg';
import newborn from '../../assets/newborn.jpg';
import hero4 from '../../assets/hero-4.jpg';
import hero5 from '../../assets/hero-5.jpg';
import hero6 from '../../assets/hero-6.jpg';
// Statische content tot de CMS-API er is. Daarna komt dit object uit de API.
const heroContent: HeroContent = {
title: 'Andrea Slop',
tagline: 'Lifestyle fotograaf · Huizen',
cta: { label: 'Lees meer', to: '/over-mij' },
slides: [
{ id: 'hero-1', src: hero1, alt: 'Lifestyle fotografie van Andrea Slop' },
{ id: 'hero-2', src: hero2, alt: 'Zwangerschapsshoot in de buitenlucht' },
{ id: 'newborn', src: newborn, alt: 'Newbornshoot van een pasgeboren baby' },
{ id: 'hero-4', src: hero4, alt: 'Spontaan portret buiten' },
{ id: 'hero-5', src: hero5, alt: 'Natuurlijke lifestylefoto' },
{ id: 'hero-6', src: hero6, alt: 'Portret in de natuur' },
],
socials: [
{
platform: 'facebook',
href: 'https://www.facebook.com/andreaslopfotografie/',
},
{
platform: 'instagram',
href: 'https://www.instagram.com/andreaslopfotografie/',
},
],
};
export default heroContent;
@@ -1,13 +0,0 @@
import facebookFilled from '@iconify-icons/ant-design/facebook-filled';
import instagramFilled from '@iconify-icons/ant-design/instagram-filled';
// Vaste set ondersteunde platforms. De icon-data zit in de build, dus er gaat
// geen request naar de Iconify API. Het CMS levert alleen de links aan.
const socialPlatforms = {
facebook: { name: 'Facebook', icon: facebookFilled },
instagram: { name: 'Instagram', icon: instagramFilled },
};
export type SocialPlatform = keyof typeof socialPlatforms;
export default socialPlatforms;
-30
View File
@@ -1,30 +0,0 @@
import type { SocialPlatform } from './socialPlatforms';
// Vorm van de hero-content. Deze types zijn bewust platte data (strings en
// arrays) zodat ze later 1-op-1 uit de CMS-API kunnen komen.
export interface HeroSlide {
id: string;
src: string;
alt: string;
}
export interface HeroCta {
label: string;
to: string;
}
export interface HeroSocial {
platform: SocialPlatform;
href: string; // leeg = niet tonen
}
export interface HeroContent {
title: string;
// Klein label in hoofdletters boven de titel: wat en waar, voor bezoekers
// en zoekmachines (bv. "Lifestyle fotograaf · Huizen")
tagline: string;
cta: HeroCta;
slides: HeroSlide[];
socials: HeroSocial[];
}
+16 -5
View File
@@ -12,15 +12,22 @@ export default function useHeroSlider(count: number) {
const [hovered, setHovered] = useState(false);
const [focused, setFocused] = useState(false);
const [hidden, setHidden] = useState(() => document.hidden);
const [reducedMotion] = useMediaQuery(['(prefers-reduced-motion: reduce)'], {
ssr: false,
});
const [reducedMotion] = useMediaQuery(
['(prefers-reduced-motion: reduce)'],
{
ssr: false,
},
);
const touchStart = useRef<{ x: number; y: number } | null>(null);
useEffect(() => {
const onVisibilityChange = () => setHidden(document.hidden);
document.addEventListener('visibilitychange', onVisibilityChange);
return () => document.removeEventListener('visibilitychange', onVisibilityChange);
return () =>
document.removeEventListener(
'visibilitychange',
onVisibilityChange,
);
}, []);
// Als de API minder slides teruggeeft dan de huidige index, begin vooraan.
@@ -65,7 +72,11 @@ export default function useHeroSlider(count: number) {
const dy = touch.clientY - start.y;
// Horizontaal genoeg, en niet bedoeld als verticaal scrollen
if (Math.abs(dx) < SWIPE_THRESHOLD || Math.abs(dx) < Math.abs(dy)) return;
if (
Math.abs(dx) < SWIPE_THRESHOLD ||
Math.abs(dx) < Math.abs(dy)
)
return;
if (dx < 0) next();
else prev();
},