Files
AndreaSlopFotografie/web/src/lib/packageFromSearch.ts
T
SluijsensandClaude Opus 5.5 30dab1af42 Adds the Prijzen section to the homepage
Shows the three live packages as cards with their price and what is
included. Each card links to the contact section with ?pakket=<id>, so
the contact form can preselect it. Invalid packages from the CMS are
skipped and the pakket value is only accepted when it names a package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 01:07:36 +02:00

15 lines
637 B
TypeScript

import type { PricingPackage } from '../content/types.ts';
// The package id from ?pakket=, if it names one of the given packages.
// Letter case and surrounding spaces do not matter; anything else (unknown
// id, number, array, missing) is ignored. Only our own ids can come out, so
// the value from the URL is never reflected on the page (BR-PARAM-01).
export function packageFromSearch(
value: unknown,
packages: readonly PricingPackage[],
): string | undefined {
if (typeof value !== 'string') return undefined;
const wanted = value.trim().toLowerCase();
return packages.find((pkg) => pkg.id === wanted)?.id;
}