Adds the Over mij page

Replaces the placeholder with the page from the design and the texts from
the live site: Andrea's introduction with her portrait, how it started,
two photos, life outside photography and a booking button. The page is
now indexed, with its own title, description, preview image and AboutPage
data about Andrea.

The portrait loads straight away instead of after the page, since on
phones it is the largest paint. Lighthouse no longer lets every indexed
page use the homepage's lower mobile performance target; it now only
applies to the homepage itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-23 01:17:33 +02:00
co-authored by Claude Opus 5.5
parent 93993718c7
commit e15215393e
40 changed files with 1159 additions and 60 deletions
+14 -3
View File
@@ -6,9 +6,8 @@
const origin = 'http://localhost:4173';
// Moet gelijk lopen met src/sitePages.ts (een test bewaakt dat)
const indexedPaths = ['/'];
const indexedPaths = ['/', '/over-mij'];
const noindexPaths = [
'/over-mij',
'/portfolio',
'/soorten-fotoshoots',
'/contact',
@@ -68,9 +67,12 @@ module.exports = {
},
},
assert: {
// Home first: lighthouserc.desktop.cjs raises its performance
// target back to 0.9. Every URL matching an entry must pass it,
// so the home exception may only match the home page itself.
assertMatrix: [
{
matchingUrlPattern: exact(indexedPaths),
matchingUrlPattern: exact(['/']),
assertions: {
...quality,
'categories:performance': [
@@ -80,6 +82,15 @@ module.exports = {
'categories:seo': ['error', { minScore: 1 }],
},
},
{
matchingUrlPattern: exact(
indexedPaths.filter((path) => path !== '/'),
),
assertions: {
...quality,
'categories:seo': ['error', { minScore: 1 }],
},
},
{
matchingUrlPattern: exact(noindexPaths),
assertions: {
Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

+38
View File
@@ -125,6 +125,44 @@ describe('app', () => {
);
});
it('shows the about page with its outline, links and structured data', async () => {
const { container } = await renderApp('/over-mij');
await screen.findByRole('heading', { level: 1, name: 'Over mij' });
// The page's own outline; the footer adds its own column headings
expect(
within(screen.getByRole('main'))
.getAllByRole('heading')
.map((h) => `${h.tagName} ${h.textContent}`),
).toEqual([
'H1 Over mij',
'H2 Hoi! Ik ben Andrea',
'H3 Hoe het begon',
'H3 Buiten de camera om',
]);
expect(
screen.getByRole('link', { name: 'mijn portfolio' }),
).toHaveAttribute('href', '/portfolio');
expect(
screen.getByRole('link', { name: 'neem contact op' }),
).toHaveAttribute('href', '/#contact');
expect(
screen.getByRole('link', { name: 'Boek je shoot' }),
).toHaveAttribute('href', '/#contact');
expect(
screen.getByRole('list', { name: "Foto's" }),
).toBeInTheDocument();
expect(document.title).toBe(
'Over mij – fotograaf in Huizen | Andrea Slop Fotografie',
);
expect(document.head.querySelector('meta[name="robots"]')).toBeNull();
const types = [
...document.querySelectorAll('script[type="application/ld+json"]'),
].map((script) => JSON.parse(script.textContent!)['@type']);
expect(types.sort()).toEqual(['AboutPage', 'ProfessionalService']);
expect(await axeResults(container)).toHaveNoViolations();
});
it('toont een onbekende URL als 404 binnen de shell', async () => {
const { container } = await renderApp('/bestaat-niet');
expect(
Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

@@ -24,4 +24,15 @@ describe('FramedImage', () => {
expect(img).toHaveAttribute('loading', 'lazy');
expect(await axeResults(container)).toHaveNoViolations();
});
it('loads a priority photo straight away, not lazily', async () => {
await renderWithProviders(
<FramedImage image={image} aspectRatio="4 / 3" priority />,
);
const img = screen.getByRole('img');
expect(img).toHaveAttribute('src', '/andrea.jpg');
expect(img).not.toHaveAttribute('loading', 'lazy');
expect(img).toHaveAttribute('fetchpriority', 'high');
expect(img).toHaveAttribute('width', '1200');
});
});
+32 -12
View File
@@ -1,4 +1,4 @@
import { Box } from '@chakra-ui/react';
import { Box, Image, type ImageProps } from '@chakra-ui/react';
import DeferredImage from '@/components/DeferredImage/DeferredImage';
import type { ContentImage } from '@/content/types';
@@ -6,13 +6,30 @@ type FramedImageProps = {
image: ContentImage;
// CSS aspect ratio of the visible crop, e.g. '4 / 3'
aspectRatio: string;
// For a photo at the top of a page, likely the largest paint: load it
// straight away with high priority instead of after the page has loaded
priority?: boolean;
};
// A photo with a soft sand-coloured block offset behind its lower left
// corner (design .about__media). The block is pure decoration (a CSS
// pseudo-element), so assistive technology never announces it. On phones it
// is left out, since it would stick out past the page edge.
export default function FramedImage({ image, aspectRatio }: FramedImageProps) {
export default function FramedImage({
image,
aspectRatio,
priority = false,
}: FramedImageProps) {
const style: ImageProps = {
display: 'block',
w: '100%',
h: 'auto',
aspectRatio,
objectFit: 'cover',
// Shown until the photo arrives
bg: 'paper.deep',
};
return (
<Box
position="relative"
@@ -30,16 +47,19 @@ export default function FramedImage({ image, aspectRatio }: FramedImageProps) {
zIndex: -1,
}}
>
<DeferredImage
image={image}
display="block"
w="100%"
h="auto"
aspectRatio={aspectRatio}
objectFit="cover"
// Shown until the deferred photo arrives
bg="paper.deep"
/>
{priority ? (
<Image
src={image.src}
alt={image.alt}
htmlWidth={image.width}
htmlHeight={image.height}
fetchPriority="high"
decoding="async"
{...style}
/>
) : (
<DeferredImage image={image} {...style} />
)}
</Box>
);
}
+8 -1
View File
@@ -8,6 +8,8 @@ type MediaTextProps = {
image: ContentImage;
// CSS aspect ratio of the visible crop, e.g. '4 / 3'
aspectRatio: string;
// The photo is at the top of the page and should not wait (FramedImage)
priority?: boolean;
'data-testid'?: string;
// The text column; each page fills in its own heading and text
children: ReactNode;
@@ -19,6 +21,7 @@ type MediaTextProps = {
export default function MediaText({
image,
aspectRatio,
priority,
'data-testid': testId,
children,
}: MediaTextProps) {
@@ -30,7 +33,11 @@ export default function MediaText({
data-testid={testId}
>
<Reveal>
<FramedImage image={image} aspectRatio={aspectRatio} />
<FramedImage
image={image}
aspectRatio={aspectRatio}
priority={priority}
/>
</Reveal>
<Reveal>{children}</Reveal>
</Grid>
@@ -57,6 +57,17 @@ describe('PageSection', () => {
expect(regular.paddingTop).not.toBe('0px');
});
it('is no landmark without a heading to name it', async () => {
const { container } = await renderWithProviders(
<PageSection data-testid="photos">
<p>Foto's</p>
</PageSection>,
);
expect(screen.getByTestId('photos').tagName).toBe('SECTION');
expect(screen.queryByRole('region')).not.toBeInTheDocument();
expect(await axeResults(container)).toHaveNoViolations();
});
it('leaves out the content column at full width', async () => {
await renderWithProviders(
<PageSection labelledBy="insta-title" width="full">
@@ -2,8 +2,9 @@ import type { ReactNode } from 'react';
import { Box, Container } from '@chakra-ui/react';
type PageSectionProps = {
// Id of the heading that names this section for assistive technology
labelledBy: string;
// Id of the heading that names this section for assistive technology.
// Without it (a block without a heading) the section is no landmark.
labelledBy?: string;
id?: string;
tone?: 'paper' | 'alt';
// full: no content column, for edge-to-edge content; the section then
@@ -0,0 +1,32 @@
import { screen, within } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import type { ContentImage } from '@/content/types';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import PhotoDuo from './PhotoDuo';
const photos: [ContentImage, ContentImage] = [
{
src: '/concert.jpg',
alt: 'Concert vanaf het podium',
width: 1200,
height: 798,
},
{ src: '/kat.jpg', alt: 'Slapende grijze kat', width: 1200, height: 800 },
];
describe('PhotoDuo', () => {
it('shows both photos in a named list', async () => {
const { container } = await renderWithProviders(
<PhotoDuo photos={photos} label="Foto's" />,
);
const list = screen.getByRole('list', { name: "Foto's" });
const images = within(list).getAllByRole('img');
expect(images).toHaveLength(2);
expect(images[0]).toHaveAccessibleName('Concert vanaf het podium');
expect(images[1]).toHaveAccessibleName('Slapende grijze kat');
expect(images[0]).toHaveAttribute('width', '1200');
expect(images[0]).toHaveAttribute('height', '798');
expect(await axeResults(container)).toHaveNoViolations();
});
});
+59
View File
@@ -0,0 +1,59 @@
import { chakra } from '@chakra-ui/react';
import DeferredImage from '@/components/DeferredImage/DeferredImage';
import Reveal from '@/components/Reveal/Reveal';
import type { ContentImage } from '@/content/types';
type PhotoDuoProps = {
photos: [ContentImage, ContentImage];
// Accessible name of the photo list, e.g. "Foto's"
label: string;
'data-testid'?: string;
};
// Two landscape photos side by side (design .intro-gallery--duo), one below
// the other on phones. Each zooms in gently on hover, as in the homepage
// gallery, except with reduced motion.
export default function PhotoDuo({
photos,
label,
'data-testid': testId,
}: PhotoDuoProps) {
return (
<Reveal>
<chakra.ul
listStyleType="none"
aria-label={label}
data-testid={testId}
display="grid"
gridTemplateColumns={{ base: '1fr', sm: 'repeat(2, 1fr)' }}
gap="gridGap"
>
{photos.map((photo) => (
<chakra.li key={photo.src}>
<chakra.figure
overflow="hidden"
// Shown until the deferred photo arrives
bg="paper.deep"
css={{
'&:hover img': { transform: 'scale(1.05)' },
}}
>
<DeferredImage
image={photo}
display="block"
w="100%"
h="auto"
aspectRatio="3 / 2"
objectFit="cover"
transitionProperty="transform"
transitionDuration="fade"
transitionTimingFunction="smooth"
_motionReduce={{ transition: 'none' }}
/>
</chakra.figure>
</chakra.li>
))}
</chakra.ul>
</Reveal>
);
}
@@ -0,0 +1,34 @@
import { screen, within } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import aboutContent from '@/content/aboutContent';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import AboutIntro from './AboutIntro';
const intro = aboutContent.intro;
describe('AboutIntro', () => {
it('shows the label, heading, text, portrait and links', async () => {
const { container } = await renderWithProviders(
<AboutIntro content={intro} />,
);
const section = screen.getByRole('region', { name: intro.title });
expect(
within(section).getByRole('heading', { level: 2 }),
).toHaveTextContent(intro.title);
expect(within(section).getByText(intro.eyebrow)).toBeInTheDocument();
expect(within(section).getByRole('img')).toHaveAccessibleName(
intro.image.alt,
);
expect(section).toHaveTextContent(
'Bekijk mijn portfolio of neem contact op voor een fotoshoot!',
);
expect(
within(section).getByRole('link', { name: 'mijn portfolio' }),
).toHaveAttribute('href', '/portfolio');
expect(
within(section).getByRole('link', { name: 'neem contact op' }),
).toHaveAttribute('href', '/#contact');
expect(await axeResults(container)).toHaveNoViolations();
});
});
@@ -0,0 +1,41 @@
import { Stack } from '@chakra-ui/react';
import RichParagraph from '@/components/about/RichParagraph/RichParagraph';
import MediaText from '@/components/MediaText/MediaText';
import PageSection from '@/components/PageSection/PageSection';
import SectionHeading from '@/components/SectionHeading/SectionHeading';
import type { AboutPageContent } from '@/content/types';
const TITLE_ID = 'about-intro-title';
type AboutIntroProps = {
content: AboutPageContent['intro'];
};
// "Hoi! Ik ben Andrea": the framed portrait next to the introduction, right
// below the page head (design .about in a .section--flush-top)
export default function AboutIntro({ content }: AboutIntroProps) {
return (
<PageSection
labelledBy={TITLE_ID}
spacing="flushTop"
data-testid="about-intro"
>
{/* Right below the page head: on phones the portrait is the
largest paint, so it must not wait for the page to load */}
<MediaText image={content.image} aspectRatio="4 / 3" priority>
<SectionHeading
id={TITLE_ID}
eyebrow={content.eyebrow}
title={content.title}
align="start"
spacing="compact"
/>
<Stack gap={4} color="ink.soft">
{content.paragraphs.map((paragraph, index) => (
<RichParagraph key={index} paragraph={paragraph} />
))}
</Stack>
</MediaText>
</PageSection>
);
}
@@ -0,0 +1,37 @@
import { screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import RichParagraph from './RichParagraph';
describe('RichParagraph', () => {
it('renders text and links in reading order', async () => {
const { container } = await renderWithProviders(
<RichParagraph
paragraph={[
'Bekijk ',
{ text: 'mijn portfolio', to: '/portfolio' },
' of ',
{ text: 'neem contact op', to: '/', hash: 'contact' },
'!',
]}
/>,
);
expect(container).toHaveTextContent(
'Bekijk mijn portfolio of neem contact op!',
);
expect(
screen.getByRole('link', { name: 'mijn portfolio' }),
).toHaveAttribute('href', '/portfolio');
expect(
screen.getByRole('link', { name: 'neem contact op' }),
).toHaveAttribute('href', '/#contact');
expect(await axeResults(container)).toHaveNoViolations();
});
it('renders a paragraph without links as plain text', async () => {
await renderWithProviders(<RichParagraph paragraph={['Hoi!']} />);
expect(screen.getByText('Hoi!')).toBeInTheDocument();
expect(screen.queryByRole('link')).not.toBeInTheDocument();
});
});
@@ -0,0 +1,29 @@
import { Link, Text } from '@chakra-ui/react';
import RouterLink from '@/components/RouterLink';
import type { RichText } from '@/content/types';
type RichParagraphProps = {
paragraph: RichText;
};
// One paragraph of running text with links in it (BR-OM-03): text pieces as
// they are, link pieces as underlined router links.
export default function RichParagraph({ paragraph }: RichParagraphProps) {
return (
<Text>
{paragraph.map((piece, index) =>
typeof piece === 'string' ? (
piece
) : (
// Static content: the order never changes, so the index
// is a stable key
<Link key={index} variant="underline" asChild>
<RouterLink to={piece.to} hash={piece.hash}>
{piece.text}
</RouterLink>
</Link>
),
)}
</Text>
);
}
@@ -0,0 +1,44 @@
import { screen, within } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import aboutContent from '@/content/aboutContent';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import StorySection from './StorySection';
const personal = aboutContent.personal;
describe('StorySection', () => {
it('is a region named by its h3 label, with the text', async () => {
const { container } = await renderWithProviders(
// An h2 above it, as on the page, so the outline is complete
<>
<h2>Hoi! Ik ben Andrea</h2>
<StorySection
content={personal}
titleId="personal-title"
tone="alt"
/>
</>,
);
const section = screen.getByRole('region', { name: personal.title });
expect(
within(section).getByRole('heading', { level: 3 }),
).toHaveAttribute('id', 'personal-title');
personal.paragraphs.forEach((paragraph) =>
expect(within(section).getByText(paragraph)).toBeInTheDocument(),
);
expect(await axeResults(container)).toHaveNoViolations();
});
it('shows extra content below the text', async () => {
await renderWithProviders(
<StorySection content={personal} titleId="personal-title">
<a href="/#contact">Boek je shoot</a>
</StorySection>,
);
const section = screen.getByRole('region', { name: personal.title });
expect(
within(section).getByRole('link', { name: 'Boek je shoot' }),
).toBeInTheDocument();
});
});
@@ -0,0 +1,53 @@
import type { ReactNode } from 'react';
import { Box, Stack, Text } from '@chakra-ui/react';
import Eyebrow from '@/components/Eyebrow/Eyebrow';
import PageSection from '@/components/PageSection/PageSection';
import Reveal from '@/components/Reveal/Reveal';
import type { AboutPageContent } from '@/content/types';
type StorySectionProps = {
content: AboutPageContent['background'];
// Id of the h3, which names the section
titleId: string;
tone?: 'paper' | 'alt';
spacing?: 'default' | 'flushTop';
'data-testid'?: string;
// Shown below the text, e.g. the booking button
children?: ReactNode;
};
// One part of Andrea's story in the narrow column. Its heading is an h3 in
// the small label style: the story continues "Hoi! Ik ben Andrea" (FR-OM-03).
export default function StorySection({
content,
titleId,
tone,
spacing,
'data-testid': testId,
children,
}: StorySectionProps) {
return (
<PageSection
labelledBy={titleId}
width="narrow"
tone={tone}
spacing={spacing}
data-testid={testId}
>
<Reveal>
<Eyebrow as="h3" id={titleId}>
{content.title}
</Eyebrow>
<Stack gap={4} color="ink.soft">
{content.paragraphs.map((paragraph) => (
<Text key={paragraph}>{paragraph}</Text>
))}
</Stack>
{/* design .mt-lg */}
{children && (
<Box mt="clamp(2rem, 4vw, 2.5rem)">{children}</Box>
)}
</Reveal>
</PageSection>
);
}
+80
View File
@@ -0,0 +1,80 @@
import type { AboutPageContent } from './types';
// Images
import portrait from '../assets/about/andrea-portret.jpg';
import concert from '../assets/about/about-1.jpg';
import cat from '../assets/about/about-2.jpg';
// Static content of the about page until the CMS API exists; texts from the
// live site, structure from the design (FR-OM-01..05).
const aboutContent: AboutPageContent = {
head: {
eyebrow: 'Andrea Slop Fotografie',
title: 'Over mij',
},
intro: {
eyebrow: 'Lifestyle fotograaf',
title: 'Hoi! Ik ben Andrea',
paragraphs: [
[
'Hoi! Ik ben Andrea, een fotograaf met liefde voor het vastleggen van momenten. Momenten die je voor altijd bewaart.',
],
[
"Mijn stijl is te omschrijven als warm en spontaan. Ik houd van natuurlijke, ongedwongen foto's die een verhaal vertellen.",
],
[
'Nieuwsgierig naar mijn werk? Bekijk ',
{ text: 'mijn portfolio', to: '/portfolio' },
' of ',
// The homepage contact section until /contact exists
{ text: 'neem contact op', to: '/', hash: 'contact' },
' voor een fotoshoot!',
],
],
image: {
src: portrait,
alt: 'Andrea Slop in een groene trui met haar camera in de handen, glimlachend in het bos',
width: 1200,
height: 800,
},
},
background: {
title: 'Hoe het begon',
paragraphs: [
"Tijdens de studie Communicatie & Media Design kon ik mijn creativiteit kwijt in verschillende vormen. Fotografie was mijn favoriet. De keuze voor de minor Fotojournalistiek was dan ook snel gemaakt. Tijdens de studie werd mijn liefde voor fotografie alleen maar groter. Waar ik voorheen altijd foto's in mijn vrije tijd maakte, ging ik tijdens de minor op pad voor verschillende opdrachten. Tijdens het fotograferen van een concert voelde ik me meteen op mijn plek. De hele zaal door met mijn camera. Ik was helemaal in mijn element. Het was even een zoektocht maar uiteindelijk heb ik mijn specialisatie gevonden. Je kunt bij mij terecht voor newbornshoots, zwangerschapsshoots en gezinsshoots.",
],
},
photos: [
{
src: concert,
alt: 'Concert vanaf het podium: de zanger steekt zijn microfoon omhoog voor een volle zaal in blauw licht',
width: 1200,
height: 798,
},
{
src: cat,
alt: 'Een grijze langharige kat slaapt met een uitgestrekte poot op de bank',
width: 1200,
height: 800,
},
],
personal: {
title: 'Buiten de camera om',
paragraphs: [
'Mijn camera gaat altijd mee op reis. Het liefst ga ik naar een plek met een mooie zee maar ik ga ook graag op pad om de natuur vast te leggen met mijn camera.',
'Wanneer ik niet achter de camera sta ben ik bezig met tekenen, schilderen of lezen.',
],
},
booking: { label: 'Boek je shoot', to: '/', hash: 'contact' },
person: {
name: 'Andrea Slop',
jobTitle: 'Lifestyle fotograaf',
knowsAbout: [
'Newbornfotografie',
'Zwangerschapsfotografie',
'Gezinsfotografie',
],
},
};
export default aboutContent;
+30
View File
@@ -88,6 +88,36 @@ export interface HomeContent {
};
}
// Where a link goes: a route (a typo is a type error) and optionally an
// anchor on that page, without the '#'
export interface LinkTarget {
to: RoutePath;
hash?: string;
}
export type InlineLink = LinkTarget & { text: string };
// A paragraph as text pieces and links in reading order, so the API can
// deliver links inside running text without HTML. Spaces belong to the text.
export type RichText = (string | InlineLink)[];
// Content of the about page (/over-mij)
export interface AboutPageContent {
head: { eyebrow: string; title: string };
intro: {
eyebrow: string;
title: string;
paragraphs: RichText[];
image: ContentImage;
};
background: { title: string; paragraphs: string[] };
photos: [ContentImage, ContentImage];
personal: { title: string; paragraphs: string[] };
booking: LinkTarget & { label: string };
// For the structured data about Andrea; summarises what the page says
person: { name: string; jobTitle: string; knowsAbout: string[] };
}
export interface HeroSlide {
id: string;
src: string;
+48
View File
@@ -0,0 +1,48 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { knowsAboutEntries } from '@/test/arbitraries';
import { knowsAboutList } from './knowsAboutList';
describe('knowsAboutList', () => {
it('trims, drops empty entries and duplicates, keeps the first one', () => {
expect(
knowsAboutList([
' Newbornfotografie ',
'',
' ',
'Gezinsfotografie',
'Newbornfotografie',
]),
).toEqual(['Newbornfotografie', 'Gezinsfotografie']);
});
it('only keeps trimmed, non-empty, unique input entries (invariant)', () => {
fc.assert(
fc.property(knowsAboutEntries, (entries) => {
const out = knowsAboutList(entries);
const trimmed = entries.map((entry) => entry.trim());
expect(out.every((entry) => entry !== '')).toBe(true);
expect(out.every((entry) => trimmed.includes(entry))).toBe(
true,
);
expect(new Set(out).size).toBe(out.length);
// Every non-empty input entry survives, in first-seen order
expect(out).toEqual(
trimmed.filter(
(entry, index) =>
entry !== '' && trimmed.indexOf(entry) === index,
),
);
}),
);
});
it('changes nothing the second time (idempotency)', () => {
fc.assert(
fc.property(knowsAboutEntries, (entries) => {
const once = knowsAboutList(entries);
expect(knowsAboutList(once)).toEqual(once);
}),
);
});
});
+6
View File
@@ -0,0 +1,6 @@
// The specialisations for the structured data (BR-SD-05): trimmed, without
// empty entries or duplicates, in the order the CMS delivers them.
export function knowsAboutList(entries: readonly string[]): string[] {
const trimmed = entries.map((entry) => entry.trim()).filter(Boolean);
return [...new Set(trimmed)];
}
+52 -6
View File
@@ -1,17 +1,63 @@
import { createFileRoute } from '@tanstack/react-router';
import AboutIntro from '../components/about/AboutIntro/AboutIntro';
import StorySection from '../components/about/StorySection/StorySection';
import LinkButton from '../components/LinkButton';
import PageIntro from '../components/PageIntro/PageIntro';
import { pageHead } from '../seo';
import PageSection from '../components/PageSection/PageSection';
import PhotoDuo from '../components/PhotoDuo/PhotoDuo';
import aboutContent from '../content/aboutContent';
import siteContent from '../content/siteContent';
import { aboutPage, pageHead, structuredDataScript } from '../seo';
export const Route = createFileRoute('/over-mij')({
head: () => pageHead('/over-mij'),
head: () => ({
...pageHead('/over-mij'),
scripts: [
structuredDataScript(
aboutPage('/over-mij', aboutContent.person, siteContent),
),
],
}),
component: About,
});
// Placeholder tot de echte pagina er is (noindex via sitePages)
// The about page: who Andrea is, how it started, two photos and what she
// does besides photography, in the order of LAYOUT.md
function About() {
const { head, intro, background, photos, personal, booking } = aboutContent;
return (
<PageIntro eyebrow="Andrea Slop Fotografie" title="Over mij">
Deze pagina is nog in de maak. Kom snel terug!
</PageIntro>
<>
<PageIntro eyebrow={head.eyebrow} title={head.title} />
<AboutIntro content={intro} />
<StorySection
content={background}
titleId="about-background-title"
tone="alt"
data-testid="about-background"
/>
{/* No heading in the design, so no named region (BR-OM-11) */}
<PageSection>
<PhotoDuo
photos={photos}
label="Foto's"
data-testid="about-photos"
/>
</PageSection>
<StorySection
content={personal}
titleId="about-personal-title"
spacing="flushTop"
data-testid="about-personal"
>
<LinkButton
variant="accent"
to={booking.to}
hash={booking.hash}
data-testid="about-booking-link"
>
{booking.label}
</LinkButton>
</StorySection>
</>
);
}
+157 -1
View File
@@ -1,15 +1,28 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import aboutContent from './content/aboutContent';
import siteContent from './content/siteContent';
import { emailAddress } from './lib/emailAddress';
import { visibleSocials } from './lib/visibleSocials';
import {
aboutPage,
businessId,
canonicalUrl,
jsonLdScript,
pageHead,
person,
personId,
professionalService,
siteHead,
siteUrl,
structuredDataScript,
} from './seo';
import { routePath } from './test/arbitraries';
import sitePages from './sitePages';
import {
anySiteContent,
knowsAboutEntries,
routePath,
} from './test/arbitraries';
const meta = (head: ReturnType<typeof pageHead>, key: string) =>
head.meta.find(
@@ -122,3 +135,146 @@ describe('professionalService en siteHead', () => {
);
});
});
describe('pageHead for the about page', () => {
it('is indexed, with its own title, description and preview image', () => {
const head = pageHead('/over-mij');
expect(head.meta[0]).toEqual({
title: 'Over mij – fotograaf in Huizen | Andrea Slop Fotografie',
});
expect(meta(head, 'robots')).toBeUndefined();
expect(meta(head, 'description')).toMatchObject({
content: sitePages['/over-mij'].description,
});
expect(meta(head, 'og:image')).toMatchObject({
content: `${siteUrl}/og-over-mij.jpg`,
});
expect(head.links[0].href).toBe(`${siteUrl}/over-mij`);
});
it('keeps title and description within what search engines show', () => {
const page = sitePages['/over-mij'];
expect(
`${page.title} | Andrea Slop Fotografie`.length,
).toBeLessThanOrEqual(60);
expect(page.description.length).toBeLessThanOrEqual(155);
});
});
describe('structured data about Andrea', () => {
const image = `${siteUrl}/og-over-mij.jpg`;
it('describes Andrea from the page content and the site socials', () => {
expect(person(aboutContent.person, siteContent, image)).toEqual({
'@type': 'Person',
'@id': personId,
name: 'Andrea Slop',
jobTitle: 'Lifestyle fotograaf',
image,
address: {
'@type': 'PostalAddress',
addressLocality: 'Huizen',
addressCountry: 'NL',
},
url: `${siteUrl}/over-mij`,
worksFor: { '@id': businessId },
knowsAbout: [
'Newbornfotografie',
'Zwangerschapsfotografie',
'Gezinsfotografie',
],
sameAs: siteContent.socials.map((social) => social.href),
});
});
it('leaves out empty lists instead of writing them', () => {
const data = person(
{ ...aboutContent.person, knowsAbout: [' ', ''] },
{ ...siteContent, socials: [] },
image,
);
expect(data).not.toHaveProperty('knowsAbout');
expect(data).not.toHaveProperty('sameAs');
});
it('links Andrea and the business both ways (invariant)', () => {
fc.assert(
fc.property(anySiteContent, (site) => {
const business = professionalService(site);
const andrea = person(aboutContent.person, site, image);
expect(business['@id']).toBe(businessId);
expect(business.founder['@id']).toBe(andrea['@id']);
expect(andrea.worksFor['@id']).toBe(business['@id']);
}),
);
});
it('lists exactly the valid https socials in sameAs (invariant)', () => {
fc.assert(
fc.property(anySiteContent, (site) => {
const valid = visibleSocials(site.socials).map((s) => s.href);
const andrea = person(aboutContent.person, site, image);
expect(andrea.sameAs ?? []).toEqual(valid);
}),
);
});
it('lists the cleaned specialisations in knowsAbout (invariant)', () => {
fc.assert(
fc.property(knowsAboutEntries, (entries) => {
const andrea = person(
{ ...aboutContent.person, knowsAbout: entries },
siteContent,
image,
);
const list = andrea.knowsAbout ?? [];
expect(
list.every(
(entry) => entry === entry.trim() && entry !== '',
),
).toBe(true);
expect(new Set(list).size).toBe(list.length);
}),
);
});
it('never contains the e-mail address, on any page (invariant)', () => {
fc.assert(
fc.property(anySiteContent, (site) => {
const address = emailAddress(site.email);
const out =
jsonLdScript(
aboutPage('/over-mij', aboutContent.person, site),
) + jsonLdScript(professionalService(site));
return address === null || !out.includes(address);
}),
);
});
it('matches the page registry and canonical URL (invariant)', () => {
fc.assert(
fc.property(anySiteContent, (site) => {
const page = aboutPage('/over-mij', aboutContent.person, site);
expect(page['@id']).toBe(canonicalUrl('/over-mij'));
expect(page.url).toBe(canonicalUrl('/over-mij'));
expect(page.name).toBe(sitePages['/over-mij'].title);
expect(page.description).toBe(
sitePages['/over-mij'].description,
);
expect(page.mainEntity.image).toBe(image);
}),
);
});
it('falls back to the site preview image for a page without its own', () => {
const page = aboutPage('/portfolio', aboutContent.person, siteContent);
expect(page.mainEntity.image).toBe(`${siteUrl}/og-image.jpg`);
});
it('wraps data in an escaped ld+json script tag', () => {
const script = structuredDataScript({ name: '</script>' });
expect(script.type).toBe('application/ld+json');
expect(script.children).not.toMatch(/[<>]/);
expect(JSON.parse(script.children)).toEqual({ name: '</script>' });
});
});
+69 -12
View File
@@ -1,6 +1,7 @@
// SEO: head-tags per pagina en voor de hele site, plus gestructureerde data.
// Titels en beschrijvingen staan in het pagina-register (sitePages.ts).
import type { SiteContent } from './content/types.ts';
import type { AboutPageContent, SiteContent } from './content/types.ts';
import { knowsAboutList } from './lib/knowsAboutList.ts';
import { visibleSocials } from './lib/visibleSocials.ts';
import type { RoutePath } from './navigation.ts';
import sitePages from './sitePages.ts';
@@ -61,24 +62,85 @@ export function jsonLdScript(data: unknown): string {
.replace(/&/g, '\\u0026');
}
// Stable ids, so the business on every page and Andrea on the about page
// refer to each other (BR-SD-03)
export const businessId = `${siteUrl}/#business`;
export const personId = `${siteUrl}/over-mij#andrea`;
const huizen = {
'@type': 'PostalAddress',
addressLocality: 'Huizen',
addressCountry: 'NL',
} as const;
// Gestructureerde data: een lokale fotograaf in Huizen. Bewust zonder
// e-mailadres, anders staat het alsnog leesbaar in de pagina.
export function professionalService(content: SiteContent) {
return {
'@context': 'https://schema.org',
'@type': 'ProfessionalService',
'@id': businessId,
name: siteName,
url: `${siteUrl}/`,
logo: `${siteUrl}/logo.png`,
image: siteUrl + defaultOgImage.path,
description: sitePages['/'].description,
address: {
'@type': 'PostalAddress',
addressLocality: 'Huizen',
addressCountry: 'NL',
},
address: huizen,
areaServed: { '@type': 'Place', name: 'Huizen' },
sameAs: visibleSocials(content.socials).map((social) => social.href),
founder: { '@id': personId },
};
}
// Andrea as a person (BR-SD-01..05). Optional lists are left out when empty;
// no e-mail address, for the same reason as above.
export function person(
content: AboutPageContent['person'],
site: SiteContent,
image: string,
) {
const sameAs = visibleSocials(site.socials).map((social) => social.href);
const knowsAbout = knowsAboutList(content.knowsAbout);
return {
'@type': 'Person',
'@id': personId,
name: content.name,
jobTitle: content.jobTitle,
image,
address: huizen,
url: canonicalUrl('/over-mij'),
worksFor: { '@id': businessId },
...(knowsAbout.length > 0 ? { knowsAbout } : {}),
...(sameAs.length > 0 ? { sameAs } : {}),
};
}
// The about page with Andrea as its subject (BR-SD-06); name, description
// and preview image come from the page registry
export function aboutPage(
path: RoutePath,
content: AboutPageContent['person'],
site: SiteContent,
) {
const page = sitePages[path];
const image = siteUrl + (page.ogImage ?? defaultOgImage).path;
return {
'@context': 'https://schema.org',
'@type': 'AboutPage',
'@id': canonicalUrl(path),
url: canonicalUrl(path),
name: page.title,
description: page.description,
inLanguage: 'nl-NL',
mainEntity: person(content, site, image),
};
}
// A head script tag with structured data, escaped by jsonLdScript (BR-SD-07)
export function structuredDataScript(data: unknown) {
return {
type: 'application/ld+json',
children: jsonLdScript(data),
};
}
@@ -91,11 +153,6 @@ export function siteHead(content: SiteContent) {
{ property: 'og:type', content: 'website' },
{ name: 'twitter:card', content: 'summary_large_image' },
],
scripts: [
{
type: 'application/ld+json',
children: jsonLdScript(professionalService(content)),
},
],
scripts: [structuredDataScript(professionalService(content))],
};
}
+9 -3
View File
@@ -26,10 +26,16 @@ const sitePages: Record<RoutePath, PageMeta> = {
indexed: true,
},
'/over-mij': {
title: 'Over mij',
title: 'Over mij – fotograaf in Huizen',
description:
'Hi! Ik ben Andrea, lifestyle fotograaf uit Huizen. Ik leg jullie vast zoals jullie zijn: spontaan en natuurlijk, zonder ongemakkelijke poses.',
indexed: false,
"Hoi! Ik ben Andrea, lifestyle fotograaf uit Huizen. Ik maak warme, spontane foto's die een verhaal vertellen: newborn-, zwangerschaps- en gezinsshoots.",
indexed: true,
ogImage: {
path: '/og-over-mij.jpg',
width: 1200,
height: 630,
alt: 'Andrea Slop met haar camera in het bos',
},
},
'/portfolio': {
title: 'Portfolio',
+2 -1
View File
@@ -17,9 +17,10 @@ const locs = (xml: string) => {
const page = fc.record({ path: routePath, indexed: fc.boolean() });
describe('sitemapXml', () => {
it('bevat nu alleen de homepage', () => {
it('contains the homepage and the about page', () => {
expect(locs(sitemapXml(pageList(sitePages), base))).toEqual([
`${base}/`,
`${base}/over-mij`,
]);
});
+26
View File
@@ -4,6 +4,7 @@ import type { ContactFormEvent } from '../lib/contactFormReducer';
import type {
EmailAddress,
PricingPackage,
SiteContent,
SocialLink,
Testimonial,
} from '../content/types';
@@ -55,6 +56,31 @@ export const anyEmail: fc.Arbitrary<EmailAddress> = fc.oneof(
fc.record({ user: fc.string(), domain: fc.string() }),
);
// Site-wide content as the CMS could deliver it; a valid e-mail address, so
// tests can check it never leaks into output
export const anySiteContent: fc.Arbitrary<SiteContent> = fc.record({
footerIntro: fc.string(),
socials: fc.array(socialLink, { maxLength: 4 }),
email: validEmail,
contactForm: fc.record({ enabled: fc.boolean() }),
});
// Specialisations with padding, blanks and repeats, as an editor might type
const specialisation = fc.oneof(
fc.constantFrom('Newbornfotografie', 'Gezinsfotografie', '', ' '),
fc.string({ maxLength: 20 }),
);
export const knowsAboutEntries = fc.array(
fc
.tuple(
fc.constantFrom('', ' ', ' '),
specialisation,
fc.constantFrom('', ' '),
)
.map(([before, text, after]) => before + text + after),
{ maxLength: 8 },
);
// Package ids: a few fixed ones so lists contain duplicates, plus random slugs
const packageId = fc.oneof(
fc.constantFrom('newborn', 'gezin', 'zwangerschap'),