ferst-core 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +13 -4
  2. package/bin/ferst-media.mjs +96 -0
  3. package/cms/config.template.yml +11 -0
  4. package/components/Card.astro +53 -51
  5. package/components/PostCard.astro +138 -136
  6. package/components/SiteHeader.astro +1356 -1273
  7. package/components/blocks/Grid.astro +49 -48
  8. package/components/blocks/Heading.astro +4 -1
  9. package/components/recipes/Banner.astro +146 -146
  10. package/components/recipes/Book.astro +39 -4
  11. package/components/recipes/FeatureCards.astro +112 -118
  12. package/components/recipes/Gallery.astro +57 -59
  13. package/components/recipes/Hero.astro +638 -533
  14. package/components/recipes/LatestPosts.astro +295 -292
  15. package/components/recipes/Locations.astro +146 -143
  16. package/components/recipes/Marquee.astro +75 -75
  17. package/components/recipes/MediaCards.astro +213 -219
  18. package/components/recipes/Pricing.astro +149 -150
  19. package/components/recipes/Stats.astro +150 -157
  20. package/components/recipes/Tiles.astro +342 -296
  21. package/content/blocks.ts +1072 -1024
  22. package/content/imageSlots.mjs +542 -0
  23. package/content/schemas.ts +35 -2
  24. package/examples/recipes.ts +4 -0
  25. package/fonts/OFL.txt +1332 -287
  26. package/fonts/anton-latin-400-normal.woff2 +0 -0
  27. package/fonts/bangers-latin-400-normal.woff2 +0 -0
  28. package/fonts/bebas-neue-latin-400-normal.woff2 +0 -0
  29. package/fonts/bowlby-one-latin-400-normal.woff2 +0 -0
  30. package/fonts/fredoka-latin-400-normal.woff2 +0 -0
  31. package/fonts/fredoka-latin-600-normal.woff2 +0 -0
  32. package/fonts/fredoka-latin-700-normal.woff2 +0 -0
  33. package/fonts/knewave-latin-400-normal.woff2 +0 -0
  34. package/fonts/lora-latin-400-normal.woff2 +0 -0
  35. package/fonts/lora-latin-600-normal.woff2 +0 -0
  36. package/fonts/lora-latin-700-normal.woff2 +0 -0
  37. package/fonts/merriweather-latin-400-normal.woff2 +0 -0
  38. package/fonts/merriweather-latin-600-normal.woff2 +0 -0
  39. package/fonts/merriweather-latin-700-normal.woff2 +0 -0
  40. package/fonts/nunito-latin-400-normal.woff2 +0 -0
  41. package/fonts/nunito-latin-600-normal.woff2 +0 -0
  42. package/fonts/nunito-latin-700-normal.woff2 +0 -0
  43. package/fonts/oswald-latin-400-normal.woff2 +0 -0
  44. package/fonts/oswald-latin-600-normal.woff2 +0 -0
  45. package/fonts/oswald-latin-700-normal.woff2 +0 -0
  46. package/fonts/rubik-dirt-latin-400-normal.woff2 +0 -0
  47. package/integration.mjs +253 -249
  48. package/layouts/Base.astro +13 -3
  49. package/lib/book.ts +94 -1
  50. package/lib/fonts.ts +130 -0
  51. package/lib/gridRows.ts +197 -0
  52. package/lib/image-fields.ts +140 -0
  53. package/lib/image-size.mjs +108 -0
  54. package/lib/image-sizes.ts +16 -0
  55. package/lib/logo-header.ts +46 -0
  56. package/lib/media-check.mjs +524 -0
  57. package/lib/theme-preview.ts +203 -140
  58. package/lib/themeTokens.ts +235 -220
  59. package/package.json +3 -2
  60. package/styles/fonts.css +239 -76
  61. package/styles/theme.css +228 -160
  62. package/lib/gridColumns.ts +0 -22
package/content/blocks.ts CHANGED
@@ -1,1024 +1,1072 @@
1
- import { z } from 'zod';
2
- import { iconKeys, isIconKey } from '../lib/icons';
3
-
4
- /**
5
- * The block palette — the heart of the Ferst page model (see
6
- * docs/BLOCK-ARCHITECTURE.md). A page is an ordered list of typed blocks stored
7
- * as JSON; a Zod **discriminated union** on `type` is the single contract the AI
8
- * composes against, the CMS validates, and the renderer's registry keys on.
9
- *
10
- * This is an original design of the *mechanism*, built from scratch. It starts
11
- * with **Level-1 primitives** only; recipes (Level 2) and
12
- * page templates (Level 3) layer on top later, and layout/container primitives
13
- * (Section/Grid/Stack, which nest child blocks) are a deliberate next slice.
14
- */
15
-
16
- /** Every block shares a `type` discriminant and an `enabled` flag (keep a block
17
- * in the page data without rendering it). */
18
- /** An icon name from the engine's registry (lib/icons). An unknown name fails validation,
19
- * and so the build, with the valid names listed, instead of rendering nothing silently. */
20
- const iconName = z.string().refine(isIconKey, (v) => ({
21
- message: `Unknown icon "${v}". Use one of: ${iconKeys.join(', ')}.`,
22
- }));
23
-
24
- export const headingBlock = z.object({
25
- type: z.literal('heading'),
26
- enabled: z.boolean().default(true),
27
- text: z.string(),
28
- level: z.number().int().min(1).max(6).default(2),
29
- /** Explicit per-heading alignment. OMITTED ⇒ inherit the page/section
30
- * `--content-align` cascade; set it only to override for this one heading. */
31
- align: z.enum(['start', 'center', 'end']).optional(),
32
- /** Paint the text with a brand → accent-2 gradient (falls back to solid ink
33
- * where background-clip:text is unsupported). A per-block opt-in effect. */
34
- gradient: z.boolean().default(false),
35
- });
36
-
37
- export const proseBlock = z.object({
38
- type: z.literal('prose'),
39
- enabled: z.boolean().default(true),
40
- /** Blank lines separate paragraphs; `- ` / `1. ` lines make lists; inline
41
- * `[links](href)` (incl. tel:/mailto:), `**bold**` and `*italic*` (lib/prose.ts). */
42
- text: z.string(),
43
- /** `lead` = the page's introduction: larger and quieter than body text, for the
44
- * paragraph straight under the hero. */
45
- variant: z.enum(['body', 'lead']).default('body'),
46
- });
47
-
48
- /** Which part of an image stays in view when it's cropped to a shape: one or two positions,
49
- * keywords or percentages (`center 25%` keeps a face in a portrait, `top`, `left 20%`).
50
- * Positions only, so no other CSS can get in. Default `center`. */
51
- export const focusPosition = z
52
- .string()
53
- .regex(/^(?:left|center|right|top|bottom|\d{1,3}%)(?: (?:left|center|right|top|bottom|\d{1,3}%))?$/, 'focus is one or two of left / center / right / top / bottom / a percentage, e.g. "center 25%"');
54
- /** An image a block may crop to a shape, with the part to keep in view. */
55
- const croppedImage = z.object({ src: z.string(), alt: z.string().default(''), focus: focusPosition.optional() });
56
-
57
- export const imageBlock = z.object({
58
- type: z.literal('image'),
59
- enabled: z.boolean().default(true),
60
- src: z.string(),
61
- alt: z.string().default(''),
62
- caption: z.string().optional(),
63
- /** Canonical framing options — a small, clear set the AI or a client picks
64
- * from, rather than free-form CSS. Corners follow the site by default. */
65
- radius: z.enum(['none', 'soft', 'round']).default('soft'),
66
- shadow: z.boolean().default(false),
67
- border: z.boolean().default(false),
68
- ratio: z.enum(['auto', 'square', '4/3', '3/2', '16/9', '21/9']).default('auto'),
69
- /** Which part stays in view when `ratio` crops it. */
70
- focus: focusPosition.optional(),
71
- /** Opt in to a soft clip-path reveal as the image scrolls into view
72
- * (progressive: no motion under reduced-motion or unsupported browsers). */
73
- reveal: z.boolean().default(false),
74
- });
75
-
76
- export const buttonBlock = z.object({
77
- type: z.literal('button'),
78
- enabled: z.boolean().default(true),
79
- label: z.string(),
80
- href: z.string(),
81
- /** Role, not decoration: primary action, secondary action, filled CTA, or a
82
- * quiet ghost. Shape (radius) is a site-wide token, not a per-button choice. */
83
- variant: z.enum(['primary', 'secondary', 'cta', 'ghost']).default('primary'),
84
- });
85
-
86
- export const quoteBlock = z.object({
87
- type: z.literal('quote'),
88
- enabled: z.boolean().default(true),
89
- text: z.string(),
90
- cite: z.string().optional(),
91
- });
92
-
93
- export const dividerBlock = z.object({
94
- type: z.literal('divider'),
95
- enabled: z.boolean().default(true),
96
- });
97
-
98
- export const spacerBlock = z.object({
99
- type: z.literal('spacer'),
100
- enabled: z.boolean().default(true),
101
- size: z.enum(['sm', 'md', 'lg']).default('md'),
102
- });
103
-
104
- export const badgeBlock = z.object({
105
- type: z.literal('badge'),
106
- enabled: z.boolean().default(true),
107
- text: z.string(),
108
- tone: z.enum(['neutral', 'accent']).default('accent'),
109
- });
110
-
111
- export const statBlock = z.object({
112
- type: z.literal('stat'),
113
- enabled: z.boolean().default(true),
114
- value: z.string(),
115
- label: z.string(),
116
- });
117
-
118
- export const listBlock = z.object({
119
- type: z.literal('list'),
120
- enabled: z.boolean().default(true),
121
- /** bullet (disc) · number (ordered) · check (ticked, uses the check icon). */
122
- style: z.enum(['bullet', 'number', 'check']).default('bullet'),
123
- items: z.array(z.string()).default([]),
124
- });
125
-
126
- /* ── Level 2 — Recipes (curated, opinionated compositions of primitives) ─────
127
- * A recipe is a first-class block in the same union, but it renders a *designed*
128
- * layout (composing primitives internally) rather than a bare element. Locked
129
- * components so quality can't drift (BLOCK-ARCHITECTURE §6). */
130
- export const heroBlock = z.object({
131
- type: z.literal('hero'),
132
- enabled: z.boolean().default(true),
133
- eyebrow: z.string().optional(),
134
- title: z.string(),
135
- subtitle: z.string().optional(),
136
- cta: z.object({ label: z.string(), href: z.string() }).optional(),
137
- image: z.object({ src: z.string(), alt: z.string().default('') }).optional(),
138
- /** Background media for the `media` layout, in order of precedence: a looping
139
- * muted `video` (a hosted file, or a YouTube / Vimeo link — embedded only after
140
- * cookie consent, showing `poster` until then), a slow crossfade through `images`
141
- * (2+), or one `image`.
142
- * `overlay` (0–100) is the darkening scrim so text stays legible; `poster` is
143
- * the video's still (and what reduced-motion visitors see). Moving backgrounds
144
- * get a pause button and stay still under prefers-reduced-motion. */
145
- media: z
146
- .object({
147
- image: z.string().optional(),
148
- images: z.array(z.string()).max(8).optional(),
149
- video: z.string().optional(),
150
- poster: z.string().optional(),
151
- overlay: z.number().min(0).max(100).default(45),
152
- /** Where the background leads: e.g. the full video on YouTube. The whole
153
- * background becomes a link (opens in a new tab — the app on phones), with
154
- * a visible "Watch the full video" cue; the text and CTA stay on top. */
155
- link: z.string().optional(),
156
- linkLabel: z.string().optional(),
157
- })
158
- .optional(),
159
- layout: z.enum(['centered', 'split', 'media']).default('centered'),
160
- /** How much of the screen a `media` hero takes: `compact` (a narrow band for a short,
161
- * wide header strip, e.g. 1000 × 175), `standard` (a band), `tall`, or `screen` — the
162
- * full first screen, edge to edge (e.g. a video opener). */
163
- size: z.enum(['compact', 'standard', 'tall', 'screen']).default('standard'),
164
- /** A `media` hero runs edge to edge across the screen, like a full-bleed banner
165
- * (`screen` always does). */
166
- fullBleed: z.boolean().default(false),
167
- /** Which part of the background image shows when it's cropped: one or two positions,
168
- * keywords or percentages (e.g. `center 30%`, `top`, `left 20%`). Default `center`. */
169
- focus: focusPosition.optional(),
170
- /** A `media` hero's background drifts more slowly than the page as it scrolls (any
171
- * background: image, slides or video). Off on touch devices and under reduced motion. */
172
- parallax: z.boolean().default(false),
173
- /** Ambient background for centered/split heroes: `mesh` = a soft, slowly
174
- * drifting brand gradient behind the text (static under reduced-motion). */
175
- background: z.enum(['none', 'mesh']).default('none'),
176
- });
177
-
178
- export const featureCardsBlock = z.object({
179
- type: z.literal('featureCards'),
180
- enabled: z.boolean().default(true),
181
- title: z.string().optional(),
182
- intro: z.string().optional(),
183
- columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).default(3),
184
- cards: z
185
- .array(
186
- z.object({
187
- icon: iconName.optional(),
188
- title: z.string(),
189
- text: z.string().optional(),
190
- href: z.string().optional(),
191
- })
192
- )
193
- .default([]),
194
- });
195
-
196
- export const ctaBlock = z.object({
197
- type: z.literal('cta'),
198
- enabled: z.boolean().default(true),
199
- title: z.string(),
200
- text: z.string().optional(),
201
- cta: z.object({ label: z.string(), href: z.string() }),
202
- background: z.enum(['muted', 'accent', 'mesh']).default('accent'),
203
- });
204
-
205
- export const faqBlock = z.object({
206
- type: z.literal('faq'),
207
- enabled: z.boolean().default(true),
208
- title: z.string().optional(),
209
- items: z.array(z.object({ question: z.string(), answer: z.string() })).default([]),
210
- });
211
-
212
- export const galleryBlock = z.object({
213
- type: z.literal('gallery'),
214
- enabled: z.boolean().default(true),
215
- columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).default(3),
216
- images: z
217
- .array(z.object({ src: z.string(), alt: z.string().default(''), caption: z.string().optional() }))
218
- .default([]),
219
- });
220
-
221
- export const testimonialBlock = z.object({
222
- type: z.literal('testimonial'),
223
- enabled: z.boolean().default(true),
224
- quote: z.string(),
225
- author: z.string(),
226
- role: z.string().optional(),
227
- avatar: z.object({ src: z.string(), alt: z.string().default('') }).optional(),
228
- });
229
-
230
- /** One of the organisation's forms from the Ferst portal, placed by id. Its fields, button
231
- * and submit address are read from the platform at build time (lib/forms), so a change
232
- * in the portal reaches the site on its next build. List a site's forms with
233
- * `npx ferst-modules`. Title defaults to the form's name. */
234
- export const formBlock = z.object({
235
- type: z.literal('form'),
236
- enabled: z.boolean().default(true),
237
- /** The form's id in the portal (e.g. `form_8c1d…`). */
238
- form: z.string().min(1),
239
- title: z.string().optional(),
240
- intro: z.string().optional(),
241
- /** Small print under the form (e.g. a privacy line). */
242
- note: z.string().optional(),
243
- });
244
-
245
- /** A payment for one of the organisation's items, from the Ferst Payments module ("Course fee",
246
- * £40). The block names the item; its name and price are the organisation's, read from the
247
- * platform at build time (lib/pay) and again in the browser, never written here: the platform
248
- * reads the price itself when the visitor pays. The visitor gives a name and email and pays on
249
- * Stripe's page. List what a site can take payment for with `npx ferst-modules`. */
250
- export const payBlock = z.object({
251
- type: z.literal('pay'),
252
- enabled: z.boolean().default(true),
253
- /** The item's id in the portal (e.g. `pi_8c1d…`). */
254
- item: z.string().min(1),
255
- /** Defaults to the item's name. */
256
- title: z.string().optional(),
257
- intro: z.string().optional(),
258
- /** Small print under the button (e.g. what happens after paying). */
259
- note: z.string().optional(),
260
- /** The button's words; the price follows them ("Pay £40"). */
261
- buttonLabel: z.string().max(40).optional(),
262
- });
263
-
264
- /** Visitors book a time for one of the organisation's offers, from the Ferst Events and bookings
265
- * module ("Haircut", 30 minutes). The block names the offer, a person or a place (everything they
266
- * provide online, the visitor choosing which), or both (that offer with them only); one of the
267
- * two is needed. Names, lengths, prices, who gives it and the free times are the organisation's,
268
- * read from the platform (lib/book), never written here. A picked time is held for the visitor
269
- * while they give their details, then booked; the visitor is emailed. List what a site takes
270
- * bookings for, and who provides it, with `npx ferst-modules`. */
271
- export const bookBlock = z.object({
272
- type: z.literal('book'),
273
- enabled: z.boolean().default(true),
274
- /** The offer's id in the portal (e.g. `evs_8c1d…`). */
275
- service: z.string().min(1).optional(),
276
- /** A person's or a place's id in the portal (e.g. `evr_3f2a…`): what they provide online, booked with them. */
277
- resource: z.string().min(1).optional(),
278
- /** One event of it (e.g. `eve_…`, the Christmas concert): only that event's dates. Left out: all of them. */
279
- event: z.string().min(1).optional(),
280
- /** `button`: "Book now" for one date of a class or an event, with only the booker's details left
281
- * (the maintainer, 2026-11-24). Its next date with places, or `date`. Left out: the calendar or list. */
282
- look: z.enum(['button']).optional(),
283
- /** With `look: button`: one date of a repeating event ('YYYY-MM-DDTHH:MM', London). Left out: the next with places. */
284
- date: z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/).optional(),
285
- /** A list of dates across chosen classes and events, in place of `service` (the maintainer, 2026-11-24:
286
- * "a custom block where we pick what event types we want to group to display as a single list"):
287
- * each an offer booked by places (all its events), or one event of it. */
288
- list: z.array(z.object({ service: z.string().min(1), event: z.string().min(1).optional() })).min(1).max(20).optional(),
289
- /** Defaults to the offer's name (or the person's or place's, when the block names them alone). */
290
- title: z.string().optional(),
291
- /** Defaults to its description. */
292
- intro: z.string().optional(),
293
- /** Small print under the form (e.g. how to cancel). */
294
- note: z.string().optional(),
295
- /** The button's words ("Book"). */
296
- buttonLabel: z.string().max(40).optional(),
297
- });
298
-
299
- /** A contact form recipe. `fields` is generic (any labelled input list) so the
300
- * same recipe serves a contact page, an enquiry form, a sign-up, etc. `action`
301
- * is optional: the core ships no backend, so with none it renders a standard
302
- * semantic form a client later points at their own endpoint or a form service. */
303
- export const contactFormBlock = z.object({
304
- type: z.literal('contactForm'),
305
- enabled: z.boolean().default(true),
306
- title: z.string().optional(),
307
- intro: z.string().optional(),
308
- /** Form target. Omit for a non-wired form (e.g. the showcase demo). */
309
- action: z.string().optional(),
310
- method: z.enum(['post', 'get']).default('post'),
311
- submitLabel: z.string().default('Send message'),
312
- /** Small print under the form (a privacy line, a demo notice, …). */
313
- note: z.string().optional(),
314
- fields: z
315
- .array(
316
- z.object({
317
- name: z.string(),
318
- label: z.string(),
319
- type: z.enum(['text', 'email', 'tel', 'textarea']).default('text'),
320
- required: z.boolean().default(false),
321
- placeholder: z.string().optional(),
322
- })
323
- )
324
- .default([
325
- { name: 'name', label: 'Your name', type: 'text', required: true },
326
- { name: 'email', label: 'Email', type: 'email', required: true },
327
- { name: 'message', label: 'Message', type: 'textarea', required: true },
328
- ]),
329
- });
330
-
331
- /** Accordion — a generic expand/collapse list (title + body). Domain-free
332
- * sibling of `faq` (which carries question/answer semantics). */
333
- export const accordionBlock = z.object({
334
- type: z.literal('accordion'),
335
- enabled: z.boolean().default(true),
336
- title: z.string().optional(),
337
- items: z.array(z.object({ heading: z.string(), body: z.string() })).default([]),
338
- });
339
-
340
- /** Tiles — a curated card grid with five looks (outline / elevated / filled /
341
- * gradient / image). The look is chosen per-block via `variant`; radius, stroke
342
- * and elevation come from the global surface tokens, so tiles stay consistent
343
- * with every other card on the page. Each tile can link (the whole tile is the
344
- * target) and carry an icon, eyebrow, title, text and (for `image`) a photo. */
345
- export const tilesBlock = z.object({
346
- type: z.literal('tiles'),
347
- enabled: z.boolean().default(true),
348
- title: z.string().optional(),
349
- intro: z.string().optional(),
350
- columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).default(3),
351
- variant: z.enum(['outline', 'elevated', 'filled', 'gradient', 'image']).default('elevated'),
352
- /** Opt in to a pointer-following spotlight glow on hover (a small JS enhancement). */
353
- spotlight: z.boolean().default(false),
354
- tiles: z
355
- .array(
356
- z
357
- .object({
358
- icon: iconName.optional(),
359
- eyebrow: z.string().optional(),
360
- /** Optional only for a picture tile: with an image and no text, the tile is
361
- * the picture alone (no scrim) — a linked poster/logo — named by its alt. */
362
- title: z.string().optional(),
363
- text: z.string().optional(),
364
- href: z.string().optional(),
365
- /** The link cue on a linking tile ("Learn more" by default). */
366
- linkLabel: z.string().optional(),
367
- image: croppedImage.optional(),
368
- })
369
- .refine((t) => !!t.title || !!t.image, { message: 'A tile needs a title or an image', path: ['title'] })
370
- )
371
- .default([]),
372
- });
373
-
374
- /** Banner — a full-bleed feature band: a fixed/parallax background image with a
375
- * legibility scrim and a floating "shaded" content card (eyebrow + heading +
376
- * text + optional CTA) drifting over it. `align` places the card; `parallax`
377
- * pins the image so it slides under the content as you scroll (auto-disabled on
378
- * touch and under reduced-motion). The showpiece "not-dull" effect. */
379
- export const bannerBlock = z.object({
380
- type: z.literal('banner'),
381
- enabled: z.boolean().default(true),
382
- image: z.string(),
383
- eyebrow: z.string().optional(),
384
- title: z.string(),
385
- text: z.string().optional(),
386
- cta: z.object({ label: z.string(), href: z.string() }).optional(),
387
- overlay: z.number().min(0).max(100).default(50),
388
- align: z.enum(['start', 'center', 'end']).default('start'),
389
- parallax: z.boolean().default(true),
390
- /** Break the band out to the full viewport width (edge-to-edge, no rounded
391
- * corners); the card stays aligned to the page's content column. Great for a
392
- * homepage hero. Off by default (the band sits inside the content column). */
393
- fullBleed: z.boolean().default(false),
394
- });
395
-
396
- /** Stats — a band of headline numbers (value + label + optional note), over an
397
- * optional heading/intro and a chosen background. Composes the Stat primitive. */
398
- export const statsBlock = z.object({
399
- type: z.literal('stats'),
400
- enabled: z.boolean().default(true),
401
- title: z.string().optional(),
402
- intro: z.string().optional(),
403
- background: z.enum(['none', 'muted', 'accent']).default('muted'),
404
- columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).default(3),
405
- items: z.array(z.object({ value: z.string(), label: z.string(), description: z.string().optional() })).default([]),
406
- });
407
-
408
- /** Steps — a numbered process (how-it-works). `horizontal` shows connected cards
409
- * in a row; `vertical` a stacked timeline. Each step: title + optional text/icon. */
410
- export const stepsBlock = z.object({
411
- type: z.literal('steps'),
412
- enabled: z.boolean().default(true),
413
- title: z.string().optional(),
414
- intro: z.string().optional(),
415
- layout: z.enum(['horizontal', 'vertical']).default('horizontal'),
416
- items: z.array(z.object({ title: z.string(), text: z.string().optional(), icon: iconName.optional() })).default([]),
417
- });
418
-
419
- /** Pricing — a row of plan cards (name, price, period, feature list, CTA). One
420
- * plan may be `featured` (highlighted). */
421
- export const pricingBlock = z.object({
422
- type: z.literal('pricing'),
423
- enabled: z.boolean().default(true),
424
- title: z.string().optional(),
425
- intro: z.string().optional(),
426
- plans: z
427
- .array(
428
- z.object({
429
- name: z.string(),
430
- price: z.string(),
431
- period: z.string().optional(),
432
- description: z.string().optional(),
433
- features: z.array(z.string()).default([]),
434
- cta: z.object({ label: z.string(), href: z.string() }).optional(),
435
- featured: z.boolean().default(false),
436
- })
437
- )
438
- .default([]),
439
- });
440
-
441
- /** Logos — a "trusted by" wall of images; muted by default, colour on hover. */
442
- export const logosBlock = z.object({
443
- type: z.literal('logos'),
444
- enabled: z.boolean().default(true),
445
- title: z.string().optional(),
446
- items: z.array(z.object({ src: z.string(), alt: z.string().default(''), href: z.string().optional() })).default([]),
447
- });
448
-
449
- /** Tabs — labelled panels; one open at a time. Progressive: the first panel is
450
- * visible with no JS; a small script wires selection + ARIA. */
451
- export const tabsBlock = z.object({
452
- type: z.literal('tabs'),
453
- enabled: z.boolean().default(true),
454
- title: z.string().optional(),
455
- items: z
456
- .array(z.object({ label: z.string(), heading: z.string().optional(), text: z.string().optional(), image: z.object({ src: z.string(), alt: z.string().default('') }).optional() }))
457
- .default([]),
458
- });
459
-
460
- /** Announcement — a thin full-width bar (message + optional link), optionally
461
- * dismissible. Dismissal is remembered per `id` in localStorage. */
462
- export const announcementBlock = z.object({
463
- type: z.literal('announcement'),
464
- enabled: z.boolean().default(true),
465
- text: z.string(),
466
- link: z.object({ label: z.string(), href: z.string() }).optional(),
467
- tone: z.enum(['accent', 'neutral']).default('accent'),
468
- dismissible: z.boolean().default(true),
469
- /** localStorage key suffix so a dismissed bar stays dismissed. */
470
- id: z.string().default('default'),
471
- });
472
-
473
- /** Bento — an asymmetric (mixed-span) grid of cards. Each item picks a `size`
474
- * (sm / wide / tall / lg) and a `variant` look; the "living moodboard" layout. */
475
- export const bentoBlock = z.object({
476
- type: z.literal('bento'),
477
- enabled: z.boolean().default(true),
478
- title: z.string().optional(),
479
- intro: z.string().optional(),
480
- items: z
481
- .array(
482
- z.object({
483
- size: z.enum(['sm', 'wide', 'tall', 'lg']).default('sm'),
484
- variant: z.enum(['surface', 'filled', 'gradient', 'image']).default('surface'),
485
- icon: iconName.optional(),
486
- eyebrow: z.string().optional(),
487
- title: z.string(),
488
- text: z.string().optional(),
489
- href: z.string().optional(),
490
- image: croppedImage.optional(),
491
- })
492
- )
493
- .default([]),
494
- });
495
-
496
- /** Marquee — an infinite horizontal scroll of short phrases (a feature strip).
497
- * Pure-CSS transform loop (GPU); pauses on hover; static wrap under
498
- * reduced-motion. Decorative, so the moving track is aria-hidden. */
499
- export const marqueeBlock = z.object({
500
- type: z.literal('marquee'),
501
- enabled: z.boolean().default(true),
502
- items: z.array(z.string()).default([]),
503
- speed: z.enum(['slow', 'normal', 'fast']).default('normal'),
504
- });
505
-
506
- /** LatestPosts — a capability-backed recipe: the N most-recent published posts
507
- * (optionally filtered to a `tag`) as a card grid or a compact list, with a
508
- * "view all" link. Unlike other recipes it carries no content of its own — it
509
- * queries the client's posts collection at build time — so it's the bridge from
510
- * the posts capability into the page/block system (no per-client custom code). */
511
- export const latestPostsBlock = z.object({
512
- type: z.literal('latestPosts'),
513
- enabled: z.boolean().default(true),
514
- title: z.string().optional(),
515
- intro: z.string().optional(),
516
- limit: z.number().int().min(1).max(12).default(3),
517
- /** Filter to a single tag slug; omit for the main index (minus excluded tags). */
518
- tag: z.string().optional(),
519
- /** `grid` = full image cards; `list` = a compact miniature index (thumbnail +
520
- * category + date per row) that stays short even with many posts. */
521
- layout: z.enum(['grid', 'list']).default('grid'),
522
- /** In the `list` layout, badge the most-recent post as "New" when it was
523
- * published within this many days (0 disables it). Only the newest row is ever
524
- * flagged, so a frequently-posting site doesn't mark every row. Grid ignores it. */
525
- newWithinDays: z.number().int().min(0).max(365).default(14),
526
- /** "View all" target + label (the posts index by default). */
527
- viewAllHref: z.string().default('/posts'),
528
- viewAllLabel: z.string().default('All posts'),
529
- });
530
-
531
- /** MapEmbed — a consent-gated external map (e.g. Google Maps), the sibling of the
532
- * calendar embed: nothing loads from the provider until the visitor opts in, so
533
- * no third-party request fires on page load. `embedUrl` must be https; an unset
534
- * or unsafe URL degrades to a friendly note + optional "open in Maps" link. */
535
- export const mapEmbedBlock = z.object({
536
- type: z.literal('mapEmbed'),
537
- enabled: z.boolean().default(true),
538
- title: z.string().optional(),
539
- intro: z.string().optional(),
540
- /** The map iframe src (an https embed URL). Blank → a "not set up yet" note. */
541
- embedUrl: z.string().default(''),
542
- /** Link to open the location in the provider's app/site (a no-embed fallback). */
543
- publicUrl: z.string().default(''),
544
- height: z.number().int().min(150).max(1200).default(450),
545
- /** Provider name shown in the consent notice ("shared with …"). */
546
- provider: z.string().default('Google Maps'),
547
- });
548
-
549
- /** Table — a simple data table (header row + body rows) for structured data our
550
- * other blocks can't carry cleanly (fees, opening hours, a cookies list). Scrolls
551
- * horizontally on narrow screens so it never breaks the page width. */
552
- export const tableBlock = z.object({
553
- type: z.literal('table'),
554
- enabled: z.boolean().default(true),
555
- title: z.string().optional(),
556
- intro: z.string().optional(),
557
- columns: z.array(z.string()).default([]),
558
- rows: z.array(z.array(z.string())).default([]),
559
- });
560
-
561
- /** Notice — an inline highlighted info box (icon? + title? + body + link?) that
562
- * sets a passage apart from prose ("reporting a concern", "please note"). Two
563
- * tones (accent / neutral); the in-flow sibling of the corner StickyCallout. */
564
- export const noticeBlock = z.object({
565
- type: z.literal('notice'),
566
- enabled: z.boolean().default(true),
567
- tone: z.enum(['accent', 'neutral']).default('accent'),
568
- icon: iconName.optional(),
569
- title: z.string().optional(),
570
- text: z.string(),
571
- link: z.object({ label: z.string(), href: z.string() }).optional(),
572
- });
573
-
574
- /** MediaCards — a grid of rich content cards with the IMAGE as a header on top
575
- * (cover-cropped), then an optional icon badge, title, meta line, description and
576
- * CTA. The image-HEADER pattern (distinct from `tiles`, which puts the image
577
- * BEHIND the text) — for groups, team, services, events where the photo AND copy
578
- * must both stay legible. Whole card links when a card has `href`. */
579
- export const mediaCardsBlock = z.object({
580
- type: z.literal('mediaCards'),
581
- enabled: z.boolean().default(true),
582
- title: z.string().optional(),
583
- intro: z.string().optional(),
584
- columns: z.union([z.literal(2), z.literal(3)]).default(3),
585
- /** The image shape: landscape 16:9 (default), 4:3, 3:2, square, or portrait 3:4 (people). */
586
- ratio: z.enum(['16/9', '4/3', '3/2', '1/1', '3/4']).default('16/9'),
587
- cards: z
588
- .array(
589
- z.object({
590
- image: croppedImage.optional(),
591
- icon: iconName.optional(),
592
- title: z.string(),
593
- /** A short meta line shown as a pill (e.g. "Sundays 10:45 · Main hall"). */
594
- meta: z.string().optional(),
595
- text: z.string().optional(),
596
- href: z.string().optional(),
597
- /** CTA label when the card links (defaults to "Learn more"). */
598
- linkLabel: z.string().optional(),
599
- })
600
- )
601
- .default([]),
602
- });
603
-
604
- /** ContactCard — a branded "get in touch" band: display title + subtitle on the
605
- * left, contact channels as tappable pills on the right, a note across the bottom. */
606
- export const contactCardBlock = z.object({
607
- type: z.literal('contactCard'),
608
- enabled: z.boolean().default(true),
609
- eyebrow: z.string().optional(),
610
- title: z.string(),
611
- subtitle: z.string().optional(),
612
- note: z.string().optional(),
613
- items: z
614
- .array(
615
- z.object({
616
- icon: iconName.optional(),
617
- value: z.string(),
618
- href: z.string().optional(),
619
- })
620
- )
621
- .default([]),
622
- });
623
-
624
- /** Locations ("Where to find us") — location tiles, each a consent-gated map over
625
- * a name / address / directions. https embed URLs only (isSafeEmbedUrl). */
626
- export const locationsBlock = z.object({
627
- type: z.literal('locations'),
628
- enabled: z.boolean().default(true),
629
- title: z.string().optional(),
630
- intro: z.string().optional(),
631
- columns: z.union([z.literal(1), z.literal(2)]).default(2),
632
- provider: z.string().default('Google Maps'),
633
- items: z
634
- .array(
635
- z.object({
636
- name: z.string(),
637
- address: z.string().optional(),
638
- embedUrl: z.string(),
639
- directionsUrl: z.string().optional(),
640
- })
641
- )
642
- .default([]),
643
- });
644
-
645
- /** Video — a consent-gated YouTube / Vimeo player (incl. a channel's live stream).
646
- * `url` is the ordinary link an editor would paste; it becomes a privacy-friendly
647
- * embed (lib/video). An unrecognised link shows as a plain "watch" link. */
648
- export const videoBlock = z.object({
649
- type: z.literal('video'),
650
- enabled: z.boolean().default(true),
651
- title: z.string().optional(),
652
- caption: z.string().optional(),
653
- /** A short note under the player (inline markdown), e.g. a live stream's schedule. */
654
- note: z.string().optional(),
655
- url: z.string(),
656
- ratio: z.enum(['16/9', '4/3', '1/1', '9/16']).default('16/9'),
657
- });
658
-
659
- /** Documents — a list of files (newsletters, minutes, policies, forms): type badge,
660
- * title, date and note per row, newest first, optionally grouped by year. `date`
661
- * is YYYY-MM-DD. Files open in the browser's own viewer, not an in-page one. */
662
- export const documentsBlock = z.object({
663
- type: z.literal('documents'),
664
- enabled: z.boolean().default(true),
665
- title: z.string().optional(),
666
- intro: z.string().optional(),
667
- groupByYear: z.boolean().default(false),
668
- items: z
669
- .array(
670
- z.object({
671
- title: z.string(),
672
- file: z.string(),
673
- date: z.string().optional(),
674
- note: z.string().optional(),
675
- })
676
- )
677
- .default([]),
678
- });
679
-
680
- /** LinkRow — a titled row of contact or reference links as tappable pills (phone, email,
681
- * web), each with the icon its link implies, plus an optional intro and footnote. For a
682
- * contact who isn't worth a whole contact card (e.g. "Vocations: phone · email · site"). */
683
- export const linkRowBlock = z.object({
684
- type: z.literal('linkRow'),
685
- enabled: z.boolean().default(true),
686
- title: z.string().optional(),
687
- intro: z.string().optional(),
688
- links: z.array(z.object({ label: z.string(), href: z.string() })).min(1),
689
- note: z.string().optional(),
690
- });
691
-
692
- /** Document — a policy or legal text as ONE block: sections numbered automatically, a
693
- * contents list linking to each (sticky beside the text on wide screens), an optional
694
- * "last updated" date (YYYY-MM-DD), and print-friendly. Section bodies take prose
695
- * formatting; `items` add a list. Replaces dozens of hand-numbered headings + paragraphs. */
696
- export const documentBlock = z.object({
697
- type: z.literal('document'),
698
- enabled: z.boolean().default(true),
699
- intro: z.string().optional(),
700
- updated: z.string().optional(),
701
- numbered: z.boolean().default(true),
702
- toc: z.boolean().default(true),
703
- sections: z
704
- .array(z.object({ title: z.string(), body: z.string().optional(), items: z.array(z.string()).optional() }))
705
- .min(1),
706
- });
707
-
708
- /** Timetable — weekly times for one or more places (worship times, opening hours,
709
- * sessions, classes). `cards`: a card per place, days with no times left out, notes
710
- * (inline markdown) under each. `table`: places side by side, days down the side. */
711
- export const timetableBlock = z.object({
712
- type: z.literal('timetable'),
713
- enabled: z.boolean().default(true),
714
- title: z.string().optional(),
715
- intro: z.string().optional(),
716
- layout: z.enum(['cards', 'table']).default('cards'),
717
- places: z
718
- .array(
719
- z.object({
720
- name: z.string(),
721
- address: z.string().optional(),
722
- href: z.string().optional(),
723
- schedule: z.array(z.object({ day: z.string(), times: z.array(z.string()).default([]) })).default([]),
724
- notes: z.string().optional(),
725
- })
726
- )
727
- .min(1),
728
- });
729
-
730
- /** Contacts — a compact directory of people or offices: role as the card title, phone and
731
- * email as tap targets (email with an optional subject), address and hours, and a shared
732
- * note per group (e.g. office hours) instead of repeating it on every card. */
733
- export const contactsBlock = z.object({
734
- type: z.literal('contacts'),
735
- enabled: z.boolean().default(true),
736
- title: z.string().optional(),
737
- intro: z.string().optional(),
738
- groups: z
739
- .array(
740
- z.object({
741
- heading: z.string().optional(),
742
- note: z.string().optional(),
743
- contacts: z
744
- .array(
745
- z.object({
746
- role: z.string().optional(),
747
- name: z.string().optional(),
748
- phone: z.string().optional(),
749
- email: z.string().optional(),
750
- emailSubject: z.string().optional(),
751
- address: z.string().optional(),
752
- hours: z.string().optional(),
753
- })
754
- .refine((c) => !!c.role || !!c.name, { message: 'A contact needs a role or a name', path: ['role'] })
755
- )
756
- .min(1),
757
- })
758
- )
759
- .min(1),
760
- });
761
-
762
- /** MediaText — an image beside its text (start or end), stacking on a phone. The text takes
763
- * prose formatting; the image keeps its shape (`ratio` crops to a set shape); optional CTA. */
764
- export const mediaTextBlock = z.object({
765
- type: z.literal('mediaText'),
766
- enabled: z.boolean().default(true),
767
- title: z.string().optional(),
768
- text: z.string(),
769
- image: z.object({ src: z.string(), alt: z.string().default(''), caption: z.string().optional(), focus: focusPosition.optional() }),
770
- imageSide: z.enum(['start', 'end']).default('end'),
771
- ratio: z.enum(['auto', '1/1', '4/3', '3/2', '16/9']).default('auto'),
772
- cta: z.object({ label: z.string(), href: z.string() }).optional(),
773
- });
774
-
775
- export type RecipeBlock =
776
- | z.infer<typeof heroBlock>
777
- | z.infer<typeof featureCardsBlock>
778
- | z.infer<typeof ctaBlock>
779
- | z.infer<typeof faqBlock>
780
- | z.infer<typeof galleryBlock>
781
- | z.infer<typeof testimonialBlock>
782
- | z.infer<typeof contactFormBlock>
783
- | z.infer<typeof formBlock>
784
- | z.infer<typeof payBlock>
785
- | z.infer<typeof bookBlock>
786
- | z.infer<typeof accordionBlock>
787
- | z.infer<typeof tilesBlock>
788
- | z.infer<typeof bannerBlock>
789
- | z.infer<typeof statsBlock>
790
- | z.infer<typeof stepsBlock>
791
- | z.infer<typeof pricingBlock>
792
- | z.infer<typeof logosBlock>
793
- | z.infer<typeof tabsBlock>
794
- | z.infer<typeof announcementBlock>
795
- | z.infer<typeof bentoBlock>
796
- | z.infer<typeof marqueeBlock>
797
- | z.infer<typeof latestPostsBlock>
798
- | z.infer<typeof mapEmbedBlock>
799
- | z.infer<typeof tableBlock>
800
- | z.infer<typeof noticeBlock>
801
- | z.infer<typeof mediaCardsBlock>
802
- | z.infer<typeof contactCardBlock>
803
- | z.infer<typeof locationsBlock>
804
- | z.infer<typeof videoBlock>
805
- | z.infer<typeof documentsBlock>
806
- | z.infer<typeof linkRowBlock>
807
- | z.infer<typeof documentBlock>
808
- | z.infer<typeof timetableBlock>
809
- | z.infer<typeof contactsBlock>
810
- | z.infer<typeof mediaTextBlock>;
811
-
812
- /* ── Level-1 layout / container primitives ─────────────────────────────────
813
- * These hold child blocks, so the schema is **recursive** (a container's
814
- * `blocks` field is the same block union). TypeScript can't infer a type through
815
- * `z.lazy`, so the recursive `Block` type is declared explicitly and the union
816
- * is cast to it. Containers are how primitives compose into layouts (and, later,
817
- * recipes). */
818
- export interface SectionBlock {
819
- type: 'section';
820
- enabled: boolean;
821
- background: 'none' | 'muted' | 'accent';
822
- width: 'normal' | 'wide' | 'full';
823
- blocks: Block[];
824
- }
825
- export interface GridBlock {
826
- type: 'grid';
827
- enabled: boolean;
828
- columns: 2 | 3 | 4;
829
- gap: 'sm' | 'md' | 'lg';
830
- blocks: Block[];
831
- }
832
- export interface StackBlock {
833
- type: 'stack';
834
- enabled: boolean;
835
- gap: 'sm' | 'md' | 'lg';
836
- blocks: Block[];
837
- }
838
-
839
- export type LeafBlock =
840
- | z.infer<typeof headingBlock>
841
- | z.infer<typeof proseBlock>
842
- | z.infer<typeof imageBlock>
843
- | z.infer<typeof buttonBlock>
844
- | z.infer<typeof quoteBlock>
845
- | z.infer<typeof dividerBlock>
846
- | z.infer<typeof spacerBlock>
847
- | z.infer<typeof badgeBlock>
848
- | z.infer<typeof statBlock>
849
- | z.infer<typeof listBlock>;
850
-
851
- /** The full recursive block type: leaf primitives + layout containers. */
852
- /**
853
- * Alignment overrides every block takes, so a page's look can follow a client's preference
854
- * from the page data alone. Defaults are the sensible visual choice (a block follows its
855
- * page / section; a recipe's section title is centred).
856
- * - `align`: re-aligns the whole block — title, intro, text, and the icons, pills and
857
- * buttons in its cards — overriding the page / section for this one block.
858
- * - `headingAlign`: just a recipe's title + intro (e.g. a start-aligned title over centred
859
- * cards). Recipes without a section title ignore it.
860
- * `heading`, `banner` and `section` already had `align` with this meaning and keep it.
861
- */
862
- const alignOption = z.enum(['start', 'center', 'end']);
863
- export interface BlockLayout {
864
- align?: 'start' | 'center' | 'end';
865
- headingAlign?: 'start' | 'center' | 'end';
866
- }
867
- function withLayout<T extends z.AnyZodObject>(block: T): z.AnyZodObject {
868
- const shape = block.shape as Record<string, unknown>;
869
- return block.extend({
870
- ...('align' in shape ? {} : { align: alignOption.optional() }),
871
- headingAlign: alignOption.optional(),
872
- });
873
- }
874
-
875
- export type Block = (LeafBlock | RecipeBlock | SectionBlock | GridBlock | StackBlock) & BlockLayout;
876
- export type BlockType = Block['type'];
877
-
878
- export const sectionBlock = z.object({
879
- type: z.literal('section'),
880
- enabled: z.boolean().default(true),
881
- background: z.enum(['none', 'muted', 'accent']).default('none'),
882
- width: z.enum(['normal', 'wide', 'full']).default('normal'),
883
- /** Override the page's content alignment for this section's subtree. */
884
- align: z.enum(['start', 'center', 'end']).optional(),
885
- blocks: z.lazy(() => z.array(blockSchema)).default([]),
886
- });
887
-
888
- export const gridBlock = z.object({
889
- type: z.literal('grid'),
890
- enabled: z.boolean().default(true),
891
- columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).default(2),
892
- gap: z.enum(['sm', 'md', 'lg']).default('md'),
893
- blocks: z.lazy(() => z.array(blockSchema)).default([]),
894
- });
895
-
896
- export const stackBlock = z.object({
897
- type: z.literal('stack'),
898
- enabled: z.boolean().default(true),
899
- gap: z.enum(['sm', 'md', 'lg']).default('md'),
900
- blocks: z.lazy(() => z.array(blockSchema)).default([]),
901
- });
902
-
903
- /** The block palette: leaf primitives + layout containers. A discriminated union
904
- * on `type` — the AI's + CMS's contract and the renderer's registry key. Adding
905
- * a member without a matching BlockRenderer registry entry is a TypeScript error
906
- * (the exhaustiveness guard against a silent-undefined render crash). Cast to
907
- * the recursive `Block` type because `z.lazy` fields can't be inferred. */
908
- export const blockSchema = z.discriminatedUnion(
909
- 'type',
910
- [
911
- headingBlock,
912
- proseBlock,
913
- imageBlock,
914
- buttonBlock,
915
- quoteBlock,
916
- dividerBlock,
917
- spacerBlock,
918
- badgeBlock,
919
- statBlock,
920
- listBlock,
921
- heroBlock,
922
- featureCardsBlock,
923
- ctaBlock,
924
- faqBlock,
925
- galleryBlock,
926
- testimonialBlock,
927
- contactFormBlock,
928
- formBlock,
929
- payBlock,
930
- bookBlock,
931
- accordionBlock,
932
- tilesBlock,
933
- bannerBlock,
934
- statsBlock,
935
- stepsBlock,
936
- pricingBlock,
937
- logosBlock,
938
- tabsBlock,
939
- announcementBlock,
940
- bentoBlock,
941
- marqueeBlock,
942
- latestPostsBlock,
943
- mapEmbedBlock,
944
- tableBlock,
945
- noticeBlock,
946
- mediaCardsBlock,
947
- contactCardBlock,
948
- locationsBlock,
949
- videoBlock,
950
- documentsBlock,
951
- linkRowBlock,
952
- documentBlock,
953
- timetableBlock,
954
- contactsBlock,
955
- mediaTextBlock,
956
- sectionBlock,
957
- gridBlock,
958
- stackBlock,
959
- ].map(withLayout) as unknown as [z.AnyZodObject, z.AnyZodObject, ...z.AnyZodObject[]],
960
- ) as unknown as z.ZodType<Block>;
961
-
962
- /** A page = metadata + an ordered list of blocks. Stored as JSON in the client
963
- * repo; the AI composes it, a human verifies. This is also the schema of the
964
- * `pages` collection that the client's `[...slug].astro` catch-all routes over,
965
- * so one page = one JSON file (its filename is the URL slug). */
966
- export const pageSchema = z.object({
967
- title: z.string(),
968
- description: z.string().optional(),
969
- /** Preloaded as the LCP image (passed to the layout) when set. */
970
- heroImage: z.string().optional(),
971
- /**
972
- * Template-level content alignment — the default for text-bearing blocks on the
973
- * page (headings, prose, quote). Cascades as `--content-align` so every recipe
974
- * inherits one coherent alignment instead of each hard-coding its own. A
975
- * `section` block can override it for its subtree; a `heading` can override per
976
- * block. `start` (left) is the readable default for long-form; `center` suits
977
- * short, hero-led pages.
978
- */
979
- align: z.enum(['start', 'center', 'end']).default('start'),
980
- /**
981
- * Provenance — the ferst-library template this page was instantiated from.
982
- * The triangular model (docs/BLOCK-ARCHITECTURE.md §5): lego box → a template
983
- * stored in the library → each client page links a `templateId`. The client
984
- * repo never depends on the library; this is just a design-time back-reference
985
- * so a template's lineage/variants stay traceable platform-side. Optional — a
986
- * bespoke page may have none.
987
- */
988
- templateId: z.string().optional(),
989
- /**
990
- * Editor change-requests captured in the CMS — the seed of AI-driven editing
991
- * ([[ferst_editing_ai_first_pdlc]]): rather than let editors edit block JSON
992
- * directly (easy to break), they describe a desired change against the page and
993
- * it's stored here for an agent to action later → PR → human verify. NEVER
994
- * rendered; carried through the schema so a CMS save preserves it.
995
- */
996
- requests: z
997
- .array(
998
- z.object({
999
- text: z.string(),
1000
- /** Stamped by the platform when the request becomes an issue in the site's repo:
1001
- * when, who asked (from their session) and the issue number. */
1002
- at: z.string().optional(),
1003
- by: z.string().optional(),
1004
- issue: z.number().int().optional(),
1005
- status: z.enum(['open', 'done']).default('open'),
1006
- }),
1007
- )
1008
- .default([]),
1009
- /** Keep the JSON in the repo but exclude it from the build. */
1010
- draft: z.boolean().default(false),
1011
- blocks: z.array(blockSchema).default([]),
1012
- });
1013
- export type Page = z.infer<typeof pageSchema>;
1014
-
1015
- /** Every block type id, derived from the union so it stays in sync — used for
1016
- * gallery coverage, CMS config generation, docs, etc. */
1017
- export const blockTypes = (
1018
- blockSchema as unknown as { options: ReadonlyArray<{ shape: { type: { value: BlockType } } }> }
1019
- ).options.map((o) => o.shape.type.value);
1020
-
1021
- /** Blocks whose content comes from the Ferst platform at build time (a form, an item to pay for, an offer to book).
1022
- * The public showcase can't render them without the platform, so its galleries show the
1023
- * look through their local twin instead (`form` renders with the contactForm recipe). */
1024
- export const platformBlockTypes: readonly BlockType[] = ['form', 'pay', 'book'];
1
+ import { z } from 'zod';
2
+ import { iconKeys, isIconKey } from '../lib/icons';
3
+
4
+ /**
5
+ * The block palette — the heart of the Ferst page model (see
6
+ * docs/BLOCK-ARCHITECTURE.md). A page is an ordered list of typed blocks stored
7
+ * as JSON; a Zod **discriminated union** on `type` is the single contract the AI
8
+ * composes against, the CMS validates, and the renderer's registry keys on.
9
+ *
10
+ * This is an original design of the *mechanism*, built from scratch. It starts
11
+ * with **Level-1 primitives** only; recipes (Level 2) and
12
+ * page templates (Level 3) layer on top later, and layout/container primitives
13
+ * (Section/Grid/Stack, which nest child blocks) are a deliberate next slice.
14
+ */
15
+
16
+ /** Every block shares a `type` discriminant and an `enabled` flag (keep a block
17
+ * in the page data without rendering it). */
18
+ /** An icon name from the engine's registry (lib/icons). An unknown name fails validation,
19
+ * and so the build, with the valid names listed, instead of rendering nothing silently. */
20
+ const iconName = z.string().refine(isIconKey, (v) => ({
21
+ message: `Unknown icon "${v}". Use one of: ${iconKeys.join(', ')}.`,
22
+ }));
23
+
24
+ export const headingBlock = z.object({
25
+ type: z.literal('heading'),
26
+ enabled: z.boolean().default(true),
27
+ text: z.string(),
28
+ level: z.number().int().min(1).max(6).default(2),
29
+ /** Explicit per-heading alignment. OMITTED ⇒ inherit the page/section
30
+ * `--content-align` cascade; set it only to override for this one heading. */
31
+ align: z.enum(['start', 'center', 'end']).optional(),
32
+ /** Paint the text with a brand → accent-2 gradient (falls back to solid ink
33
+ * where background-clip:text is unsupported). A per-block opt-in effect. */
34
+ gradient: z.boolean().default(false),
35
+ });
36
+
37
+ export const proseBlock = z.object({
38
+ type: z.literal('prose'),
39
+ enabled: z.boolean().default(true),
40
+ /** Blank lines separate paragraphs; `- ` / `1. ` lines make lists; inline
41
+ * `[links](href)` (incl. tel:/mailto:), `**bold**` and `*italic*` (lib/prose.ts). */
42
+ text: z.string(),
43
+ /** `lead` = the page's introduction: larger and quieter than body text, for the
44
+ * paragraph straight under the hero. */
45
+ variant: z.enum(['body', 'lead']).default('body'),
46
+ });
47
+
48
+ /** How a grid's ragged last row lays out (lib/gridRows). Rows are planned for you: full rows
49
+ * stay full, and a shorter last row is tidied. `auto` (default) spreads its items across the
50
+ * row when that makes them at most a third wider, else centres them at the same width;
51
+ * `fill` always spreads them; `center` always keeps the same width, centred. */
52
+ export const lastRow = z.enum(['auto', 'fill', 'center']).default('auto');
53
+
54
+ /** Which part of an image stays in view when it's cropped to a shape: one or two positions,
55
+ * keywords or percentages (`center 25%` keeps a face in a portrait, `top`, `left 20%`).
56
+ * Positions only, so no other CSS can get in. Default `center`. */
57
+ export const focusPosition = z
58
+ .string()
59
+ .regex(/^(?:left|center|right|top|bottom|\d{1,3}%)(?: (?:left|center|right|top|bottom|\d{1,3}%))?$/, 'focus is one or two of left / center / right / top / bottom / a percentage, e.g. "center 25%"');
60
+ /** An image a block may crop to a shape, with the part to keep in view. */
61
+ const croppedImage = z.object({ src: z.string(), alt: z.string().default(''), focus: focusPosition.optional() });
62
+
63
+ export const imageBlock = z.object({
64
+ type: z.literal('image'),
65
+ enabled: z.boolean().default(true),
66
+ src: z.string(),
67
+ alt: z.string().default(''),
68
+ caption: z.string().optional(),
69
+ /** Canonical framing options — a small, clear set the AI or a client picks
70
+ * from, rather than free-form CSS. Corners follow the site by default. */
71
+ radius: z.enum(['none', 'soft', 'round']).default('soft'),
72
+ shadow: z.boolean().default(false),
73
+ border: z.boolean().default(false),
74
+ ratio: z.enum(['auto', 'square', '4/3', '3/2', '16/9', '21/9']).default('auto'),
75
+ /** Which part stays in view when `ratio` crops it. */
76
+ focus: focusPosition.optional(),
77
+ /** Opt in to a soft clip-path reveal as the image scrolls into view
78
+ * (progressive: no motion under reduced-motion or unsupported browsers). */
79
+ reveal: z.boolean().default(false),
80
+ });
81
+
82
+ export const buttonBlock = z.object({
83
+ type: z.literal('button'),
84
+ enabled: z.boolean().default(true),
85
+ label: z.string(),
86
+ href: z.string(),
87
+ /** Role, not decoration: primary action, secondary action, filled CTA, or a
88
+ * quiet ghost. Shape (radius) is a site-wide token, not a per-button choice. */
89
+ variant: z.enum(['primary', 'secondary', 'cta', 'ghost']).default('primary'),
90
+ });
91
+
92
+ export const quoteBlock = z.object({
93
+ type: z.literal('quote'),
94
+ enabled: z.boolean().default(true),
95
+ text: z.string(),
96
+ cite: z.string().optional(),
97
+ });
98
+
99
+ export const dividerBlock = z.object({
100
+ type: z.literal('divider'),
101
+ enabled: z.boolean().default(true),
102
+ });
103
+
104
+ export const spacerBlock = z.object({
105
+ type: z.literal('spacer'),
106
+ enabled: z.boolean().default(true),
107
+ size: z.enum(['sm', 'md', 'lg']).default('md'),
108
+ });
109
+
110
+ export const badgeBlock = z.object({
111
+ type: z.literal('badge'),
112
+ enabled: z.boolean().default(true),
113
+ text: z.string(),
114
+ tone: z.enum(['neutral', 'accent']).default('accent'),
115
+ });
116
+
117
+ export const statBlock = z.object({
118
+ type: z.literal('stat'),
119
+ enabled: z.boolean().default(true),
120
+ value: z.string(),
121
+ label: z.string(),
122
+ });
123
+
124
+ export const listBlock = z.object({
125
+ type: z.literal('list'),
126
+ enabled: z.boolean().default(true),
127
+ /** bullet (disc) · number (ordered) · check (ticked, uses the check icon). */
128
+ style: z.enum(['bullet', 'number', 'check']).default('bullet'),
129
+ items: z.array(z.string()).default([]),
130
+ });
131
+
132
+ /* ── Level 2 — Recipes (curated, opinionated compositions of primitives) ─────
133
+ * A recipe is a first-class block in the same union, but it renders a *designed*
134
+ * layout (composing primitives internally) rather than a bare element. Locked
135
+ * components so quality can't drift (BLOCK-ARCHITECTURE §6). */
136
+ export const heroBlock = z.object({
137
+ type: z.literal('hero'),
138
+ enabled: z.boolean().default(true),
139
+ eyebrow: z.string().optional(),
140
+ title: z.string(),
141
+ /** The title set as a picture: a designed wordmark or logo, ideally on a transparent
142
+ * background. It sits inside the page's h1 in place of the title text, and `title` is its
143
+ * description, so screen readers and search engines still read the name. `width`: about
144
+ * 320 / 520 / 760px on desktop (`small` / `medium` / `large`), capped to the screen on
145
+ * phones and never cropped; the picture keeps its own shape. `shadow` adds the soft logo
146
+ * shadow, so light lettering stays readable over a busy photo. Works in every layout. */
147
+ titleImage: z
148
+ .object({
149
+ src: z.string(),
150
+ width: z.enum(['small', 'medium', 'large']).default('medium'),
151
+ shadow: z.boolean().default(false),
152
+ })
153
+ .optional(),
154
+ /** The title stays the page's h1, read by screen readers and search engines, but isn't
155
+ * shown: for a picture that already carries the name (e.g. a poster, `media.fit:
156
+ * "contain"`). With a `titleImage` it changes nothing: that picture is already the
157
+ * visible title, and it stays. */
158
+ titleHidden: z.boolean().default(false),
159
+ subtitle: z.string().optional(),
160
+ cta: z.object({ label: z.string(), href: z.string() }).optional(),
161
+ image: z.object({ src: z.string(), alt: z.string().default('') }).optional(),
162
+ /** Background media for the `media` layout, in order of precedence: a looping
163
+ * muted `video` (a hosted file, or a YouTube / Vimeo link — embedded only after
164
+ * cookie consent, showing `poster` until then), a slow crossfade through `images`
165
+ * (2+), or one `image`.
166
+ * `overlay` (0–100) is the darkening scrim so text stays legible; `poster` is
167
+ * the video's still (and what reduced-motion visitors see). Moving backgrounds
168
+ * get a pause button and stay still under prefers-reduced-motion. */
169
+ media: z
170
+ .object({
171
+ image: z.string().optional(),
172
+ images: z.array(z.string()).max(8).optional(),
173
+ video: z.string().optional(),
174
+ poster: z.string().optional(),
175
+ overlay: z.number().min(0).max(100).default(45),
176
+ /** How the picture fills the band: `cover` (default) fills it, cropped to fit, with
177
+ * the words over it; `contain` shows it whole, never cropped, at its own shape (edge
178
+ * to edge with `size: "screen"` or `fullBleed`), the band's height following the
179
+ * picture, with no scrim and no parallax, and the words below it. For a designed
180
+ * poster with its own lettering. A video always covers. */
181
+ fit: z.enum(['cover', 'contain']).default('cover'),
182
+ /** Where the background leads: e.g. the full video on YouTube. The whole
183
+ * background becomes a link (opens in a new tab — the app on phones), with
184
+ * a visible "Watch the full video" cue; the text and CTA stay on top. */
185
+ link: z.string().optional(),
186
+ linkLabel: z.string().optional(),
187
+ })
188
+ .optional(),
189
+ layout: z.enum(['centered', 'split', 'media']).default('centered'),
190
+ /** How much of the screen a `media` hero takes: `compact` (a narrow band for a short,
191
+ * wide header strip, e.g. 1000 × 175), `standard` (a band), `tall`, or `screen` — the
192
+ * full first screen, edge to edge (e.g. a video opener). */
193
+ size: z.enum(['compact', 'standard', 'tall', 'screen']).default('standard'),
194
+ /** A `media` hero runs edge to edge across the screen, like a full-bleed banner
195
+ * (`screen` always does). */
196
+ fullBleed: z.boolean().default(false),
197
+ /** Which part of the background image shows when it's cropped: one or two positions,
198
+ * keywords or percentages (e.g. `center 30%`, `top`, `left 20%`). Default `center`. */
199
+ focus: focusPosition.optional(),
200
+ /** A `media` hero's background drifts more slowly than the page as it scrolls (any
201
+ * background: image, slides or video). Off on touch devices and under reduced motion. */
202
+ parallax: z.boolean().default(false),
203
+ /** Ambient background for centered/split heroes: `mesh` = a soft, slowly
204
+ * drifting brand gradient behind the text (static under reduced-motion). */
205
+ background: z.enum(['none', 'mesh']).default('none'),
206
+ });
207
+
208
+ export const featureCardsBlock = z.object({
209
+ type: z.literal('featureCards'),
210
+ enabled: z.boolean().default(true),
211
+ lastRow,
212
+ title: z.string().optional(),
213
+ intro: z.string().optional(),
214
+ columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).default(3),
215
+ cards: z
216
+ .array(
217
+ z.object({
218
+ icon: iconName.optional(),
219
+ title: z.string(),
220
+ text: z.string().optional(),
221
+ href: z.string().optional(),
222
+ })
223
+ )
224
+ .default([]),
225
+ });
226
+
227
+ export const ctaBlock = z.object({
228
+ type: z.literal('cta'),
229
+ enabled: z.boolean().default(true),
230
+ title: z.string(),
231
+ text: z.string().optional(),
232
+ cta: z.object({ label: z.string(), href: z.string() }),
233
+ background: z.enum(['muted', 'accent', 'mesh']).default('accent'),
234
+ });
235
+
236
+ export const faqBlock = z.object({
237
+ type: z.literal('faq'),
238
+ enabled: z.boolean().default(true),
239
+ title: z.string().optional(),
240
+ items: z.array(z.object({ question: z.string(), answer: z.string() })).default([]),
241
+ });
242
+
243
+ export const galleryBlock = z.object({
244
+ type: z.literal('gallery'),
245
+ enabled: z.boolean().default(true),
246
+ lastRow,
247
+ columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).default(3),
248
+ images: z
249
+ .array(z.object({ src: z.string(), alt: z.string().default(''), caption: z.string().optional() }))
250
+ .default([]),
251
+ });
252
+
253
+ export const testimonialBlock = z.object({
254
+ type: z.literal('testimonial'),
255
+ enabled: z.boolean().default(true),
256
+ quote: z.string(),
257
+ author: z.string(),
258
+ role: z.string().optional(),
259
+ avatar: z.object({ src: z.string(), alt: z.string().default('') }).optional(),
260
+ });
261
+
262
+ /** One of the organisation's forms from the Ferst portal, placed by id. Its fields, button
263
+ * and submit address are read from the platform at build time (lib/forms), so a change
264
+ * in the portal reaches the site on its next build. List a site's forms with
265
+ * `npx ferst-modules`. Title defaults to the form's name. */
266
+ export const formBlock = z.object({
267
+ type: z.literal('form'),
268
+ enabled: z.boolean().default(true),
269
+ /** The form's id in the portal (e.g. `form_8c1d…`). */
270
+ form: z.string().min(1),
271
+ title: z.string().optional(),
272
+ intro: z.string().optional(),
273
+ /** Small print under the form (e.g. a privacy line). */
274
+ note: z.string().optional(),
275
+ });
276
+
277
+ /** A payment for one of the organisation's items, from the Ferst Payments module ("Course fee",
278
+ * £40). The block names the item; its name and price are the organisation's, read from the
279
+ * platform at build time (lib/pay) and again in the browser, never written here: the platform
280
+ * reads the price itself when the visitor pays. The visitor gives a name and email and pays on
281
+ * Stripe's page. List what a site can take payment for with `npx ferst-modules`. */
282
+ export const payBlock = z.object({
283
+ type: z.literal('pay'),
284
+ enabled: z.boolean().default(true),
285
+ /** The item's id in the portal (e.g. `pi_8c1d…`). */
286
+ item: z.string().min(1),
287
+ /** Defaults to the item's name. */
288
+ title: z.string().optional(),
289
+ intro: z.string().optional(),
290
+ /** Small print under the button (e.g. what happens after paying). */
291
+ note: z.string().optional(),
292
+ /** The button's words; the price follows them ("Pay £40"). */
293
+ buttonLabel: z.string().max(40).optional(),
294
+ });
295
+
296
+ /** Visitors book a time for one of the organisation's offers, from the Ferst Events and bookings
297
+ * module ("Haircut", 30 minutes). The block names the offer, a person or a place (everything they
298
+ * provide online, the visitor choosing which), or both (that offer with them only); one of the
299
+ * two is needed. Names, lengths, prices, who gives it and the free times are the organisation's,
300
+ * read from the platform (lib/book), never written here. A picked time is held for the visitor
301
+ * while they give their details, then booked; the visitor is emailed. List what a site takes
302
+ * bookings for, and who provides it, with `npx ferst-modules`. */
303
+ export const bookBlock = z.object({
304
+ type: z.literal('book'),
305
+ enabled: z.boolean().default(true),
306
+ /** The offer's id in the portal (e.g. `evs_8c1d…`). */
307
+ service: z.string().min(1).optional(),
308
+ /** A person's or a place's id in the portal (e.g. `evr_3f2a…`): what they provide online, booked with them. */
309
+ resource: z.string().min(1).optional(),
310
+ /** One event of it (e.g. `eve_…`, the Christmas concert): only that event's dates. Left out: all of them. */
311
+ event: z.string().min(1).optional(),
312
+ /** `button`: "Book now" for one date of a class or an event, with only the booker's details left
313
+ * (the maintainer, 2026-11-24). Its next date with places, or `date`. Left out: the calendar or list. */
314
+ look: z.enum(['button']).optional(),
315
+ /** With `look: button`: one date of a repeating event ('YYYY-MM-DDTHH:MM', London). Left out: the next with places. */
316
+ date: z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/).optional(),
317
+ /** A list of dates across chosen classes and events, in place of `service` (the maintainer, 2026-11-24:
318
+ * "a custom block where we pick what event types we want to group to display as a single list"):
319
+ * each an offer booked by places (all its events), or one event of it. */
320
+ list: z.array(z.object({ service: z.string().min(1), event: z.string().min(1).optional() })).min(1).max(20).optional(),
321
+ /** Defaults to the offer's name (or the person's or place's, when the block names them alone). */
322
+ title: z.string().optional(),
323
+ /** Defaults to its description. */
324
+ intro: z.string().optional(),
325
+ /** Small print under the form (e.g. how to cancel). */
326
+ note: z.string().optional(),
327
+ /** The button's words ("Book"). */
328
+ buttonLabel: z.string().max(40).optional(),
329
+ });
330
+
331
+ /** A contact form recipe. `fields` is generic (any labelled input list) so the
332
+ * same recipe serves a contact page, an enquiry form, a sign-up, etc. `action`
333
+ * is optional: the core ships no backend, so with none it renders a standard
334
+ * semantic form a client later points at their own endpoint or a form service. */
335
+ export const contactFormBlock = z.object({
336
+ type: z.literal('contactForm'),
337
+ enabled: z.boolean().default(true),
338
+ title: z.string().optional(),
339
+ intro: z.string().optional(),
340
+ /** Form target. Omit for a non-wired form (e.g. the showcase demo). */
341
+ action: z.string().optional(),
342
+ method: z.enum(['post', 'get']).default('post'),
343
+ submitLabel: z.string().default('Send message'),
344
+ /** Small print under the form (a privacy line, a demo notice, …). */
345
+ note: z.string().optional(),
346
+ fields: z
347
+ .array(
348
+ z.object({
349
+ name: z.string(),
350
+ label: z.string(),
351
+ type: z.enum(['text', 'email', 'tel', 'textarea']).default('text'),
352
+ required: z.boolean().default(false),
353
+ placeholder: z.string().optional(),
354
+ })
355
+ )
356
+ .default([
357
+ { name: 'name', label: 'Your name', type: 'text', required: true },
358
+ { name: 'email', label: 'Email', type: 'email', required: true },
359
+ { name: 'message', label: 'Message', type: 'textarea', required: true },
360
+ ]),
361
+ });
362
+
363
+ /** Accordion — a generic expand/collapse list (title + body). Domain-free
364
+ * sibling of `faq` (which carries question/answer semantics). */
365
+ export const accordionBlock = z.object({
366
+ type: z.literal('accordion'),
367
+ enabled: z.boolean().default(true),
368
+ title: z.string().optional(),
369
+ items: z.array(z.object({ heading: z.string(), body: z.string() })).default([]),
370
+ });
371
+
372
+ /** Tiles — a curated card grid with five looks (outline / elevated / filled /
373
+ * gradient / image). The look is chosen per-block via `variant`; radius, stroke
374
+ * and elevation come from the global surface tokens, so tiles stay consistent
375
+ * with every other card on the page. Each tile can link (the whole tile is the
376
+ * target) and carry an icon, eyebrow, title, text and (for `image`) a photo. */
377
+ export const tilesBlock = z.object({
378
+ type: z.literal('tiles'),
379
+ enabled: z.boolean().default(true),
380
+ lastRow,
381
+ title: z.string().optional(),
382
+ intro: z.string().optional(),
383
+ columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).default(3),
384
+ variant: z.enum(['outline', 'elevated', 'filled', 'gradient', 'image']).default('elevated'),
385
+ /** Opt in to a pointer-following spotlight glow on hover (a small JS enhancement). */
386
+ spotlight: z.boolean().default(false),
387
+ /** How a picture tile (variant `image`, a picture with no words) holds its picture:
388
+ * `frame` (default) shows it whole in a padded card; `bleed` makes the picture the tile,
389
+ * edge to edge, its corners rounded like every other card. */
390
+ fit: z.enum(['frame', 'bleed']).default('frame'),
391
+ /** One shape for every picture tile, whatever sizes the pictures arrive in: landscape
392
+ * 16:9, 3:2, 4:3, square or portrait 3:4 (the `mediaCards` shapes), or `auto` (default)
393
+ * for each picture's own shape. With `bleed` the picture is cropped to the shape, keeping
394
+ * its `focus` in view; in a `frame` it's shown whole inside it, so a logo is never cut. */
395
+ ratio: z.enum(['auto', '16/9', '3/2', '4/3', '1/1', '3/4']).default('auto'),
396
+ tiles: z
397
+ .array(
398
+ z
399
+ .object({
400
+ icon: iconName.optional(),
401
+ eyebrow: z.string().optional(),
402
+ /** Optional only for a picture tile: with an image and no text, the tile is
403
+ * the picture alone (no scrim) — a linked poster/logo — named by its alt. */
404
+ title: z.string().optional(),
405
+ text: z.string().optional(),
406
+ href: z.string().optional(),
407
+ /** The link cue on a linking tile ("Learn more" by default). */
408
+ linkLabel: z.string().optional(),
409
+ image: croppedImage.optional(),
410
+ })
411
+ .refine((t) => !!t.title || !!t.image, { message: 'A tile needs a title or an image', path: ['title'] })
412
+ )
413
+ .default([]),
414
+ });
415
+
416
+ /** Banner — a full-bleed feature band: a fixed/parallax background image with a
417
+ * legibility scrim and a floating "shaded" content card (eyebrow + heading +
418
+ * text + optional CTA) drifting over it. `align` places the card; `parallax`
419
+ * pins the image so it slides under the content as you scroll (auto-disabled on
420
+ * touch and under reduced-motion). The showpiece "not-dull" effect. */
421
+ export const bannerBlock = z.object({
422
+ type: z.literal('banner'),
423
+ enabled: z.boolean().default(true),
424
+ image: z.string(),
425
+ eyebrow: z.string().optional(),
426
+ title: z.string(),
427
+ text: z.string().optional(),
428
+ cta: z.object({ label: z.string(), href: z.string() }).optional(),
429
+ overlay: z.number().min(0).max(100).default(50),
430
+ align: z.enum(['start', 'center', 'end']).default('start'),
431
+ parallax: z.boolean().default(true),
432
+ /** Break the band out to the full viewport width (edge-to-edge, no rounded
433
+ * corners); the card stays aligned to the page's content column. Great for a
434
+ * homepage hero. Off by default (the band sits inside the content column). */
435
+ fullBleed: z.boolean().default(false),
436
+ });
437
+
438
+ /** Stats — a band of headline numbers (value + label + optional note), over an
439
+ * optional heading/intro and a chosen background. Composes the Stat primitive. */
440
+ export const statsBlock = z.object({
441
+ type: z.literal('stats'),
442
+ enabled: z.boolean().default(true),
443
+ lastRow,
444
+ title: z.string().optional(),
445
+ intro: z.string().optional(),
446
+ background: z.enum(['none', 'muted', 'accent']).default('muted'),
447
+ columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).default(3),
448
+ items: z.array(z.object({ value: z.string(), label: z.string(), description: z.string().optional() })).default([]),
449
+ });
450
+
451
+ /** Steps — a numbered process (how-it-works). `horizontal` shows connected cards
452
+ * in a row; `vertical` a stacked timeline. Each step: title + optional text/icon. */
453
+ export const stepsBlock = z.object({
454
+ type: z.literal('steps'),
455
+ enabled: z.boolean().default(true),
456
+ title: z.string().optional(),
457
+ intro: z.string().optional(),
458
+ layout: z.enum(['horizontal', 'vertical']).default('horizontal'),
459
+ items: z.array(z.object({ title: z.string(), text: z.string().optional(), icon: iconName.optional() })).default([]),
460
+ });
461
+
462
+ /** Pricing — a row of plan cards (name, price, period, feature list, CTA). One
463
+ * plan may be `featured` (highlighted). */
464
+ export const pricingBlock = z.object({
465
+ type: z.literal('pricing'),
466
+ enabled: z.boolean().default(true),
467
+ lastRow,
468
+ title: z.string().optional(),
469
+ intro: z.string().optional(),
470
+ plans: z
471
+ .array(
472
+ z.object({
473
+ name: z.string(),
474
+ price: z.string(),
475
+ period: z.string().optional(),
476
+ description: z.string().optional(),
477
+ features: z.array(z.string()).default([]),
478
+ cta: z.object({ label: z.string(), href: z.string() }).optional(),
479
+ featured: z.boolean().default(false),
480
+ })
481
+ )
482
+ .default([]),
483
+ });
484
+
485
+ /** Logos — a "trusted by" wall of images; muted by default, colour on hover. */
486
+ export const logosBlock = z.object({
487
+ type: z.literal('logos'),
488
+ enabled: z.boolean().default(true),
489
+ title: z.string().optional(),
490
+ items: z.array(z.object({ src: z.string(), alt: z.string().default(''), href: z.string().optional() })).default([]),
491
+ });
492
+
493
+ /** Tabs — labelled panels; one open at a time. Progressive: the first panel is
494
+ * visible with no JS; a small script wires selection + ARIA. */
495
+ export const tabsBlock = z.object({
496
+ type: z.literal('tabs'),
497
+ enabled: z.boolean().default(true),
498
+ title: z.string().optional(),
499
+ items: z
500
+ .array(z.object({ label: z.string(), heading: z.string().optional(), text: z.string().optional(), image: z.object({ src: z.string(), alt: z.string().default('') }).optional() }))
501
+ .default([]),
502
+ });
503
+
504
+ /** Announcement — a thin full-width bar (message + optional link), optionally
505
+ * dismissible. Dismissal is remembered per `id` in localStorage. */
506
+ export const announcementBlock = z.object({
507
+ type: z.literal('announcement'),
508
+ enabled: z.boolean().default(true),
509
+ text: z.string(),
510
+ link: z.object({ label: z.string(), href: z.string() }).optional(),
511
+ tone: z.enum(['accent', 'neutral']).default('accent'),
512
+ dismissible: z.boolean().default(true),
513
+ /** localStorage key suffix so a dismissed bar stays dismissed. */
514
+ id: z.string().default('default'),
515
+ });
516
+
517
+ /** Bento — an asymmetric (mixed-span) grid of cards. Each item picks a `size`
518
+ * (sm / wide / tall / lg) and a `variant` look; the "living moodboard" layout. */
519
+ export const bentoBlock = z.object({
520
+ type: z.literal('bento'),
521
+ enabled: z.boolean().default(true),
522
+ title: z.string().optional(),
523
+ intro: z.string().optional(),
524
+ items: z
525
+ .array(
526
+ z.object({
527
+ size: z.enum(['sm', 'wide', 'tall', 'lg']).default('sm'),
528
+ variant: z.enum(['surface', 'filled', 'gradient', 'image']).default('surface'),
529
+ icon: iconName.optional(),
530
+ eyebrow: z.string().optional(),
531
+ title: z.string(),
532
+ text: z.string().optional(),
533
+ href: z.string().optional(),
534
+ image: croppedImage.optional(),
535
+ })
536
+ )
537
+ .default([]),
538
+ });
539
+
540
+ /** Marquee — an infinite horizontal scroll of short phrases (a feature strip).
541
+ * Pure-CSS transform loop (GPU); pauses on hover; static wrap under
542
+ * reduced-motion. Decorative, so the moving track is aria-hidden. */
543
+ export const marqueeBlock = z.object({
544
+ type: z.literal('marquee'),
545
+ enabled: z.boolean().default(true),
546
+ items: z.array(z.string()).default([]),
547
+ speed: z.enum(['slow', 'normal', 'fast']).default('normal'),
548
+ });
549
+
550
+ /** LatestPosts — a capability-backed recipe: the N most-recent published posts
551
+ * (optionally filtered to a `tag`) as a card grid or a compact list, with a
552
+ * "view all" link. Unlike other recipes it carries no content of its own — it
553
+ * queries the client's posts collection at build time — so it's the bridge from
554
+ * the posts capability into the page/block system (no per-client custom code). */
555
+ export const latestPostsBlock = z.object({
556
+ type: z.literal('latestPosts'),
557
+ enabled: z.boolean().default(true),
558
+ lastRow,
559
+ title: z.string().optional(),
560
+ intro: z.string().optional(),
561
+ limit: z.number().int().min(1).max(12).default(3),
562
+ /** Filter to a single tag slug; omit for the main index (minus excluded tags). */
563
+ tag: z.string().optional(),
564
+ /** `grid` = full image cards; `list` = a compact miniature index (thumbnail +
565
+ * category + date per row) that stays short even with many posts. */
566
+ layout: z.enum(['grid', 'list']).default('grid'),
567
+ /** In the `list` layout, badge the most-recent post as "New" when it was
568
+ * published within this many days (0 disables it). Only the newest row is ever
569
+ * flagged, so a frequently-posting site doesn't mark every row. Grid ignores it. */
570
+ newWithinDays: z.number().int().min(0).max(365).default(14),
571
+ /** "View all" target + label (the posts index by default). */
572
+ viewAllHref: z.string().default('/posts'),
573
+ viewAllLabel: z.string().default('All posts'),
574
+ });
575
+
576
+ /** MapEmbed — a consent-gated external map (e.g. Google Maps), the sibling of the
577
+ * calendar embed: nothing loads from the provider until the visitor opts in, so
578
+ * no third-party request fires on page load. `embedUrl` must be https; an unset
579
+ * or unsafe URL degrades to a friendly note + optional "open in Maps" link. */
580
+ export const mapEmbedBlock = z.object({
581
+ type: z.literal('mapEmbed'),
582
+ enabled: z.boolean().default(true),
583
+ title: z.string().optional(),
584
+ intro: z.string().optional(),
585
+ /** The map iframe src (an https embed URL). Blank → a "not set up yet" note. */
586
+ embedUrl: z.string().default(''),
587
+ /** Link to open the location in the provider's app/site (a no-embed fallback). */
588
+ publicUrl: z.string().default(''),
589
+ height: z.number().int().min(150).max(1200).default(450),
590
+ /** Provider name shown in the consent notice ("shared with …"). */
591
+ provider: z.string().default('Google Maps'),
592
+ });
593
+
594
+ /** Table — a simple data table (header row + body rows) for structured data our
595
+ * other blocks can't carry cleanly (fees, opening hours, a cookies list). Scrolls
596
+ * horizontally on narrow screens so it never breaks the page width. */
597
+ export const tableBlock = z.object({
598
+ type: z.literal('table'),
599
+ enabled: z.boolean().default(true),
600
+ title: z.string().optional(),
601
+ intro: z.string().optional(),
602
+ columns: z.array(z.string()).default([]),
603
+ rows: z.array(z.array(z.string())).default([]),
604
+ });
605
+
606
+ /** Notice — an inline highlighted info box (icon? + title? + body + link?) that
607
+ * sets a passage apart from prose ("reporting a concern", "please note"). Two
608
+ * tones (accent / neutral); the in-flow sibling of the corner StickyCallout. */
609
+ export const noticeBlock = z.object({
610
+ type: z.literal('notice'),
611
+ enabled: z.boolean().default(true),
612
+ tone: z.enum(['accent', 'neutral']).default('accent'),
613
+ icon: iconName.optional(),
614
+ title: z.string().optional(),
615
+ text: z.string(),
616
+ link: z.object({ label: z.string(), href: z.string() }).optional(),
617
+ });
618
+
619
+ /** MediaCards — a grid of rich content cards with the IMAGE as a header on top
620
+ * (cover-cropped), then an optional icon badge, title, meta line, description and
621
+ * CTA. The image-HEADER pattern (distinct from `tiles`, which puts the image
622
+ * BEHIND the text) — for groups, team, services, events where the photo AND copy
623
+ * must both stay legible. Whole card links when a card has `href`. */
624
+ export const mediaCardsBlock = z.object({
625
+ type: z.literal('mediaCards'),
626
+ enabled: z.boolean().default(true),
627
+ lastRow,
628
+ title: z.string().optional(),
629
+ intro: z.string().optional(),
630
+ columns: z.union([z.literal(2), z.literal(3)]).default(3),
631
+ /** The image shape: landscape 16:9 (default), 4:3, 3:2, square, or portrait 3:4 (people). */
632
+ ratio: z.enum(['16/9', '4/3', '3/2', '1/1', '3/4']).default('16/9'),
633
+ cards: z
634
+ .array(
635
+ z.object({
636
+ image: croppedImage.optional(),
637
+ icon: iconName.optional(),
638
+ title: z.string(),
639
+ /** A short meta line shown as a pill (e.g. "Sundays 10:45 · Main hall"). */
640
+ meta: z.string().optional(),
641
+ text: z.string().optional(),
642
+ href: z.string().optional(),
643
+ /** CTA label when the card links (defaults to "Learn more"). */
644
+ linkLabel: z.string().optional(),
645
+ })
646
+ )
647
+ .default([]),
648
+ });
649
+
650
+ /** ContactCard — a branded "get in touch" band: display title + subtitle on the
651
+ * left, contact channels as tappable pills on the right, a note across the bottom. */
652
+ export const contactCardBlock = z.object({
653
+ type: z.literal('contactCard'),
654
+ enabled: z.boolean().default(true),
655
+ eyebrow: z.string().optional(),
656
+ title: z.string(),
657
+ subtitle: z.string().optional(),
658
+ note: z.string().optional(),
659
+ items: z
660
+ .array(
661
+ z.object({
662
+ icon: iconName.optional(),
663
+ value: z.string(),
664
+ href: z.string().optional(),
665
+ })
666
+ )
667
+ .default([]),
668
+ });
669
+
670
+ /** Locations ("Where to find us") — location tiles, each a consent-gated map over
671
+ * a name / address / directions. https embed URLs only (isSafeEmbedUrl). */
672
+ export const locationsBlock = z.object({
673
+ type: z.literal('locations'),
674
+ enabled: z.boolean().default(true),
675
+ lastRow,
676
+ title: z.string().optional(),
677
+ intro: z.string().optional(),
678
+ columns: z.union([z.literal(1), z.literal(2)]).default(2),
679
+ provider: z.string().default('Google Maps'),
680
+ items: z
681
+ .array(
682
+ z.object({
683
+ name: z.string(),
684
+ address: z.string().optional(),
685
+ embedUrl: z.string(),
686
+ directionsUrl: z.string().optional(),
687
+ })
688
+ )
689
+ .default([]),
690
+ });
691
+
692
+ /** Video — a consent-gated YouTube / Vimeo player (incl. a channel's live stream).
693
+ * `url` is the ordinary link an editor would paste; it becomes a privacy-friendly
694
+ * embed (lib/video). An unrecognised link shows as a plain "watch" link. */
695
+ export const videoBlock = z.object({
696
+ type: z.literal('video'),
697
+ enabled: z.boolean().default(true),
698
+ title: z.string().optional(),
699
+ caption: z.string().optional(),
700
+ /** A short note under the player (inline markdown), e.g. a live stream's schedule. */
701
+ note: z.string().optional(),
702
+ url: z.string(),
703
+ ratio: z.enum(['16/9', '4/3', '1/1', '9/16']).default('16/9'),
704
+ });
705
+
706
+ /** Documents — a list of files (newsletters, minutes, policies, forms): type badge,
707
+ * title, date and note per row, newest first, optionally grouped by year. `date`
708
+ * is YYYY-MM-DD. Files open in the browser's own viewer, not an in-page one. */
709
+ export const documentsBlock = z.object({
710
+ type: z.literal('documents'),
711
+ enabled: z.boolean().default(true),
712
+ title: z.string().optional(),
713
+ intro: z.string().optional(),
714
+ groupByYear: z.boolean().default(false),
715
+ items: z
716
+ .array(
717
+ z.object({
718
+ title: z.string(),
719
+ file: z.string(),
720
+ date: z.string().optional(),
721
+ note: z.string().optional(),
722
+ })
723
+ )
724
+ .default([]),
725
+ });
726
+
727
+ /** LinkRow — a titled row of contact or reference links as tappable pills (phone, email,
728
+ * web), each with the icon its link implies, plus an optional intro and footnote. For a
729
+ * contact who isn't worth a whole contact card (e.g. "Vocations: phone · email · site"). */
730
+ export const linkRowBlock = z.object({
731
+ type: z.literal('linkRow'),
732
+ enabled: z.boolean().default(true),
733
+ title: z.string().optional(),
734
+ intro: z.string().optional(),
735
+ links: z.array(z.object({ label: z.string(), href: z.string() })).min(1),
736
+ note: z.string().optional(),
737
+ });
738
+
739
+ /** Document — a policy or legal text as ONE block: sections numbered automatically, a
740
+ * contents list linking to each (sticky beside the text on wide screens), an optional
741
+ * "last updated" date (YYYY-MM-DD), and print-friendly. Section bodies take prose
742
+ * formatting; `items` add a list. Replaces dozens of hand-numbered headings + paragraphs. */
743
+ export const documentBlock = z.object({
744
+ type: z.literal('document'),
745
+ enabled: z.boolean().default(true),
746
+ intro: z.string().optional(),
747
+ updated: z.string().optional(),
748
+ numbered: z.boolean().default(true),
749
+ toc: z.boolean().default(true),
750
+ sections: z
751
+ .array(z.object({ title: z.string(), body: z.string().optional(), items: z.array(z.string()).optional() }))
752
+ .min(1),
753
+ });
754
+
755
+ /** Timetable — weekly times for one or more places (worship times, opening hours,
756
+ * sessions, classes). `cards`: a card per place, days with no times left out, notes
757
+ * (inline markdown) under each. `table`: places side by side, days down the side. */
758
+ export const timetableBlock = z.object({
759
+ type: z.literal('timetable'),
760
+ enabled: z.boolean().default(true),
761
+ title: z.string().optional(),
762
+ intro: z.string().optional(),
763
+ layout: z.enum(['cards', 'table']).default('cards'),
764
+ places: z
765
+ .array(
766
+ z.object({
767
+ name: z.string(),
768
+ address: z.string().optional(),
769
+ href: z.string().optional(),
770
+ schedule: z.array(z.object({ day: z.string(), times: z.array(z.string()).default([]) })).default([]),
771
+ notes: z.string().optional(),
772
+ })
773
+ )
774
+ .min(1),
775
+ });
776
+
777
+ /** Contacts — a compact directory of people or offices: role as the card title, phone and
778
+ * email as tap targets (email with an optional subject), address and hours, and a shared
779
+ * note per group (e.g. office hours) instead of repeating it on every card. */
780
+ export const contactsBlock = z.object({
781
+ type: z.literal('contacts'),
782
+ enabled: z.boolean().default(true),
783
+ title: z.string().optional(),
784
+ intro: z.string().optional(),
785
+ groups: z
786
+ .array(
787
+ z.object({
788
+ heading: z.string().optional(),
789
+ note: z.string().optional(),
790
+ contacts: z
791
+ .array(
792
+ z.object({
793
+ role: z.string().optional(),
794
+ name: z.string().optional(),
795
+ phone: z.string().optional(),
796
+ email: z.string().optional(),
797
+ emailSubject: z.string().optional(),
798
+ address: z.string().optional(),
799
+ hours: z.string().optional(),
800
+ })
801
+ .refine((c) => !!c.role || !!c.name, { message: 'A contact needs a role or a name', path: ['role'] })
802
+ )
803
+ .min(1),
804
+ })
805
+ )
806
+ .min(1),
807
+ });
808
+
809
+ /** MediaText — an image beside its text (start or end), stacking on a phone. The text takes
810
+ * prose formatting; the image keeps its shape (`ratio` crops to a set shape); optional CTA. */
811
+ export const mediaTextBlock = z.object({
812
+ type: z.literal('mediaText'),
813
+ enabled: z.boolean().default(true),
814
+ title: z.string().optional(),
815
+ text: z.string(),
816
+ image: z.object({ src: z.string(), alt: z.string().default(''), caption: z.string().optional(), focus: focusPosition.optional() }),
817
+ imageSide: z.enum(['start', 'end']).default('end'),
818
+ ratio: z.enum(['auto', '1/1', '4/3', '3/2', '16/9']).default('auto'),
819
+ cta: z.object({ label: z.string(), href: z.string() }).optional(),
820
+ });
821
+
822
+ export type RecipeBlock =
823
+ | z.infer<typeof heroBlock>
824
+ | z.infer<typeof featureCardsBlock>
825
+ | z.infer<typeof ctaBlock>
826
+ | z.infer<typeof faqBlock>
827
+ | z.infer<typeof galleryBlock>
828
+ | z.infer<typeof testimonialBlock>
829
+ | z.infer<typeof contactFormBlock>
830
+ | z.infer<typeof formBlock>
831
+ | z.infer<typeof payBlock>
832
+ | z.infer<typeof bookBlock>
833
+ | z.infer<typeof accordionBlock>
834
+ | z.infer<typeof tilesBlock>
835
+ | z.infer<typeof bannerBlock>
836
+ | z.infer<typeof statsBlock>
837
+ | z.infer<typeof stepsBlock>
838
+ | z.infer<typeof pricingBlock>
839
+ | z.infer<typeof logosBlock>
840
+ | z.infer<typeof tabsBlock>
841
+ | z.infer<typeof announcementBlock>
842
+ | z.infer<typeof bentoBlock>
843
+ | z.infer<typeof marqueeBlock>
844
+ | z.infer<typeof latestPostsBlock>
845
+ | z.infer<typeof mapEmbedBlock>
846
+ | z.infer<typeof tableBlock>
847
+ | z.infer<typeof noticeBlock>
848
+ | z.infer<typeof mediaCardsBlock>
849
+ | z.infer<typeof contactCardBlock>
850
+ | z.infer<typeof locationsBlock>
851
+ | z.infer<typeof videoBlock>
852
+ | z.infer<typeof documentsBlock>
853
+ | z.infer<typeof linkRowBlock>
854
+ | z.infer<typeof documentBlock>
855
+ | z.infer<typeof timetableBlock>
856
+ | z.infer<typeof contactsBlock>
857
+ | z.infer<typeof mediaTextBlock>;
858
+
859
+ /* ── Level-1 layout / container primitives ─────────────────────────────────
860
+ * These hold child blocks, so the schema is **recursive** (a container's
861
+ * `blocks` field is the same block union). TypeScript can't infer a type through
862
+ * `z.lazy`, so the recursive `Block` type is declared explicitly and the union
863
+ * is cast to it. Containers are how primitives compose into layouts (and, later,
864
+ * recipes). */
865
+ export interface SectionBlock {
866
+ type: 'section';
867
+ enabled: boolean;
868
+ background: 'none' | 'muted' | 'accent';
869
+ width: 'normal' | 'wide' | 'full';
870
+ blocks: Block[];
871
+ }
872
+ export interface GridBlock {
873
+ type: 'grid';
874
+ enabled: boolean;
875
+ columns: 2 | 3 | 4;
876
+ gap: 'sm' | 'md' | 'lg';
877
+ blocks: Block[];
878
+ }
879
+ export interface StackBlock {
880
+ type: 'stack';
881
+ enabled: boolean;
882
+ gap: 'sm' | 'md' | 'lg';
883
+ blocks: Block[];
884
+ }
885
+
886
+ export type LeafBlock =
887
+ | z.infer<typeof headingBlock>
888
+ | z.infer<typeof proseBlock>
889
+ | z.infer<typeof imageBlock>
890
+ | z.infer<typeof buttonBlock>
891
+ | z.infer<typeof quoteBlock>
892
+ | z.infer<typeof dividerBlock>
893
+ | z.infer<typeof spacerBlock>
894
+ | z.infer<typeof badgeBlock>
895
+ | z.infer<typeof statBlock>
896
+ | z.infer<typeof listBlock>;
897
+
898
+ /** The full recursive block type: leaf primitives + layout containers. */
899
+ /**
900
+ * Alignment overrides every block takes, so a page's look can follow a client's preference
901
+ * from the page data alone. Defaults are the sensible visual choice (a block follows its
902
+ * page / section; a recipe's section title is centred).
903
+ * - `align`: re-aligns the whole block — title, intro, text, and the icons, pills and
904
+ * buttons in its cards — overriding the page / section for this one block.
905
+ * - `headingAlign`: just a recipe's title + intro (e.g. a start-aligned title over centred
906
+ * cards). Recipes without a section title ignore it.
907
+ * `heading`, `banner` and `section` already had `align` with this meaning and keep it.
908
+ */
909
+ const alignOption = z.enum(['start', 'center', 'end']);
910
+ export interface BlockLayout {
911
+ align?: 'start' | 'center' | 'end';
912
+ headingAlign?: 'start' | 'center' | 'end';
913
+ }
914
+ function withLayout<T extends z.AnyZodObject>(block: T): z.AnyZodObject {
915
+ const shape = block.shape as Record<string, unknown>;
916
+ return block.extend({
917
+ ...('align' in shape ? {} : { align: alignOption.optional() }),
918
+ headingAlign: alignOption.optional(),
919
+ });
920
+ }
921
+
922
+ export type Block = (LeafBlock | RecipeBlock | SectionBlock | GridBlock | StackBlock) & BlockLayout;
923
+ export type BlockType = Block['type'];
924
+
925
+ export const sectionBlock = z.object({
926
+ type: z.literal('section'),
927
+ enabled: z.boolean().default(true),
928
+ background: z.enum(['none', 'muted', 'accent']).default('none'),
929
+ width: z.enum(['normal', 'wide', 'full']).default('normal'),
930
+ /** Override the page's content alignment for this section's subtree. */
931
+ align: z.enum(['start', 'center', 'end']).optional(),
932
+ blocks: z.lazy(() => z.array(blockSchema)).default([]),
933
+ });
934
+
935
+ export const gridBlock = z.object({
936
+ type: z.literal('grid'),
937
+ enabled: z.boolean().default(true),
938
+ lastRow,
939
+ columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).default(2),
940
+ gap: z.enum(['sm', 'md', 'lg']).default('md'),
941
+ blocks: z.lazy(() => z.array(blockSchema)).default([]),
942
+ });
943
+
944
+ export const stackBlock = z.object({
945
+ type: z.literal('stack'),
946
+ enabled: z.boolean().default(true),
947
+ gap: z.enum(['sm', 'md', 'lg']).default('md'),
948
+ blocks: z.lazy(() => z.array(blockSchema)).default([]),
949
+ });
950
+
951
+ /** The block palette: leaf primitives + layout containers. A discriminated union
952
+ * on `type` — the AI's + CMS's contract and the renderer's registry key. Adding
953
+ * a member without a matching BlockRenderer registry entry is a TypeScript error
954
+ * (the exhaustiveness guard against a silent-undefined render crash). Cast to
955
+ * the recursive `Block` type because `z.lazy` fields can't be inferred. */
956
+ export const blockSchema = z.discriminatedUnion(
957
+ 'type',
958
+ [
959
+ headingBlock,
960
+ proseBlock,
961
+ imageBlock,
962
+ buttonBlock,
963
+ quoteBlock,
964
+ dividerBlock,
965
+ spacerBlock,
966
+ badgeBlock,
967
+ statBlock,
968
+ listBlock,
969
+ heroBlock,
970
+ featureCardsBlock,
971
+ ctaBlock,
972
+ faqBlock,
973
+ galleryBlock,
974
+ testimonialBlock,
975
+ contactFormBlock,
976
+ formBlock,
977
+ payBlock,
978
+ bookBlock,
979
+ accordionBlock,
980
+ tilesBlock,
981
+ bannerBlock,
982
+ statsBlock,
983
+ stepsBlock,
984
+ pricingBlock,
985
+ logosBlock,
986
+ tabsBlock,
987
+ announcementBlock,
988
+ bentoBlock,
989
+ marqueeBlock,
990
+ latestPostsBlock,
991
+ mapEmbedBlock,
992
+ tableBlock,
993
+ noticeBlock,
994
+ mediaCardsBlock,
995
+ contactCardBlock,
996
+ locationsBlock,
997
+ videoBlock,
998
+ documentsBlock,
999
+ linkRowBlock,
1000
+ documentBlock,
1001
+ timetableBlock,
1002
+ contactsBlock,
1003
+ mediaTextBlock,
1004
+ sectionBlock,
1005
+ gridBlock,
1006
+ stackBlock,
1007
+ ].map(withLayout) as unknown as [z.AnyZodObject, z.AnyZodObject, ...z.AnyZodObject[]],
1008
+ ) as unknown as z.ZodType<Block>;
1009
+
1010
+ /** A page = metadata + an ordered list of blocks. Stored as JSON in the client
1011
+ * repo; the AI composes it, a human verifies. This is also the schema of the
1012
+ * `pages` collection that the client's `[...slug].astro` catch-all routes over,
1013
+ * so one page = one JSON file (its filename is the URL slug). */
1014
+ export const pageSchema = z.object({
1015
+ title: z.string(),
1016
+ description: z.string().optional(),
1017
+ /** Preloaded as the LCP image (passed to the layout) when set. */
1018
+ heroImage: z.string().optional(),
1019
+ /**
1020
+ * Template-level content alignment — the default for text-bearing blocks on the
1021
+ * page (headings, prose, quote). Cascades as `--content-align` so every recipe
1022
+ * inherits one coherent alignment instead of each hard-coding its own. A
1023
+ * `section` block can override it for its subtree; a `heading` can override per
1024
+ * block. `start` (left) is the readable default for long-form; `center` suits
1025
+ * short, hero-led pages.
1026
+ */
1027
+ align: z.enum(['start', 'center', 'end']).default('start'),
1028
+ /**
1029
+ * Provenance — the ferst-library template this page was instantiated from.
1030
+ * The triangular model (docs/BLOCK-ARCHITECTURE.md §5): lego box → a template
1031
+ * stored in the library → each client page links a `templateId`. The client
1032
+ * repo never depends on the library; this is just a design-time back-reference
1033
+ * so a template's lineage/variants stay traceable platform-side. Optional — a
1034
+ * bespoke page may have none.
1035
+ */
1036
+ templateId: z.string().optional(),
1037
+ /**
1038
+ * Editor change-requests captured in the CMS — the seed of AI-driven editing
1039
+ * ([[ferst_editing_ai_first_pdlc]]): rather than let editors edit block JSON
1040
+ * directly (easy to break), they describe a desired change against the page and
1041
+ * it's stored here for an agent to action later → PR → human verify. NEVER
1042
+ * rendered; carried through the schema so a CMS save preserves it.
1043
+ */
1044
+ requests: z
1045
+ .array(
1046
+ z.object({
1047
+ text: z.string(),
1048
+ /** Stamped by the platform when the request becomes an issue in the site's repo:
1049
+ * when, who asked (from their session) and the issue number. */
1050
+ at: z.string().optional(),
1051
+ by: z.string().optional(),
1052
+ issue: z.number().int().optional(),
1053
+ status: z.enum(['open', 'done']).default('open'),
1054
+ }),
1055
+ )
1056
+ .default([]),
1057
+ /** Keep the JSON in the repo but exclude it from the build. */
1058
+ draft: z.boolean().default(false),
1059
+ blocks: z.array(blockSchema).default([]),
1060
+ });
1061
+ export type Page = z.infer<typeof pageSchema>;
1062
+
1063
+ /** Every block type id, derived from the union so it stays in sync — used for
1064
+ * gallery coverage, CMS config generation, docs, etc. */
1065
+ export const blockTypes = (
1066
+ blockSchema as unknown as { options: ReadonlyArray<{ shape: { type: { value: BlockType } } }> }
1067
+ ).options.map((o) => o.shape.type.value);
1068
+
1069
+ /** Blocks whose content comes from the Ferst platform at build time (a form, an item to pay for, an offer to book).
1070
+ * The public showcase can't render them without the platform, so its galleries show the
1071
+ * look through their local twin instead (`form` renders with the contactForm recipe). */
1072
+ export const platformBlockTypes: readonly BlockType[] = ['form', 'pay', 'book'];