Files
AndreaSlopFotografie/docs/cms-integration.md
T
SluijsensandClaude Sonnet 5.5 ba7288526b Gives a featured package a quiet highlight and makes the optional CMS fields explicit
A featured card gets a heidegroen top rule, border and a small "Uitgelicht"
tab on its top edge; the tab sits on the border so the row keeps its layout.
Tests and docs state that the site does not depend on description, price note
or button label.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 14:15:23 +01:00

8.7 KiB

CMS integration

The site talks to the SLP CMS host through its API. On the test host the CMS host serves the site itself, so every call is same-origin (/api/v1/*, CSP connect-src 'self', no CORS). Three things come from the CMS: the shoot packages, two banners and the contact form.

Shoot packages

Source: GET /api/v1/offerings. One list feeds the price cards on the home page and on the pages for each shoot type, the "welke shoot" choices of the contact form and the ?pakket= check, so they can never disagree.

  • Any number of packages. The cards are a wrapping flex row. On desktop (lg and up) every card is a third of the row (calc((100% - 2 * gap) / 3)) and every row is centred, so an incomplete last row (4, 5, 7, 8, 10 cards, ...) sits in the middle. There is no styling per number of cards. On phone and tablet the cards are one column; there is no swipe row.
  • Mapping (web/src/lib/offerings.ts, pure functions): slug is the package id (kept zwangerschap, newborn, gezin: they appear in ?pakket= and the form), title the name, the free price text is read as whole euros ("€ 175", "€ 1.250", "175,-"). A card with an unreadable price, no features or a bad slug is skipped. Order follows displayOrder. Empty description, priceNote and ctaLabel are accepted and left out of the card.
  • Where the data comes from, in order:
    1. At build time web/config/fetchOfferings.ts (the first step of pnpm build) asks OFFERINGS_URL (10 s timeout, 2 attempts) and writes the gitignored web/src/content/offerings.generated.json. The packages are baked into the prerendered HTML (search engines see the prices, no layout jump).
    2. Without OFFERINGS_URL, with a CMS that is down or with an unusable answer, the committed web/src/content/offerings.snapshot.json is used. The build never fails and never shows empty prices; the log says which source was used. Tests always use the snapshot.
    3. After hydration PackagesProvider (web/src/components/PackagesProvider/) asks the CMS once and replaces the baked list only if the answer differs. A network error, time-out (8 s), bad status or invalid answer keeps what was baked. A change in the CMS therefore shows at once; the nightly build only matters for search engines.
  • Featured package (the star in the CMS admin, field featured): the card gets a heidegroen rule along its top, a heidegroen border and a small "Uitgelicht" tab on the top edge (PriceCard). The tab is positioned on the border, so the cards of a row keep the same layout. Any number of cards may be featured.
  • Description, price note and button label (description, priceNote, ctaLabel) are optional in the CMS and the site does not use them: they are not shown and a card never depends on them (empty, null or absent all give the same card; covered by tests).
  • Scheduling in the CMS: the API only returns packages that are live at the moment of the request (switched on and inside their from/to dates), so the site shows them and nothing else. The baked list reflects the moment of the build; the live refresh after hydration corrects it for every visitor, and the nightly build corrects it for search engines. A package that goes live or expires between two builds is therefore right in the browser but can be stale in the HTML until the next build.
  • Keep the snapshot current when the real packages change (prices, features), because production builds use it (see "Reverse proxy" below).

Banners (OfferingBanner)

Source: GET /api/v1/offerings/banner?position=top|bottom. No parameter means bottom; 204 means no active banner; an invalid value is 400. Answer fields: title (at most 100 characters), text (at most 300 for bottom, 120 for top), linkLabel, linkUrl (both or neither; https:// or a path on the site with one /) and position. Both banners may be active and visible at the same time.

Under the cards (bottom) Above the cards (top)
Component PriceBanner PriceTopBar
Look Light band, thin heidegroen top rule, section-heading title, ornament, sprig, deep-green link button Slim white bar, same hairline and top rule, one line: small capitals title, diamond, text, small underlined link
Required title title or text (title may be empty)
Mapping mapBanner mapTopBanner

Both follow the same rules as the packages: baked into the HTML at build time, replaced live after hydration, empty fields are hidden, an error or invalid answer keeps what was baked. A 204 hides that banner (the one deliberate exception to "keep what was baked"); the two banners are independent of each other. Neither banner is a package: not in the form choices, not in the package count.

Layout shift: a banner that was not active at the last build is not in the HTML. When it appears live, the content below it moves down by its height once (for the top bar, the cards move). Rebuilding with the banner active (the nightly test build does this) removes the shift. The same holds in reverse when a baked banner is switched off.

Contact form

GET /api/v1/contact-messages/token and POST /api/v1/contact-messages through the headless web/src/cms-client. The form is behind the switch contactForm.enabled in web/src/content/siteContent.ts (off means the "Binnenkort" gate and no request to the server). Details and the go-live conditions are in aidlc-docs/features/contact-form-cms/ and go-live-checklist.md. Friendly Captcha is off at go-live.

Reverse proxy for /api/v1/*

  • Test (ASF): nginx on the proxy Pi forwards everything for test.andreaslop.nl to the CMS host (web/deploy/nginx/test.andreaslop.nl.proxy.conf), which serves the site files and the API. Nothing to add.
  • Production (IIS): not in place yet. The generated web/deploy/iis/web.config only serves static files, so /api/v1/* answers 404 there. Production needs either a reverse-proxy rule (URL Rewrite with ARR) from /api/v1/* to a production CMS host for ASF, or the CMS host serving the site as on test. This is a separate follow-up together with ASF production hosting. Until then the production build uses the committed snapshot and the live calls fail safely (the baked list stays; the browser console shows the 404). Change the rule in web/config/serverConfig.ts and run pnpm server-config; never edit the generated files.

Environment and variables

Name Where Meaning
OFFERINGS_URL build env Site address that serves the API (for example https://test.andreaslop.nl). Unset gives the snapshot.
ASF_OFFERINGS_URL_TEST Gitea repo variable Value of OFFERINGS_URL for the test build. Set by SLS, not by feature sessions.
API_PROXY_TARGET dev env Forwards /api in pnpm dev to a CMS host.
VITE_SITE_URL build env Address the site presents itself under (canonical, og:*, JSON-LD, sitemap). Only the test build sets it (https://test.andreaslop.nl); unset gives https://andreaslop.nl.

The production artifact is built without OFFERINGS_URL on purpose: production must never carry the prices of the test CMS.