From befe97af1e4e02a89fc634b2833ec27306e9db83 Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Sat, 24 Oct 2026 23:40:24 +0200 Subject: [PATCH] Shares the service area in the structured data The business's areaServed now comes from a serviceArea list in the site content: Huizen and Gooi en Vechtstreek, as the pages describe it, instead of a fixed Place Huizen. Services on other pages can use the same list through areaServed(). Co-Authored-By: Claude Opus 5.5 --- web/src/content/siteContent.ts | 6 ++++++ web/src/content/types.ts | 10 ++++++++++ web/src/seo.test.ts | 36 ++++++++++++++++++++++++++++++++++ web/src/seo.ts | 17 ++++++++++++++-- web/src/test/arbitraries.ts | 20 +++++++++++++++++++ 5 files changed, 87 insertions(+), 2 deletions(-) diff --git a/web/src/content/siteContent.ts b/web/src/content/siteContent.ts index 1e17fe2..96e5382 100644 --- a/web/src/content/siteContent.ts +++ b/web/src/content/siteContent.ts @@ -18,6 +18,12 @@ const siteContent: SiteContent = { email: { user: 'info', domain: 'andreaslop.nl' }, // Switched on once the API can receive the form contactForm: { enabled: false }, + // Huizen and the region around it (Bussum, Hilversum, …), as the pages + // say; not the whole country, which would weaken the local signal + serviceArea: [ + { type: 'City', name: 'Huizen' }, + { type: 'AdministrativeArea', name: 'Gooi en Vechtstreek' }, + ], }; export default siteContent; diff --git a/web/src/content/types.ts b/web/src/content/types.ts index a0e6f30..ca8c668 100644 --- a/web/src/content/types.ts +++ b/web/src/content/types.ts @@ -22,6 +22,16 @@ export interface SiteContent { email: EmailAddress; // Off: the form is shown dimmed under a "coming soon" notice (FR-HP-07) contactForm: { enabled: boolean }; + // Where Andrea mainly works, for the structured data of the business + // and its services. Matches what the pages say, not every place she + // would travel to. + serviceArea: ServiceArea[]; +} + +// A place in schema.org terms: a town, or a region such as Gooi en Vechtstreek +export interface ServiceArea { + type: 'City' | 'AdministrativeArea'; + name: string; } // An image as the API will deliver it. width and height are the intrinsic diff --git a/web/src/seo.test.ts b/web/src/seo.test.ts index ae9c8d4..a86bbce 100644 --- a/web/src/seo.test.ts +++ b/web/src/seo.test.ts @@ -6,6 +6,7 @@ import { emailAddress } from './lib/emailAddress'; import { visibleSocials } from './lib/visibleSocials'; import { aboutPage, + areaServed, businessId, canonicalUrl, jsonLdScript, @@ -119,6 +120,13 @@ describe('professionalService en siteHead', () => { expect(JSON.stringify(data)).not.toContain('@andreaslop'); }); + it('serves Huizen and Gooi en Vechtstreek', () => { + expect(professionalService(siteContent).areaServed).toEqual([ + { '@type': 'City', name: 'Huizen' }, + { '@type': 'AdministrativeArea', name: 'Gooi en Vechtstreek' }, + ]); + }); + it('laat ongeldige socials weg uit sameAs', () => { const data = professionalService({ ...siteContent, @@ -136,6 +144,34 @@ describe('professionalService en siteHead', () => { }); }); +describe('areaServed', () => { + it('keeps every named area, trimmed and in order (invariant)', () => { + fc.assert( + fc.property(anySiteContent, (site) => { + const named = site.serviceArea.filter( + (area) => area.name.trim() !== '', + ); + expect(areaServed(site.serviceArea)).toEqual( + named.map((area) => ({ + '@type': area.type, + name: area.name.trim(), + })), + ); + }), + ); + }); + + it('only produces towns and regions (invariant)', () => { + fc.assert( + fc.property(anySiteContent, (site) => + areaServed(site.serviceArea).every((place) => + ['City', 'AdministrativeArea'].includes(place['@type']), + ), + ), + ); + }); +}); + describe('pageHead for the about page', () => { it('is indexed, with its own title, description and preview image', () => { const head = pageHead('/over-mij'); diff --git a/web/src/seo.ts b/web/src/seo.ts index 4e14086..ae75bba 100644 --- a/web/src/seo.ts +++ b/web/src/seo.ts @@ -1,6 +1,10 @@ // 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 { AboutPageContent, SiteContent } from './content/types.ts'; +import type { + AboutPageContent, + ServiceArea, + SiteContent, +} from './content/types.ts'; import { knowsAboutList } from './lib/knowsAboutList.ts'; import { visibleSocials } from './lib/visibleSocials.ts'; import type { RoutePath } from './navigation.ts'; @@ -73,6 +77,15 @@ const huizen = { addressCountry: 'NL', } as const; +// The service area as schema.org places, in the given order. Blank names +// are left out and padding is trimmed, so a stray entry from the CMS never +// shows up as an empty place. +export function areaServed(areas: readonly ServiceArea[]) { + return areas + .map((area) => ({ '@type': area.type, name: area.name.trim() })) + .filter((place) => place.name !== ''); +} + // Gestructureerde data: een lokale fotograaf in Huizen. Bewust zonder // e-mailadres, anders staat het alsnog leesbaar in de pagina. export function professionalService(content: SiteContent) { @@ -86,7 +99,7 @@ export function professionalService(content: SiteContent) { image: siteUrl + defaultOgImage.path, description: sitePages['/'].description, address: huizen, - areaServed: { '@type': 'Place', name: 'Huizen' }, + areaServed: areaServed(content.serviceArea), sameAs: visibleSocials(content.socials).map((social) => social.href), founder: { '@id': personId }, }; diff --git a/web/src/test/arbitraries.ts b/web/src/test/arbitraries.ts index 90414d6..4601ca1 100644 --- a/web/src/test/arbitraries.ts +++ b/web/src/test/arbitraries.ts @@ -66,6 +66,26 @@ export const anySiteContent: fc.Arbitrary = fc.record({ socials: fc.array(socialLink, { maxLength: 4 }), email: validEmail, contactForm: fc.record({ enabled: fc.boolean() }), + serviceArea: fc.array( + fc.record({ + type: fc.constantFrom( + 'City' as const, + 'AdministrativeArea' as const, + ), + // Includes blanks and padding, as an editor might type + name: fc.oneof( + fc.constantFrom( + 'Huizen', + 'Gooi en Vechtstreek', + '', + ' ', + ' Bussum ', + ), + fc.string({ maxLength: 20 }), + ), + }), + { maxLength: 4 }, + ), }); // Specialisations with padding, blanks and repeats, as an editor might type