Adds the Contact page
The contact page in the approved layout: the form next to a photo with the contact card on wide screens, and the card with a small portrait above the form on phones, where the large photo is never downloaded. /contact?pakket= preselects a package. The page is indexed, with its own title, description, preview image and ContactPage structured data. Over mij and Soorten fotoshoots now link to /contact. The green button gets a darker background, so its white text meets the contrast minimum. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,16 +16,14 @@ const shoot = (id: string) => shootTypes.find((item) => item.id === id)!;
|
||||
describe('shootContactLink', () => {
|
||||
it('preselects the package of a shoot that has one', () => {
|
||||
expect(shootContactLink(shoot('newborn'), packages)).toEqual({
|
||||
to: '/',
|
||||
to: '/contact',
|
||||
search: { pakket: 'newborn' },
|
||||
hash: 'contact',
|
||||
});
|
||||
});
|
||||
|
||||
it('links without a package for a shoot that has none', () => {
|
||||
expect(shootContactLink(shoot('loveshoot'), packages)).toEqual({
|
||||
to: '/',
|
||||
hash: 'contact',
|
||||
to: '/contact',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,14 +33,13 @@ describe('shootContactLink', () => {
|
||||
shoot('gezin'),
|
||||
packages.filter((pkg) => pkg.id !== 'gezin'),
|
||||
),
|
||||
).toEqual({ to: '/', hash: 'contact' });
|
||||
).toEqual({ to: '/contact' });
|
||||
});
|
||||
|
||||
it('always goes to the contact section (invariant)', () => {
|
||||
it('always goes to the contact page (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(shootType, fc.array(anyPackage), (item, list) => {
|
||||
const link = shootContactLink(item, list);
|
||||
return link.to === '/' && link.hash === 'contact';
|
||||
return shootContactLink(item, list).to === '/contact';
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -3,9 +3,8 @@ import type { RoutePath } from '../navigation.ts';
|
||||
import type { PageMeta } from '../sitePages.ts';
|
||||
import { visiblePackages } from './visiblePackages.ts';
|
||||
|
||||
// Where "Stuur een berichtje" goes: the homepage contact section, with the
|
||||
// shoot's package preselected when that package is shown (BR-SF-01..03).
|
||||
// Once /contact exists, only this function changes.
|
||||
// Where "Stuur een berichtje" goes: the contact page, with the shoot's
|
||||
// package preselected when that package is shown (BR-SF-01..03, FR-CP-09)
|
||||
export function shootContactLink(
|
||||
shoot: ShootType,
|
||||
packages: readonly PricingPackage[],
|
||||
@@ -14,12 +13,8 @@ export function shootContactLink(
|
||||
(pkg) => pkg.id === shoot.packageId,
|
||||
);
|
||||
return shown && shoot.packageId !== undefined
|
||||
? {
|
||||
to: '/' as const,
|
||||
search: { pakket: shoot.packageId },
|
||||
hash: 'contact',
|
||||
}
|
||||
: { to: '/' as const, hash: 'contact' };
|
||||
? { to: '/contact' as const, search: { pakket: shoot.packageId } }
|
||||
: { to: '/contact' as const };
|
||||
}
|
||||
|
||||
// "Bekijk meer …foto's": the portfolio filtered on this shoot type
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import fc from 'fast-check';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import contactContent from '../content/contactContent';
|
||||
import siteContent from '../content/siteContent';
|
||||
import { REPLY_TIME_PLACEHOLDER, withReplyTime } from './withReplyTime';
|
||||
|
||||
// Text with some placeholders in it, as an editor might write it. Plain
|
||||
// pieces have no braces: half a placeholder around a real one could
|
||||
// otherwise form a new one, which content never contains.
|
||||
const plain = fc.string().filter((text) => !/[{}]/.test(text));
|
||||
const template = fc
|
||||
.array(fc.oneof(plain, fc.constant(REPLY_TIME_PLACEHOLDER)))
|
||||
.map((pieces) => pieces.join(''));
|
||||
const replyTime = fc
|
||||
.string()
|
||||
.filter((value) => !value.includes(REPLY_TIME_PLACEHOLDER));
|
||||
|
||||
describe('withReplyTime', () => {
|
||||
it('fills in the reply time of the site in the contact intro', () => {
|
||||
expect(
|
||||
withReplyTime(
|
||||
contactContent.head.intro,
|
||||
siteContent.contactForm.replyTime,
|
||||
),
|
||||
).toBe(
|
||||
'Wil je een fotoshoot boeken of meer informatie ontvangen? Stuur me een berichtje, ik reageer binnen 1-2 werkdagen.',
|
||||
);
|
||||
});
|
||||
|
||||
it('leaves no placeholder behind (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(template, replyTime, (text, time) => {
|
||||
expect(withReplyTime(text, time)).not.toContain(
|
||||
REPLY_TIME_PLACEHOLDER,
|
||||
);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('returns text without the placeholder as it is (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(
|
||||
fc.string().filter((t) => !t.includes(REPLY_TIME_PLACEHOLDER)),
|
||||
fc.string(),
|
||||
(text, time) => {
|
||||
expect(withReplyTime(text, time)).toBe(text);
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it('puts the reply time exactly where the placeholders were (oracle)', () => {
|
||||
fc.assert(
|
||||
fc.property(fc.array(plain), replyTime, (pieces, time) => {
|
||||
const text = pieces.join(REPLY_TIME_PLACEHOLDER);
|
||||
expect(withReplyTime(text, time)).toBe(pieces.join(time));
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
// The placeholder for the reply time in content texts (BR-CP-05)
|
||||
export const REPLY_TIME_PLACEHOLDER = '{reactietermijn}';
|
||||
|
||||
// Fills in the reply time, so a text and the form's thank-you always name
|
||||
// the same one. Text without the placeholder comes back as it is.
|
||||
export function withReplyTime(text: string, replyTime: string): string {
|
||||
return text.split(REPLY_TIME_PLACEHOLDER).join(replyTime);
|
||||
}
|
||||
Reference in New Issue
Block a user