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 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,12 @@ const siteContent: SiteContent = {
|
|||||||
email: { user: 'info', domain: 'andreaslop.nl' },
|
email: { user: 'info', domain: 'andreaslop.nl' },
|
||||||
// Switched on once the API can receive the form
|
// Switched on once the API can receive the form
|
||||||
contactForm: { enabled: false },
|
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;
|
export default siteContent;
|
||||||
|
|||||||
@@ -22,6 +22,16 @@ export interface SiteContent {
|
|||||||
email: EmailAddress;
|
email: EmailAddress;
|
||||||
// Off: the form is shown dimmed under a "coming soon" notice (FR-HP-07)
|
// Off: the form is shown dimmed under a "coming soon" notice (FR-HP-07)
|
||||||
contactForm: { enabled: boolean };
|
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
|
// An image as the API will deliver it. width and height are the intrinsic
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { emailAddress } from './lib/emailAddress';
|
|||||||
import { visibleSocials } from './lib/visibleSocials';
|
import { visibleSocials } from './lib/visibleSocials';
|
||||||
import {
|
import {
|
||||||
aboutPage,
|
aboutPage,
|
||||||
|
areaServed,
|
||||||
businessId,
|
businessId,
|
||||||
canonicalUrl,
|
canonicalUrl,
|
||||||
jsonLdScript,
|
jsonLdScript,
|
||||||
@@ -119,6 +120,13 @@ describe('professionalService en siteHead', () => {
|
|||||||
expect(JSON.stringify(data)).not.toContain('@andreaslop');
|
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', () => {
|
it('laat ongeldige socials weg uit sameAs', () => {
|
||||||
const data = professionalService({
|
const data = professionalService({
|
||||||
...siteContent,
|
...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', () => {
|
describe('pageHead for the about page', () => {
|
||||||
it('is indexed, with its own title, description and preview image', () => {
|
it('is indexed, with its own title, description and preview image', () => {
|
||||||
const head = pageHead('/over-mij');
|
const head = pageHead('/over-mij');
|
||||||
|
|||||||
+15
-2
@@ -1,6 +1,10 @@
|
|||||||
// SEO: head-tags per pagina en voor de hele site, plus gestructureerde data.
|
// SEO: head-tags per pagina en voor de hele site, plus gestructureerde data.
|
||||||
// Titels en beschrijvingen staan in het pagina-register (sitePages.ts).
|
// 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 { knowsAboutList } from './lib/knowsAboutList.ts';
|
||||||
import { visibleSocials } from './lib/visibleSocials.ts';
|
import { visibleSocials } from './lib/visibleSocials.ts';
|
||||||
import type { RoutePath } from './navigation.ts';
|
import type { RoutePath } from './navigation.ts';
|
||||||
@@ -73,6 +77,15 @@ const huizen = {
|
|||||||
addressCountry: 'NL',
|
addressCountry: 'NL',
|
||||||
} as const;
|
} 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
|
// Gestructureerde data: een lokale fotograaf in Huizen. Bewust zonder
|
||||||
// e-mailadres, anders staat het alsnog leesbaar in de pagina.
|
// e-mailadres, anders staat het alsnog leesbaar in de pagina.
|
||||||
export function professionalService(content: SiteContent) {
|
export function professionalService(content: SiteContent) {
|
||||||
@@ -86,7 +99,7 @@ export function professionalService(content: SiteContent) {
|
|||||||
image: siteUrl + defaultOgImage.path,
|
image: siteUrl + defaultOgImage.path,
|
||||||
description: sitePages['/'].description,
|
description: sitePages['/'].description,
|
||||||
address: huizen,
|
address: huizen,
|
||||||
areaServed: { '@type': 'Place', name: 'Huizen' },
|
areaServed: areaServed(content.serviceArea),
|
||||||
sameAs: visibleSocials(content.socials).map((social) => social.href),
|
sameAs: visibleSocials(content.socials).map((social) => social.href),
|
||||||
founder: { '@id': personId },
|
founder: { '@id': personId },
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -66,6 +66,26 @@ export const anySiteContent: fc.Arbitrary<SiteContent> = fc.record({
|
|||||||
socials: fc.array(socialLink, { maxLength: 4 }),
|
socials: fc.array(socialLink, { maxLength: 4 }),
|
||||||
email: validEmail,
|
email: validEmail,
|
||||||
contactForm: fc.record({ enabled: fc.boolean() }),
|
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
|
// Specialisations with padding, blanks and repeats, as an editor might type
|
||||||
|
|||||||
Reference in New Issue
Block a user