Block library: docs, agent guide, skills; picker order as an explicit list

- docs/block-library.md: setup, every block (fields, variants, accessibility),
  options, registry, primitives, eject, page templates, seeding after launch,
  versioning, manifest, turn off / override / extend
- AGENT.md (compass, how to add, §6, §6.3, module map), ipal-block (library
  block first), ipal-site (phases 2, 4, 6, 8), ipal-reference (wiring rows,
  export index), seed-content template from pageTemplates, seeding.md ($form)
- CHANGELOG Unreleased; proposal marked built with an as-built section

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-29 14:12:50 +01:00
co-authored by Claude Opus 5.5
parent 2d1cc0e77d
commit 2a07fb8844
14 changed files with 470 additions and 39 deletions
+19 -1
View File
@@ -10,9 +10,21 @@ once there are more than 20.
## Unreleased
Database names follow one rule, and seeding a live site touches only the records you name.
Database names follow one rule, and seeding a live site touches only the records you name. The block library:
fifteen ready page sections and ten page templates.
### New
- **Block library** ([block-library.md](./block-library.md)): `hero`, `textMedia`, `featureGrid`, `cta`, `richText`, `faq`,
`contact`, `gallery`, `testimonials`, `stats`, `steps`, `logos`, `team`, `pricing`, `entryList` — Payload block +
server component each, `{ en, pl }` panel, accessibility built in, styled only with design-token utilities.
Opt in per block: `libraryBlocks({ hero: true, … })` (`@intecion/ipal-kit/blocks`); render with
`createBlockRegistry(content, { Image, Link, sendForm })` (`@intecion/ipal-kit/blocks/rsc`). Nothing is on by default.
Override fields, variants, slugs, labels, part classes, primitives or whole components; own blocks share the registry.
- **Page templates:** `pageTemplates` (`@intecion/ipal-kit/templates`) — home, about, services, service, contact, blog
index, post, legal pages, cookie policy, 404 — as `createSeeder` data in English and Polish; `systemPageRefs`.
- **`ipal-blocks eject <block>`** copies a library block into `src/blocks/` (same slug and data shape).
- **`blockLibraryManifest`** — the library's blocks, variants, fields and primitives as data, for checks.
- **Seeder:** `{ $form: 'Contact form' }` references (by title, `formsCollection`, default `forms`).
- **Database name rule:** `<domain without dots>_prod` / `_dev` (e.g. `acmepl_prod`), docs/deployment.md.
`ipalEnvRules({ databaseName: true })` (domain from `NEXT_PUBLIC_SERVER_URL`, skipped on localhost) or
`{ databaseName: { domain, warn } }` checks `DATABASE_URI` and **warns only** — never fails startup. Default off.
@@ -22,6 +34,8 @@ Database names follow one rule, and seeding a live site touches only the records
`skip (not listed)`. The seed templates (`ipal-site`, `ipal-form`) read it.
### Changed
- **Admin labels:** the link "Open in new tab" checkbox is now **New tab** (with a description) and the table-of-contents
switch **Show contents** — shorter labels per admin-ux; the stored fields are unchanged.
- **A full seed of a live database is refused:** a run without `only` / `SEED_ONLY` against `NODE_ENV=production` or
a non-local database now throws (with the steps to follow). Dry runs (`SEED_DRY_RUN=1`) are never refused. Allow it
only with the owner's explicit OK: `IPAL_SEED_ALLOW_FULL=1` or `guard: { allowFull: true }`; `guard: false` turns
@@ -34,6 +48,10 @@ Database names follow one rule, and seeding a live site touches only the records
2. Optional: name the databases `<domain without dots>_prod` / `_dev` and add `ipalEnvRules({ databaseName: true })`
to see a warning when `DATABASE_URI` points elsewhere. Existing databases need not be renamed.
3. Seed scripts copied from older templates: take the new `SEED_ONLY` handling from `ipal-site` / `ipal-form`.
4. Block library — optional, nothing changes until you turn blocks on. New sites: the starter turns on eight blocks.
Existing sites move block by block when they get work (an own block with the same slug and fields can be replaced by
the library block with `slug`, else a migration with **ipal-migrate-fields**). After turning blocks on:
`pnpm generate:types`, `pnpm payload generate:importmap`, Postgres/SQLite `pnpm payload migrate:create`.
## 1.14.6
+1
View File
@@ -23,6 +23,7 @@ API details — one file per module:
| Accessibility widget (optional) | [accessibility.md](./accessibility.md) |
| GA4, GTM, Meta Pixel, Clarity, LinkedIn, TikTok, `defer` | [analytics.md](./analytics.md) |
| Blocks, RenderBlocks, enhanceProps | [blocks.md](./blocks.md) |
| Block library: ready sections, page templates | [block-library.md](./block-library.md) |
| Cookie consent, banner, settings window (in the bar / modal / large with cookie details) | [consent.md](./consent.md) |
| Cookie scanner: review list of drafts, "Scan cookies", Open Cookie Database lookup (optional) | [cookie-scanner.md](./cookie-scanner.md) |
| Under construction — locks subpages behind a popup (developer tool) | [construction.md](./construction.md) |
+16 -2
View File
@@ -134,6 +134,8 @@ export function Offer({ header, items }: OfferBlockProps) { return <Section head
`docs/dev/admin-ux.md`); no empty "just in case" fields.
7. **Renderers from the plugin:** `RenderBlocks` (not a `switch`), `RenderRichText` (not
your own Lexical parser), `useForm` (not hand-made form plumbing).
**Sections from the block library first:** `libraryBlocks` + `createBlockRegistry` (15 ready blocks,
docs/block-library.md); an own block only when no library block, variant or option fits.
8. **No `any` and no `@ts-ignore`.** Types from `@/payload-types`, `unknown` + guard.
9. **One source of truth** — `i18n.config.ts`, `lib/content.ts`, never copies.
10. **"Done" only after** a local `pnpm build` + the checks from §11.
@@ -145,7 +147,8 @@ export function Offer({ header, items }: OfferBlockProps) { return <Section head
| What | How |
|---|---|
| a page | in the panel: Pages + blocks, no code (§5.1) |
| a section (block) | `src/blocks/<Name>/config.ts` + `Component.tsx`, an entry in `blocks/registry.ts`, the block in the Pages `layout` field → `pnpm generate:types` (+ `pnpm payload generate:importmap` with `rowLabel`) — **ipal-block** |
| a section (block) | a library block first: `blockOptions` → `libraryBlocks` in `src/blocks/configs.ts`, `createBlockRegistry(content, { Image, Link, sendForm })` in `blocks/registry.ts` (docs/block-library.md). None fits → `src/blocks/<Name>/config.ts` + `Component.tsx`, `extra` in the registry, `pageBlocks` → `pnpm generate:types` (+ `pnpm payload generate:importmap` with `rowLabel`) — **ipal-block** |
| a standard page (home, about, services, contact, legal, 404…) | `pageTemplates` from `@intecion/ipal-kit/templates` in the content seed (after launch only with `SEED_ONLY`) — **ipal-site** phase 6 |
| a form | the Forms panel (builder) from the seed `scripts/seed-form-*.ts`, a block with `<RenderForm>`, sending via `sendForm` — **ipal-form** |
| a language | `i18n.config.ts` (the only place) + a Postgres migration + content in the new language — **ipal-locale-add** |
| a collection with URLs | `content: { collections: [...] }` in `ipalKit` and `createContentHelpers` (§5.4) — **ipal-collection** |
@@ -565,6 +568,13 @@ never by slug. pages.md.
## 6. BUILDING SECTIONS (`.tsx` blocks)
**Block library first.** The plugin ships 15 sections built to every rule below — `hero`, `textMedia`,
`featureGrid`, `cta`, `richText`, `faq`, `contact`, `gallery`, `testimonials`, `stats`, `steps`, `logos`, `team`,
`pricing`, `entryList` — with variants, `{ en, pl }` panels, accessibility and token-only styling, plus ten page
templates ([block-library.md](../block-library.md)). Turn them on with `libraryBlocks(blockOptions)`, render them with
`createBlockRegistry`, change them with their options (`fields`, `variants`, `classNames`, `ui`, `components`), own one
with `ipal-blocks eject`. The rules below are how those blocks are built and how you build your own when none fits.
Three problems that must never repeat: **a zoo of CTA fields** (`ctaLabel`,
`cta2Text`, `buttonUrl`…), **files as text** (`pdfUrl: '/files/x.pdf'`),
**the monolith section** (200–400 lines with cards, SVG icons and button styles).
@@ -624,7 +634,10 @@ Field labels as `{ en, pl }` objects (the panel runs in English and Polish; §6.
### 6.3 Layer 2 — UI primitives
Code 1:1: [section-code.md](./skills/ipal-block/resources/section-code.md). Each one has one job:
With the block library they come from the plugin: `Section`, `SectionHeader`, `Media`, `CMSLink`, `buttonClass`,
`Container`, `Card` from `@intecion/ipal-kit/blocks/rsc` (no project copies; `src/components/ui/` holds only a
project version you pass in with `createBlockRegistry(content, { ui: { Media } })`). A project without the library:
code 1:1 from [section-code.md](./skills/ipal-block/resources/section-code.md). Each one has one job:
| Primitive | Does | Instead of |
|---|---|---|
@@ -1245,6 +1258,7 @@ Anything that needs a developer → move it to the panel.
| Accessibility widget (optional) | [accessibility.md](../accessibility.md) |
| GA4, GTM, Meta Pixel, Clarity, LinkedIn, TikTok | [analytics.md](../analytics.md) |
| Blocks, RenderBlocks, enhanceProps | [blocks.md](../blocks.md) |
| Block library: 15 ready sections, page templates, eject | [block-library.md](../block-library.md) |
| Cookie consent, banner | [consent.md](../consent.md) |
| Cookie scanner (review list, Open Cookie Database) | [cookie-scanner.md](../cookie-scanner.md) |
| Routing, archives, redirects, Markdown, search | [content.md](../content.md) |
+26 -5
View File
@@ -1,6 +1,6 @@
---
name: ipal-block
description: Builds or refactors one page section (Payload block + React component) in an ipal-kit project the correct way — a clean editor panel (repeatable things as "+ Add …" arrays with rowLabel, never cta1/cta2 slots, short `{ en, pl }` labels per docs/dev/admin-ux.md, no empty spare fields), shared fields from the plugin (buildSectionHeaderField, buildLinksField, buildLinkField, buildSectionSettingsField), UI primitives (Section, SectionHeader, Media, CMSLink), fixed field vocabulary, max ~80 lines of JSX, subcomponents for repeated items, registry wiring. Use when creating a new section/block (hero, features, CTA, FAQ, gallery, pricing, testimonials…), changing a block's fields, or fixing a block with ctaLabel/buttonUrl/pdfUrl fields or a monolithic component.
description: Builds or refactors one page section (Payload block + React component) in an ipal-kit project the correct way — first a block of the plugin's block library (libraryBlocks / createBlockRegistry, 15 ready sections) or its variant or options, and only when none fits an own block with a clean editor panel (repeatable things as "+ Add …" arrays with rowLabel, never cta1/cta2 slots, short `{ en, pl }` labels per docs/dev/admin-ux.md, no empty spare fields), shared fields from the plugin (buildSectionHeaderField, buildLinksField, buildLinkField, buildSectionSettingsField), UI primitives (Section, SectionHeader, Media, CMSLink), fixed field vocabulary, max ~80 lines of JSX, subcomponents for repeated items, registry wiring. Use when creating a new section/block (hero, features, CTA, FAQ, gallery, pricing, testimonials…), changing a block's fields, or fixing a block with ctaLabel/buttonUrl/pdfUrl fields or a monolithic component.
---
# ipal-block
@@ -13,8 +13,29 @@ decision on that part; no hand-built replacement, no silent workaround. **Code r
One section per use of this skill. Details and ready code:
`node_modules/@intecion/ipal-kit/docs/agent/AGENT.md` §6.
## 0. Prerequisites
Check that these exist: `src/components/ui/{CMSLink,Button,Media,Section,SectionHeader}.tsx`.
## 0. Library block first (docs/block-library.md)
The plugin ships 15 blocks: `hero`, `textMedia`, `featureGrid`, `cta`, `richText`, `faq`, `contact`, `gallery`,
`testimonials`, `stats`, `steps`, `logos`, `team`, `pricing`, `entryList` (variants: `blockLibraryManifest`).
1. Does a library block or one of its variants fit the section? → turn it on in `src/blocks/configs.ts`
(`blockOptions` → `libraryBlocks`), no component code. Done after step 3 below.
2. Almost fits → its options, not a copy: `fields: (defaults) => …` (`replaceField`, `removeField`), `variants`
(own `{ label: { en, pl }, value }` + `components` / `classNames` in the registry), `settings: { backgrounds }`,
`links`, `maxItems`. Another look of one part → `createBlockRegistry(content, { classNames: { faq: { item: '…' } } })`;
another primitive everywhere → `ui: { Media }`.
3. The project must own it completely → `pnpm exec ipal-blocks eject <block>` (same slug and data, no migration),
then the ejected builder in `pageBlocks` and `components: { <slug>: <Name>Block }` in the registry.
4. Nothing fits → an own block (below), with the library's builders (`buildItemsField`, `buildMediaField`,
`buildVariantField`, `buildContentField`, `defineLibraryBlock`) and primitives (`Section`, `SectionHeader`, `Media`,
`CMSLink`, `Card` from `@intecion/ipal-kit/blocks/rsc`), added to `extra` in `createBlockRegistry`.
Record the reason in AGENTS.md → "Project decisions" (`ipal-doctor` warns about own blocks that copy a library block).
**Check (library block):** `pnpm generate:types` → `pnpm payload generate:importmap` → Postgres/SQLite
`pnpm payload migrate:create`; add the block to a page in the panel (en and pl labels, ≤ 6 fields), the page shows
the section with `data-ipal-block="<slug>"`.
## 0a. Prerequisites (own block)
With `createBlockRegistry` the primitives come from `@intecion/ipal-kit/blocks/rsc` — import them, no project copies.
A project without it: check that these exist: `src/components/ui/{CMSLink,Button,Media,Section,SectionHeader}.tsx`.
Old `src/fields/sectionHeader.ts` / `sectionSettings.ts` → replace with the plugin import and delete them (blocks.md, no migration).
Links (`buildLinkField`, `buildLinksField`, `resolveLink`) and section fields (`buildSectionHeaderField`, `buildSectionSettingsField`) come from the plugin — do not create them in the project.
Missing → first create them 1:1 from `resources/section-code.md` (this skill)
@@ -48,8 +69,8 @@ File patterns (Hero, FeatureGrid + FeatureCard): `resources/section-code.md`.
`<LightboxTrigger group={`<name>-${id}`} image={lightboxImage(item.image, { size: 'hero' })}>`
(`@intecion/ipal-kit/client`; skip the trigger when `lightboxImage` returns `null`). No
`useState` dialog, no `glightbox` — lightbox.md.
4. Add `config.ts` to `layout` in `src/collections/Pages.ts`,
and the component to `src/blocks/registry.ts` (key = slug).
4. Add `config.ts` to `pageBlocks` (`src/blocks/configs.ts`, used by `layout` in `src/collections/Pages.ts`),
and the component to `src/blocks/registry.ts` (`extra: { <slug>: Component }` in `createBlockRegistry`, key = slug).
5. `pnpm generate:types`.
## 3. Check
+5 -1
View File
@@ -184,11 +184,15 @@ Mandatory set: AGENT.md §0b, skill **ipal-setup**; checks: **ipal-audit**, **ip
| analytics | layout | `SiteProviders` wires `Analytics` (ID from Site integrations → Analytics); Consent Mode: `analytics={{ consentMode: 'basic' }}` = no request to Google before consent, default `'advanced'` = the Google tag loads at once with every signal `denied` | Meta/other pixels only after consent; in `basic` no `gtm.js` / `gtag/js` in Network before consent | analytics.md, gtm-meta-pixel.md |
| extra JSON-LD | layout / `lib/content` | `jsonLd={[buildNavigationJsonLd(…)]}`; `siteJsonLd` → `buildLocalBusinessJsonLd` | Rich Results Test | seo.md |
| links and navigation | components | `buildLinkField`/`buildLinksField` in fields; `resolveNav`, `resolveLink`, `getSystemLinks` | a menu link still works after a slug change | links.md, skill **ipal-nav** |
| blocks | `src/blocks/registry.ts` | `blocks` for `createPageRoute`; fields `buildSectionHeaderField`, `buildSectionSettingsField` | block visible on the page | blocks.md, skill **ipal-block** |
| block library (schema) | `src/blocks/configs.ts` → `Pages.layout` | `export const blockOptions = { hero: true, textMedia: true, featureGrid: true, cta: true, richText: true, faq: true, contact: true, gallery: true } satisfies LibraryBlocksOptions`; `blocks: [...libraryBlocks(blockOptions), ...ownBlocks]` (`/blocks`) | block picker in en/pl; `pnpm generate:types`, `generate:importmap`; Postgres/SQLite `migrate:create` | block-library.md |
| blocks (registry) | `src/blocks/registry.ts` | `createBlockRegistry(content, { Image, Link, sendForm, formClassNames, contactDetails?, extra: { own: Own } })` (`/blocks/rsc`; `Image`/`Link` from `next/image`/`next/link`) → `blocks` for `createPageRoute`; own blocks use `buildSectionHeaderField`, `buildSectionSettingsField`, `buildItemsField` | every section has `data-ipal-block`; one `h1` per page | block-library.md, blocks.md, skill **ipal-block** |
| page templates | `scripts/seed-content.ts` | `pageTemplates.home({ blocks: libraryBlockSlugs(blockOptions) })`, `pageTemplates.contact({ form: { $form: 'Contact form' } })` (`/templates`); after launch only with `SEED_ONLY` | seed summary 0 errors | block-library.md, seeding.md |
| FAQ rich results | page route | `getPageJsonLd(locale, slug, { faq: faqItemsFromLayout })` | Rich Results Test → FAQPage | block-library.md, seo.md |
| languages in the header | header | `<LanguageSwitcher>` (`/client`), `<AlternateLinksUpdater>` | switches to `/en/<slug-en>` | i18n.md |
| Tailwind | `styles.css` | `@import "@intecion/ipal-kit/fluid.css";` + `@source "…/node_modules/@intecion/ipal-kit/dist/**/*.js";` | the cookie banner is styled | PROGRAMISTA §2.5 |
| `/its` panel | `app/(payload)/its/…` | `adminRoute: '/its'` + `its` in the proxy matcher | `/its` login, `/admin` 404 | security.md |
| skills | `package.json` | `"ipal:skills": "ipal-skills"` | `.agents/skills/` up to date | PROGRAMISTA §2.1a |
| eject a library block | CLI | `pnpm exec ipal-blocks list` / `pnpm exec ipal-blocks eject faq [--dest src/blocks] [--dry-run]` → `src/blocks/Faq/`; then the ejected builder in `blockOptions`' place and `components: { faq: FaqBlock }` | the block renders from the project file | block-library.md "Own blocks and eject" |
**`createContentHelpers` keys (exports of `@/lib/content`)** — all lazy and cached per request:
@@ -1,7 +1,7 @@
# ipal-kit — export index
Every public export of `@intecion/ipal-kit` (all entries: root, `/client`, `/rsc`,
`/server`, `/seed`, `/next/middleware`, `/admin`, `/env`), grouped by module. Search with grep
`/server`, `/seed`, `/next/middleware`, `/admin`, `/env`, `/blocks`, `/blocks/rsc`, `/templates`), grouped by module. Search with grep
(`grep -n "name" .agents/skills/ipal-reference/resources/api.md`) before you write anything yourself.
"Import from" column — the first entry is preferred. Plugin options, env, routes and what the
project wires: `../SKILL.md`. Module details: `node_modules/@intecion/ipal-kit/docs/<page>.md`.
@@ -109,6 +109,35 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
**Types:** `BlockData`, `BlockComponentMap`, `EnhanceProps`, `RenderBlocksProps` (`/rsc`) — block data, component map, props enhancer, renderer props; `SectionHeaderFieldOptions`, `SectionSettingsFieldOptions` (root) — options of the section field builders.
## Block library (`block-library`) — details: `node_modules/@intecion/ipal-kit/docs/block-library.md`
Fifteen ready blocks and ten page templates. **Use a library block (or a variant / options of one) before writing a block.**
| Export | Import from | What it does / when |
|---|---|---|
| `libraryBlocks(options, shared?)` | `@intecion/ipal-kit/blocks` | The blocks the project turned on, for `Pages.layout`: `{ hero: true, faq: { maxItems: 10 }, cta: (b) => b }`; nothing is on by default; `shared` = `{ localization, settings }` for every block. |
| `libraryBlockSlugs(options)` | `@intecion/ipal-kit/blocks` | Turned-on blocks with renamed slugs → `{ faq: 'faq', testimonials: 'reviews' }` — for `pageTemplates` (`blocks`) and the registry (`slugs`). |
| `LIBRARY_BLOCK_BUILDERS`, `LIBRARY_BLOCK_SLUGS` | `@intecion/ipal-kit/blocks` | Builder per slug; the 15 slugs in picker order. |
| `buildHeroBlock`, `buildTextMediaBlock`, `buildFeatureGridBlock`, `buildCtaBlock`, `buildRichTextBlock`, `buildFaqBlock`, `buildContactBlock`, `buildGalleryBlock`, `buildTestimonialsBlock`, `buildStatsBlock`, `buildStepsBlock`, `buildLogosBlock`, `buildTeamBlock`, `buildPricingBlock`, `buildEntryListBlock` | `@intecion/ipal-kit/blocks` | One block each, `(options?: BlockOptions) => Block`. Options: `slug`, `interfaceName`, `labels`, `admin`, `custom`, `fields` (array or `(defaults) => fields`), `variants` (subset / own / `false`), `header`, `links`, `settings` (`false` drops header / links), `maxItems`, `localization` (`'fields'` / `'layout'`), `thumbnail`. Extra: featureGrid `icons`, testimonials `collection`, entryList `collections`, contact `formsCollection`. |
| `buildItemsField`, `buildMediaField`, `buildVariantField`, `buildIconField`, `buildContentField`, `columnsField`, `COLUMNS` | `@intecion/ipal-kit/blocks` | Field builders of the library for the project's own blocks: `items` array with readable rows, `media` upload, sidebar `variant`, `icon` select of the project's names, `content` rich text, `columns` (`two`/`three`/`four`). |
| `defineLibraryBlock(def)`, `adminText(en, pl)`, `variantOption(value, en, pl)` | `@intecion/ipal-kit/blocks` | The library's block frame (header → fields → buttons → variant → settings) for an own block; `{ en, pl }` text and variant shorthands. |
| `applyBlockOptions(block, options)`, `isNamed(field, name)`, `replaceField(fields, name, patch)`, `removeField(fields, name)`, `stripLocalized(fields)`, `pickVariants(defaults, chosen)` | `@intecion/ipal-kit/blocks` | Option merging and field-list helpers (also for `fields: (defaults) => …`). |
| `blockThumbnail(slug)` | `@intecion/ipal-kit/blocks` | Inline SVG sketch (data URL) for the block picker — what `thumbnail: true` uses. |
| `faqItemsFromLayout(doc, { field?, slugs? })` | `@intecion/ipal-kit/blocks` | FAQ questions of the page's FAQ blocks → `getPageJsonLd(locale, slug, { faq: faqItemsFromLayout })` (FAQPage). |
| `blockLibraryManifest`, `buildBlockLibraryManifest()`, `fieldPaths(fields)` | `@intecion/ipal-kit/blocks` | Plain data: every block's slug, interface name, variants, stored field paths; primitives, field builders, templates — for `ipal-doctor` and tests. |
| `createBlockRegistry(content, options?)` | `@intecion/ipal-kit/blocks/rsc` | `blockType → component` map for `createPageRoute` / `RenderBlocks`, bound to lib/content. Options: `Image`, `Link` (next/image, next/link), `sendForm`, `formClassNames`, `contactDetails`, `classNames` (per block part), `ui` (swap primitives), `components` (swap a block), `backgrounds`, `slugs`, `only`, `extra` (own blocks), `icons`, `texts`, `lightbox`, `richText`, `entryCard`, `mapTestimonial`. |
| `LIBRARY_BLOCK_COMPONENTS` | `@intecion/ipal-kit/blocks/rsc` | The plugin's component per slug. |
| `HeroBlock`, `TextMediaBlock`, `FeatureGridBlock`, `GalleryBlock`, `FaqBlock`, `CtaBlock`, `ContactBlock`, `TeamBlock`, `PricingBlock`, `LogosBlock`, `TestimonialsBlock`, `StatsBlock`, `RichTextBlock`, `StepsBlock`, `EntryListBlock` | `@intecion/ipal-kit/blocks/rsc` | The block components (server; props `LibraryBlockProps`: data + `locale`, `isFirst`, `ui`, `ctx`, `classNames`). |
| `HERO_PARTS`, `TEXT_MEDIA_PARTS`, `FEATURE_GRID_PARTS`, `GALLERY_PARTS`, `FAQ_PARTS`, `CTA_PARTS`, `CONTACT_PARTS`, `TEAM_PARTS`, `PRICING_PARTS`, `LOGOS_PARTS`, `TESTIMONIALS_PARTS`, `STATS_PARTS`, `RICH_TEXT_PARTS`, `STEPS_PARTS`, `ENTRY_LIST_PARTS` | `@intecion/ipal-kit/blocks/rsc` | Default token classes per block part — the keys of `classNames`. |
| `defaultEntryCard(doc)`, `defaultTestimonial(doc)` | `@intecion/ipal-kit/blocks/rsc` | Default mapping of a collection document to an entry card / a testimonial (`entryCard`, `mapTestimonial` replace them). |
| `Section`, `SECTION_BACKGROUNDS`, `SectionHeader`, `Media`, `CMSLink`, `Anchor`, `buttonClass`, `BUTTON_CLASSES`, `Container`, `CONTAINER_WIDTHS`, `Card`, `CARD_CLASS`, `CARD_INTERACTIVE_CLASS` | `@intecion/ipal-kit/blocks/rsc` | UI primitives, token utilities only: section (anchor, background, `data-surface`), heading group, image/video, panel link, link element, button looks, page column, card. |
| `Buttons`, `headingId(block)`, `TitleLink`, `GRID_COLUMNS`, `cx`, `parts(defaults, overrides)` | `@intecion/ipal-kit/blocks/rsc` | Helpers for own blocks: button row, heading id for `aria-labelledby`, card title link (plain text when the link is dead), grid columns, class joining, part classes. |
| `BLOCK_TEXTS`, `blockTexts(locale, own?)`, `fillText(text, value)` | `@intecion/ipal-kit/blocks/rsc` | Visitor texts the blocks write (rating, step) in en/pl; override with `texts`. |
| `pageTemplates` | `@intecion/ipal-kit/templates` | `home`, `about`, `services`, `service`, `contact`, `blogIndex`, `post`, `legal(role)`, `cookiePolicy`, `notFound` → `{ title, slug, layout }` for `seed.upsertBySlug('pages', …)`. Options: `blocks`, `overrides`, `layout`, `slug`, `title`, `defaultLocale`, `linkTo`; `contact`/`service` take `form` (`{ $form: 'title' }`). After launch: only with `SEED_ONLY`. |
| `systemPageRefs(roles)` | `@intecion/ipal-kit/templates` | `{ homepage: 'start' }` → `{ homepage: { $page: 'start' } }` for `seed.fillGlobal('site-settings', …)`. |
**Types:** `BlockOptions`, `BlockBuilder`, `BlockLocalization`, `LibraryBlockSetting`, `LibraryBlocksShared`, `LibraryBlockSlug`, `LibraryBlocksOptions`, `VariantOption`, `LibraryBlockDefinition`, `ContactOptions`, `EntryListOptions`, `FeatureGridOptions`, `TestimonialsOptions`, `ItemsFieldOptions`, `MediaFieldOptions`, `VariantFieldOptions`, `IconFieldOptions`, `Columns`, `BlockLibraryManifest`, `ManifestBlock`, `ManifestField` (`/blocks`); `BlockRegistryOptions`, `BlockContent`, `BlockContext`, `BlockUi`, `LibraryBlockProps`, `ContactDetail`, `EntryCard`, `TestimonialItem`, `BlockTexts`, `PartClasses`, `BaseBlockData`, `LinkData`, `LinksData`, `MediaValue`, `RichTextData`, `SectionHeaderData`, `SectionSettingsData`, `HeroBlockData`, `TextMediaBlockData`, `FeatureGridBlockData`, `FeatureItem`, `GalleryBlockData`, `GalleryItem`, `FaqBlockData`, `FaqItem`, `CtaBlockData`, `ContactBlockData`, `TeamBlockData`, `TeamMember`, `PricingBlockData`, `PricingPlan`, `LogosBlockData`, `LogoItem`, `TestimonialsBlockData`, `StatsBlockData`, `StatItem`, `RichTextBlockData`, `StepsBlockData`, `StepItem`, `EntryListBlockData`, `CMSLinkProps`, `ResolveLink`, `LinkComponent`, `ImageComponent`, `MediaProps`, `SectionProps`, `SectionHeaderProps`, `HeadingLevel`, `CardProps`, `ContainerProps`, `ContainerWidth` (`/blocks/rsc`); `TemplateOptions`, `TemplatePage`, `TemplateBlock`, `TemplateValue` (`/templates`).
## Cookie consent (`consent`) — details: `node_modules/@intecion/ipal-kit/docs/consent.md`
| Export | Import from | What it does / when |
@@ -523,8 +552,8 @@ Server only (`pnpm payload run`); never import it from client code, the Payload
| Export | Import from | What it does / when |
|---|---|---|
| `createSeeder(payload, { dryRun?, update?, force?, only?, guard?, editCheck?, context?, pagesCollection?, label?, log? })` | `@intecion/ipal-kit/seed` | The seed rules in one place → `{ upsertBySlug, upsertBy, fillGlobal, summary, dryRun, update, force, local, only }`. `only` (or `SEED_ONLY`) = the records the run may touch (`pages:kontakt`, `forms:<title>`, `global:<slug>`, `pages:*`), the rest → `skip (not listed)`; a run without it against production / a non-local database throws unless `IPAL_SEED_ALLOW_FULL=1` / `guard.allowFull: true` (after launch: named records only; dry runs are never refused; `guard: false` turns every guard off). Create-only by default, natural keys, never deletes, globals: empty fields only, every locale with `fallbackLocale: false` onto the same row ids, skips records edited since seeding, writes with `context` `{ ipalSeed, disableRevalidate, ipalSkipIndexNow }`. Throws when `update` runs on production / a non-local database without `IPAL_SEED_ALLOW_PROD_UPDATE=1`. Both seed templates use it. |
| `upsertBySlug(collection, data \| data[], { slugField? })` | (method of `createSeeder`) | Matches by the default-locale slug; an array creates missing records first, so `{ $page: 'slug' }` links work in any order. |
| `createSeeder(payload, { dryRun?, update?, force?, only?, guard?, editCheck?, context?, pagesCollection?, formsCollection?, label?, log? })` | `@intecion/ipal-kit/seed` | The seed rules in one place → `{ upsertBySlug, upsertBy, fillGlobal, summary, dryRun, update, force, local, only }`. `only` (or `SEED_ONLY`) = the records the run may touch (`pages:kontakt`, `forms:<title>`, `global:<slug>`, `pages:*`), the rest → `skip (not listed)`; a run without it against production / a non-local database throws unless `IPAL_SEED_ALLOW_FULL=1` / `guard.allowFull: true` (after launch: named records only; dry runs are never refused; `guard: false` turns every guard off). Create-only by default, natural keys, never deletes, globals: empty fields only, every locale with `fallbackLocale: false` onto the same row ids, skips records edited since seeding, writes with `context` `{ ipalSeed, disableRevalidate, ipalSkipIndexNow }`. Throws when `update` runs on production / a non-local database without `IPAL_SEED_ALLOW_PROD_UPDATE=1`. Both seed templates use it. |
| `upsertBySlug(collection, data \| data[], { slugField? })` | (method of `createSeeder`) | Matches by the default-locale slug; an array creates missing records first, so `{ $page: 'slug' }` links work in any order; `{ $form: 'title' }` = the form's id (`formsCollection`, default `forms`). |
| `upsertBy(collection, key, data)` | (method) | Matches by other keys, e.g. a form by `{ title }`. |
| `fillGlobal(slug, data)` | (method) | Fills only empty fields of a global (all seeded fields with `update` when untouched). |
| `summary()` | (method) | Prints and returns `{ created, skipped, updated, skippedEdited, errors }`; exit 1 when `errors`. |
+18 -6
View File
@@ -54,14 +54,22 @@ decision on that part; no hand-built replacement, no silent workaround. **Code r
## Phase 2 — Content model
- Pages = `Pages` + blocks. Collections only for lists with URLs (**ipal-collection**).
- Globals: Header, Footer, Company (**ipal-nav**), Site settings, System pages.
- Every section from the site map → an existing block, a variant of an existing one (`variant`)
or a new block. Goal: as few blocks as possible, as many variants as possible.
- Every section from the site map → **a block of the block library first** (`libraryBlocks` from
`@intecion/ipal-kit/blocks`: hero, textMedia, featureGrid, cta, richText, faq, contact, gallery, testimonials,
stats, steps, logos, team, pricing, entryList — docs/block-library.md), or one of its variants (`variant`),
or its options (`fields`, `variants`, `settings`); a project block only when none fits, recorded in
"Project decisions". Goal: as few own blocks as possible.
- Write the map down: page → sections → library block + variant (or own block + why). The starter turns on
hero, textMedia, featureGrid, cta, richText, faq, contact, gallery; turn on the rest only when the map needs them.
- Schema change with content in the database → **ipal-migrate-fields**, never "live".
## Phase 3 — Navigation and company data → **ipal-nav**
## Phase 4 — Sections → **ipal-block** for every block
Order: Hero → recurring sections (FeatureGrid, CTA, FAQ…) → specific ones.
Library blocks need no code: `libraryBlocks(blockOptions)` in the Pages layout and `createBlockRegistry(content,
{ Image, Link, sendForm })` in `src/blocks/registry.ts` (docs/block-library.md "Setup"). Change looks through
`classNames` / `ui`, never by copying a block; own it completely only with `ipal-blocks eject <block>`.
Own blocks (no library block fits): order Hero → recurring sections → specific ones.
Every block: schema from the field dictionary, composition of primitives, zero text in JSX
(`ipal-audit --quick` after every block — fix errors right away).
**Enlarged images** (gallery, cards, product photos, certificates, rich text): the shared lightbox,
@@ -76,8 +84,11 @@ company **and** confirmation to the customer, every language) — the renderer a
form with fields in JSX, an `api/contact` route, `nodemailer`, reCAPTCHA (AGENT.md §0b).
## Phase 6 — Content in the panel, every language
1. Copy `resources/seed-content.template.ts` → `scripts/seed-content.ts`,
enter content from the brief: pages, blocks, links (`{ $page: 'slug' }`), globals —
1. Copy `resources/seed-content.template.ts` → `scripts/seed-content.ts`. Start every standard page from
`pageTemplates` (`@intecion/ipal-kit/templates`: home, about, services, service, contact, blogIndex, post,
legal, cookiePolicy, notFound) with `blocks: libraryBlockSlugs(blockOptions)` and `overrides` for the brief's
texts; forms by `{ $form: 'Contact form' }`; system pages with `systemPageRefs` (docs/block-library.md).
Enter content from the brief: pages, blocks, links (`{ $page: 'slug' }`), globals —
all languages side by side (`{ pl, en }`). Missing data → `[TO FILL: …]`.
Never invent company data, prices, reviews, numbers, certificates, names.
**VERY IMPORTANT — after launch never run the whole seed again** (the owner's edits must survive): a later
@@ -106,7 +117,8 @@ keep the auto-fill or fix it when the summary is weak.
## Phase 8 — Design
`DESIGN.md` exists → tokens in `@theme`. None → neutral tokens + an Impeccable
recommendation in the report. Do not polish styles ad hoc in components.
recommendation in the report. Do not polish styles ad hoc in components. Library blocks follow the tokens by
themselves (token utilities only); a part that needs another look → `createBlockRegistry({ classNames })`.
Responsiveness: 360 px, 768 px, 1280 px — no horizontal scroll.
## Phase 9 — Verification (all by yourself, results go into the report)
@@ -26,27 +26,37 @@
* heading: { pl: 'Nasze usługi', en: 'Our services' } → localized value
* heading: 'Nasze usługi' → same in every locale / non-localized field
* page: { $page: 'kontakt' } → ID of the page whose DEFAULT-locale slug is 'kontakt'
* form: { $form: 'Contact form' } → ID of the form with that title (seed forms first)
* Missing data: '[TO FILL: tax ID (NIP)]' — never invent company data, prices, reviews, numbers.
* Media: leave empty or reference existing uploads by ID — the editor adds images. Never upload here.
*/
import config from '@payload-config'
import { libraryBlockSlugs } from '@intecion/ipal-kit/blocks'
import { createSeeder } from '@intecion/ipal-kit/seed'
import { pageTemplates } from '@intecion/ipal-kit/templates'
import { getPayload } from 'payload'
import { blockOptions } from '@/blocks/configs'
// ------------------------------------------------------------------ CONTENT --
// Standard pages start from the library templates (docs/block-library.md "Page templates"): every text in
// pl + en, [TO FILL: …] where only the client can write. Put the brief's texts in `overrides`; change the
// sections with `layout`. `blocks` = the library blocks this project turned on (others are left out).
const blocks = libraryBlockSlugs(blockOptions)
const PAGES: Record<string, unknown>[] = [
{
title: { pl: 'Strona główna', en: 'Home' },
slug: { pl: 'home', en: 'home' },
layout: [
{
blockType: 'hero',
pageTemplates.home({
blocks,
overrides: {
hero: {
header: { heading: { pl: 'Nagłówek z briefu', en: 'Heading from the brief' } }, // buildSectionHeaderField
links: [{ link: { type: 'internal', page: { $page: 'kontakt' }, label: { pl: 'Kontakt', en: 'Contact' }, appearance: 'primary' } }],
variant: 'split',
},
],
},
{ title: { pl: 'Kontakt', en: 'Contact' }, slug: { pl: 'kontakt', en: 'contact' }, layout: [] },
},
}),
pageTemplates.contact({ blocks, form: { $form: 'Contact form' } }), // seed the form first (ipal-form)
pageTemplates.legal('privacyPolicy', { blocks }),
pageTemplates.notFound({ blocks }),
// A page of your own: { title: { pl, en }, slug: { pl, en }, layout: [{ blockType: 'faq', items: [...] }] }
]
const GLOBALS: { slug: string; data: Record<string, unknown> }[] = [
// { slug: 'header', data: { links: [{ link: { type: 'internal', page: { $page: 'kontakt' }, label: { pl: 'Kontakt', en: 'Contact' } } }] } },
+276
View File
@@ -0,0 +1,276 @@
# Block library — ready page sections and page templates
Fifteen standard page sections (Payload block + React server component) and ten page templates,
so every site is assembled from the same parts. Each block is made of the plugin's building blocks
(`buildSectionHeaderField`, `buildLinksField`, `RenderForm`, `LightboxTrigger`, `RenderRichText`…),
has an editor panel in English and Polish (docs/dev/admin-ux.md), meets the accessibility rules below,
and is styled **only with the design-token utilities** (`bg-surface`, `text-fg`, `py-section`…).
Nothing is on by default. The project turns on the blocks it wants, and can change, swap or eject any
of them, or keep its own blocks in the same layout (CLAUDE.md main rule).
| Entry | What | Imported by |
|---|---|---|
| `@intecion/ipal-kit/blocks` | block configs, field builders, the manifest — no React | `payload.config`, collections |
| `@intecion/ipal-kit/blocks/rsc` | block components, UI primitives, `createBlockRegistry` | `src/blocks/registry.ts` |
| `@intecion/ipal-kit/templates` | page templates (seed data) | seed scripts only |
## Setup (a new site)
**1. Turn the blocks on in the Pages layout:**
```ts
// src/blocks/configs.ts — imported by src/collections/Pages.ts
import { libraryBlocks, type LibraryBlocksOptions } from '@intecion/ipal-kit/blocks'
export const blockOptions = {
hero: true, textMedia: true, featureGrid: true, cta: true, richText: true, faq: true, contact: true, gallery: true,
} satisfies LibraryBlocksOptions
export const pageBlocks = [
...libraryBlocks(blockOptions),
// the project's own blocks, e.g. TimelineBlock
]
// Pages.ts: { name: 'layout', type: 'blocks', blocks: pageBlocks }
```
The eight above are what every surveyed site built; add `testimonials`, `stats`, `steps`, `logos`, `team`,
`pricing`, `entryList` when the site map needs them. Fewer blocks = a shorter block picker for the editor.
**2. The registry** — every library block bound to lib/content, plus the project's own:
```ts
// src/blocks/registry.ts
import Image from 'next/image'
import Link from 'next/link'
import { createBlockRegistry } from '@intecion/ipal-kit/blocks/rsc'
import * as content from '@/lib/content'
import { sendForm } from '@/lib/sendForm'
import { formClasses } from '@/components/forms/formClasses'
export const blockRegistry = createBlockRegistry(content, {
Image, // next/image: optimized images with blur-up (without it: a plain <img>)
Link, // next/link: client-side navigation (without it: a plain <a>)
sendForm, // the contact block's form action (createSubmitAction, docs/forms.md)
formClassNames: formClasses,
// contactDetails: async (locale) => [{ label: 'Phone', value: '+48 …', href: 'tel:+48…' }],
// extra: { timeline: TimelineBlock },
})
```
The plugin never imports `next/*` itself, so `Image` and `Link` are passed in. `createPageRoute(content, { blocks: blockRegistry, … })`
or `<RenderBlocks components={blockRegistry} />` renders them (docs/frontend.md, docs/blocks.md).
**3. Styles.** The components use the token utilities of the design-token preset (`@intecion/ipal-kit/tailwind.css`)
and Tailwind must scan the plugin's files — the line projects already have:
```css
@import "tailwindcss";
@source "../../../node_modules/@intecion/ipal-kit/dist/**/*.js";
```
**4. Also wire:** `<SiteProviders lightbox>` in the layout (gallery images open in the viewer, docs/lightbox.md) and
FAQ rich results: `getPageJsonLd(locale, slug, { faq: faqItemsFromLayout })` (docs/seo.md). For your own
`seo` pass-through: `faqItemsFromLayout(doc, { slugs: ['faq'] })`.
**5. Then:** `pnpm generate:types` · `pnpm payload generate:importmap` (the blocks use the plugin's row-label
component) · Postgres/SQLite: `pnpm payload migrate:create` and commit the migration (MongoDB needs none).
**Verify:** the block picker shows the blocks in the editor's language; adding each block shows at most six
fields; a page with every block renders (`pnpm build`); every section has `data-ipal-block="<slug>"` in the HTML; only the
first section's heading is `h1`; the gallery opens images in the viewer; `ipal-doctor` / `ipal-audit` report no block errors.
## The blocks
Every block has, in panel order: `header` (eyebrow, heading, intro) → its own fields → `links` (buttons, where the
block has them) → `variant` (sidebar) → `settings` (sidebar: anchor, background). Field names follow AGENT.md §6.5.
| Slug (builder) | Panel name | Own fields | Variants | Accessibility |
|---|---|---|---|---|
| `hero` (`buildHeroBlock`) | Hero / `Sekcja główna` | `media` (image or video), `poster` | `split`, `background`, `centered`, `page` | the first section's heading is the page `h1`; its image is the LCP image (eager, high priority); a background image is decorative (`alt=""`) under a scrim |
| `textMedia` (`buildTextMediaBlock`) | Text and image | `content` (rich text), `media` | `mediaRight`, `mediaLeft` | reading order = text first on every screen |
| `featureGrid` (`buildFeatureGridBlock`) | Feature grid | `items[]`: `icon` (with `icons`), `media`, `heading`, `text`, `link`; `columns` | `cards`, `list`, `numbered` | a linked feature: its heading is the link and covers the card; a dead link leaves plain text |
| `gallery` (`buildGalleryBlock`) | Gallery | `items[]`: `media`, `caption`; `columns` | `grid`, `masonry` | each image a `LightboxTrigger` (keyboard, focus return, labels from Form messages); captions in `<figcaption>` |
| `faq` (`buildFaqBlock`) | FAQ | `items[]`: `question`, `answer` | `single`, `twoColumn` | native `<details>`/`<summary>`, works without script |
| `cta` (`buildCtaBlock`) | Call to action | `media` | `band`, `card`, `split` | renders nothing without a heading and buttons |
| `contact` (`buildContactBlock`) | Contact | `form` (relation), `content` | `formWithDetails`, `formOnly` | `RenderForm` (labels, errors, consent); details as `<dl>` |
| `team` (`buildTeamBlock`) | Team | `items[]`: `media`, `heading` (name), `text` (role), `bio`, `link` | `grid`, `list` | the name is the profile link |
| `pricing` (`buildPricingBlock`) | Pricing | `items[]`: `heading`, `price`, `period`, `text`, `features[]`, `highlighted`, `link`; `highlightLabel`, `note` | — | the highlighted plan carries a text label, not only a colour |
| `logos` (`buildLogosBlock`) | Logos | `items[]`: `media`, `heading` (name), `link` | `row`, `grid` | the name is the alt text when the image has none; no marquee |
| `testimonials` (`buildTestimonialsBlock`) | Testimonials | `items[]`: `quote`, `heading` (author), `text`, `media`, `rating`; with `collection`: `source`, `entries` | `grid`, `single` | `<figure>` + `<blockquote>` + `<figcaption>`; stars hidden, rating read as text |
| `stats` (`buildStatsBlock`) | Key figures / `Liczby` | `items[]`: `value`, `heading` (label), `text` | `row`, `cards` | a `<dl>`; static (no count-up animation) |
| `richText` (`buildRichTextBlock`) | Text | `content`, `tableOfContents` | `narrow`, `wide` | heading anchors + table of contents (`aria-current` on the section being read) |
| `steps` (`buildStepsBlock`) | Steps | `items[]`: `heading`, `text`, `media` | `numbered`, `timeline` | an `<ol>`; the number read as "Step 1" |
| `entryList` (`buildEntryListBlock`) | Entry list | `collection`, `mode` (latest / chosen), `limit`, `entries` | `cards`, `list` | each title links to its entry and covers the card; dates in `<time>` |
**Rules every block meets:** one `<section>` with `aria-labelledby` its heading and `data-ipal-block`; `h1` only in the
first block (`isFirst` from `createPageRoute`), `h2` otherwise, items `h3`; images through `Media` (alt from the media
document, width and height, lazy except the hero); visible focus (`outline-focus`); no autoplay, motion only through
the token durations (0 ms under reduced motion); **an empty block renders nothing** (no empty section, no "Lorem").
**Visitor texts** the components write themselves — `rating` ("Rated {value} out of 5") and `step` ("Step {value}") —
ship in English and Polish (`BLOCK_TEXTS`, picked by `blockTexts(locale, own)`, `{value}` filled by `fillText`); other
languages or words: `createBlockRegistry(content, { texts: { de: { rating: '{value} von 5' } } })`. Everything else
comes from the panel.
## Change a block (schema)
`libraryBlocks(options, shared?)` takes a setting per block: `true`, an options object, a function `(block) => block`
that takes the finished block over, or `false`/missing = off. `shared` (`localization`, `settings`) applies to every
block; a block's own options win. Each block also has its own builder (`buildFaqBlock(options)` …, all in
`LIBRARY_BLOCK_BUILDERS`, slugs in `LIBRARY_BLOCK_SLUGS`).
| Option (`BlockOptions`) | Does |
|---|---|
| `slug` | keep an existing slug, e.g. `testimonials: { slug: 'reviews' }` (then `libraryBlockSlugs(options)` gives the registry and the templates the renamed slugs) |
| `interfaceName`, `labels`, `admin`, `custom` | the generated type name, the panel name, merged admin / custom |
| `fields` | an array replaces the fields; `(defaults) => fields` adds, changes or drops some — `replaceField(fields, 'media', { required: true })`, `removeField(fields, 'links')`, `isNamed(field, 'items')` |
| `variants` | a subset (`['single']`), the project's own (`{ label: { en, pl }, value }`), or `false` (no select). Unknown names throw (`pickVariants`) |
| `header`, `links`, `settings` | options for `buildSectionHeaderField`, `buildLinksField`, `buildSectionSettingsField` (e.g. project backgrounds); `header: false` / `links: false` drop them |
| `maxItems` | the `items` limit |
| `localization` | `'fields'` (default: text localized inside the block) or `'layout'` for projects that localize the whole `layout` field — drops every inner `localized` (`stripLocalized`) |
| `thumbnail` | the block picker picture: `true` = the plugin's sketch (an inline SVG from `blockThumbnail(slug)`, no route), a URL of your own, default none |
Block-specific options: `featureGrid: { icons: ['phone', 'mail'] }` (the project's icon names — adds an icon select;
the components come from `createBlockRegistry({ icons })`), `testimonials: { collection: 'testimonials' }` (pick from a
collection as well), `entryList: { collections: [{ label: { en: 'Projects', pl: 'Realizacje' }, value: 'projects' }] }`
(default posts), `contact: { formsCollection }` (default `forms`).
**Same panel for the project's own blocks:** `buildItemsField({ fields, labels, rowLabelField, maxRows })`,
`buildMediaField()`, `buildVariantField({ options })`, `buildIconField({ names })`, `buildContentField()`,
`columnsField()` (values `COLUMNS`: `two`, `three`, `four`), `adminText(en, pl)`, `variantOption(value, en, pl)`, and
`defineLibraryBlock({ slug, interfaceName, labels, fields, links, variants })` for the same frame
(header → fields → buttons → variant → settings). `applyBlockOptions(block, options)` applies `BlockOptions` to any block.
## Change the look or the component (front end)
`createBlockRegistry(content, options)` returns the `blockType → component` map; `LIBRARY_BLOCK_COMPONENTS` lists the
plugin's components. `content` needs `resolveLink`; `getEntries` (entry list), `getFormTexts` and `getLinkOptions`
(contact) are used when present — pass the whole `@/lib/content`.
| Option (`BlockRegistryOptions`) | Does |
|---|---|
| `classNames` | replace the classes of one part: `{ faq: { item: 'border-b border-border' } }`. The parts and their defaults: `HERO_PARTS`, `TEXT_MEDIA_PARTS`, `FEATURE_GRID_PARTS`, `GALLERY_PARTS`, `FAQ_PARTS`, `CTA_PARTS`, `CONTACT_PARTS`, `TEAM_PARTS`, `PRICING_PARTS`, `LOGOS_PARTS`, `TESTIMONIALS_PARTS`, `STATS_PARTS`, `RICH_TEXT_PARTS`, `STEPS_PARTS`, `ENTRY_LIST_PARTS` |
| `ui` | swap a primitive for every block: `{ Media, CMSLink, Section, SectionHeader, Container, Card, buttonClass }` |
| `components` | replace one block's component; it gets the same props (`LibraryBlockProps`: the data, `locale`, `isFirst`, `ui`, `ctx`, `classNames`) |
| `backgrounds` | section background values → classes, merged over `SECTION_BACKGROUNDS` (`default`, `muted`, `inverted`) |
| `slugs`, `only`, `extra` | renamed slugs; only some blocks; the project's own blocks in the same map |
| `Image`, `Link` | next/image and next/link |
| `sendForm`, `formClassNames`, `contactDetails` | the contact block: form action, form classes, details beside the form |
| `entryCard`, `mapTestimonial` | how a collection document becomes an entry card / a testimonial (defaults `defaultEntryCard`, `defaultTestimonial`) |
| `icons`, `texts`, `lightbox`, `richText` | feature icons by name; visitor texts; `lightbox: false` = plain gallery images; `richText.className` for every rich text |
**UI primitives** (`/blocks/rsc`), each styled once with token utilities: `Section` (anchor, background,
`data-surface` for the inverted token scope, spacing, `Container`), `SectionHeader` (eyebrow, `h1`/`h2`, intro),
`Media` (image or video; `next/image` when passed), `CMSLink` (a panel link → `Anchor`, with `buttonClass`),
`buttonClass` / `BUTTON_CLASSES` (button looks by appearance), `Container` / `CONTAINER_WIDTHS`, `Card` / `CARD_CLASS` /
`CARD_INTERACTIVE_CLASS`. Helpers for the project's own blocks: `Buttons` (a block's button row), `headingId(block)`
(the heading id for `aria-labelledby`), `TitleLink` (a card title that links when its link resolves), `GRID_COLUMNS`,
`cx`, `parts(defaults, overrides)`.
**Every component is exported** (`HeroBlock`, `TextMediaBlock`, `FeatureGridBlock`, `GalleryBlock`, `FaqBlock`, `CtaBlock`,
`ContactBlock`, `TeamBlock`, `PricingBlock`, `LogosBlock`, `TestimonialsBlock`, `StatsBlock`, `RichTextBlock`,
`StepsBlock`, `EntryListBlock`) for a project that wires them without the factory.
**Section backgrounds and tokens.** `settings.background` → `default` `bg-bg text-fg`, `muted` `bg-surface-muted`
(+ `data-surface="muted"`), `inverted` `bg-inverse text-on-inverse` + `data-surface="inverse"`; inside the inverse
scope the token preset re-maps text, borders, links and focus, so blocks use plain `text-fg`, `text-link`,
`border-border`. No hex, no `dark:` for colours, no `clamp()` in the components (a test enforces it).
## Own blocks and eject
A section no library block or variant fits → the project's own block (**ipal-block** skill): `src/blocks/<Name>/`,
the same field builders and primitives, added to `pageBlocks` and to `extra` in the registry.
To own a library block completely:
```bash
pnpm exec ipal-blocks list
pnpm exec ipal-blocks eject faq # → src/blocks/Faq/config.ts + Component.tsx
```
Eject copies the block's source with its imports pointing at the package entries (same slug, same data shape —
no migration). Then use the ejected `buildFaqBlock` in `pageBlocks` (instead of `faq: true`), pass
`components: { faq: FaqBlock }` to the registry, and record it in AGENTS.md → "Project decisions". It never
overwrites an existing file (`--dest`, `--dry-run`).
## Page templates
`pageTemplates` (`@intecion/ipal-kit/templates`) — pages made of library blocks, every text in English and Polish,
`[TO FILL: …]` where only the client can write. Data for `createSeeder` (docs/seeding.md); nothing changes in the panel.
| Template | Layout | System page role |
|---|---|---|
| `home()` | hero · logos · featureGrid · textMedia · stats · testimonials · faq · cta | `homepage` |
| `about()` | hero (page) · textMedia · stats · team · steps · cta | — |
| `services()` | hero (page) · featureGrid · steps · pricing · faq · cta | — |
| `service({ form? })` | hero · textMedia · featureGrid (list) · gallery · faq · contact | — |
| `contact({ form })` | hero (page) · contact · faq | — |
| `blogIndex()` | hero (page) · cta — the entries come from the archive view (docs/content.md) | `postsArchive` |
| `post()` | richText (table of contents) · entryList · cta — for a posts collection with a `layout` field | — |
| `legal('privacyPolicy' \| 'termsOfService')` | hero (page) · richText (table of contents) — structure only; the wording comes from the client | `privacyPolicy`, `termsOfService` |
| `cookiePolicy()` | hero (page) · richText | `cookiePolicy` |
| `notFound()` | hero (page) with a button home | `notFound` |
```ts
// scripts/seed-content.ts
import { libraryBlockSlugs } from '@intecion/ipal-kit/blocks'
import { pageTemplates, systemPageRefs } from '@intecion/ipal-kit/templates'
import { blockOptions } from '@/blocks/configs' // the object passed to libraryBlocks
const blocks = libraryBlockSlugs(blockOptions) // blocks that are off are left out (with a warning)
await seed.upsertBy('forms', { title: 'Contact form' }, CONTACT_FORM)
await seed.upsertBySlug('pages', [
pageTemplates.home({ blocks, overrides: { hero: { header: { heading: { pl: '…', en: '…' } } } } }),
pageTemplates.contact({ blocks, form: { $form: 'Contact form' } }),
pageTemplates.legal('privacyPolicy', { blocks }),
])
await seed.fillGlobal('site-settings', systemPageRefs({ homepage: 'start', privacyPolicy: 'polityka-prywatnosci' }))
```
Template options (`TemplateOptions`): `blocks` (turned-on blocks with renamed slugs), `overrides` (data per block),
`layout` (`(blocks) => blocks` to reorder, drop or add), `slug`, `title`, `defaultLocale` (buttons link to pages by
their slug in it; default `pl`), `linkTo` (the slugs of the about / contact / home pages when yours differ).
`{ $form: 'title' }` and `{ $page: 'slug' }` are seed references (docs/seeding.md).
**After launch — named records only** (AGENT.md "Seeding on production", docs/seeding.md): use a template only through a
seed that names its records — `SEED_ONLY="pages:kontakt" pnpm payload run scripts/seed-content.ts` after
`SEED_DRY_RUN=1` and a Coolify backup — never a run of every template. Seeds stay create-only; a page an editor
changed is skipped. A newer ipal-kit never changes existing pages: templates are only read when a seed runs.
## Versioning — new fields never break content
- A minor release only **adds**: new optional fields (or with a `defaultValue`), new variant values. A component renders
the old output while a new field is empty.
- Never in a minor: renaming or removing a stored field, a select value, a slug or an `interfaceName`; a new
required field; a field becoming required. A rename happens only in a major, with an **ipal-migrate-fields** recipe
and upgrade notes.
- Database names come from the slugs and field names only — never from labels — so renaming a panel label changes no
table, column or enum.
- `test/blockLibrarySchema.test.ts` compares every block's field paths, types, select values and required flags with
`test/block-library.schema.json` and fails on any of the above.
- Upgrade notes list every new field. Postgres/SQLite: a new field needs `pnpm payload migrate:create` in the project;
MongoDB needs nothing.
## Manifest (for checks)
`blockLibraryManifest` (`/blocks`) is plain data built from the block configs: every block's `slug`, `interfaceName`,
`variants` and stored `fields` (paths from `fieldPaths(fields)`), the `primitives` a project may swap, the
`fieldBuilders` a project block should use instead of its own copy, and the `templates`. `ipal-doctor` reads its names
from here. `buildBlockLibraryManifest()` builds it again (e.g. in a test).
## Turn off, override, extend
| What | Default | Turn off / override |
|---|---|---|
| Any block | off | `libraryBlocks({ faq: true })`; your own block next to it |
| Fields, labels, variants, slug | the library's | `BlockOptions` per block, or `(block) => block` |
| Look of one part | token classes (`*_PARTS`) | `classNames` per block and part |
| A primitive | the plugin's | `ui: { Media, CMSLink, … }` |
| A block's component | the plugin's | `components: { faq: MyFaq }`, or eject |
| Images / links | `<img>` / `<a>` | `Image` / `Link` (next/image, next/link) |
| Lightbox on gallery images | on | `lightbox: false` |
| Visitor texts | `en`, `pl` | `texts` |
| Picker thumbnails | off | `thumbnail: true` or a URL |
| Localization | inside the blocks | `localization: 'layout'` |
| The whole library | not used | don't import it — `RenderBlocks` and the field builders work as before (docs/blocks.md) |
+4
View File
@@ -1,5 +1,9 @@
# blocks
> **Ready sections:** the plugin ships fifteen standard blocks (hero, FAQ, gallery, contact…) and page
> templates — [block-library.md](./block-library.md). Use a library block or a variant of one first; this page
> describes the engine and the field builders they are made of, which your own blocks use too.
`RenderBlocks` — a generic, server-side block rendering engine. The plugin does not
know your blocks: it iterates over the data, maps `blockType` → component through a
registry (prop), handles nesting and per-block extensions. You define the blocks
+25 -7
View File
@@ -1,6 +1,7 @@
# Block library — proposal
> **Status:** approved design, not built. The owner accepted every recommendation, D1–D10, on 2026-10-29 (§12).
> **Status:** approved (D1–D10, 2026-10-29) and built on `claude/block-library-build`. The shipped reference is
> [block-library.md](../block-library.md); where the build differs from this proposal, §13 says how and why.
> Building starts when the coordinator confirms that all five designs (tokens, blocks, reference site,
> doctor, starter) are in and consistent.
> **Scope:** a shared set of page blocks and page templates in `@intecion/ipal-kit`, so agents
@@ -118,7 +119,6 @@ New entries (names to confirm, decision D1):
|---|---|---|
| `@intecion/ipal-kit/blocks` | block configs and field builders (no React) | `payload.config`, collections |
| `@intecion/ipal-kit/blocks/rsc` | block components, UI primitives, `createBlockRegistry` | the page route, `blocks/registry.ts` |
| `@intecion/ipal-kit/blocks/client` | small client parts (accordion state, if any) | used internally; exported for custom components |
| `@intecion/ipal-kit/templates` | page template data for seeds | seed scripts only |
**Manifest.** `@intecion/ipal-kit/blocks` also exports `blockLibraryManifest`, plain data with no React:
@@ -166,21 +166,21 @@ Phase 2 = less common blocks.
| Slug | Panel name (en / pl) | Fields (in panel order) | Variants | Notes |
|---|---|---|---|---|
| `hero` | Hero / Sekcja główna | `header`, `media`, `links`, `settings` | `split` (image beside), `background` (image behind, `bg-overlay` scrim), `centered`, `page` (small page hero, no media) | the LCP image: `priority` when `isFirst`; video via `Media videoMode="background"` with a poster |
| `hero` | Hero / `Sekcja główna` | `header`, `media`, `links`, `settings` | `split` (image beside), `background` (image behind, `bg-overlay` scrim), `centered`, `page` (small page hero, no media) | the LCP image: `priority` when `isFirst`; video via `Media videoMode="background"` with a poster |
| `textMedia` | Text and image / Tekst i obraz | `header`, `content` (rich text), `media`, `links`, `settings` | `mediaRight`, `mediaLeft` | rich text via `RenderRichText`; image `sizes` = half |
| `featureGrid` | Feature grid / Siatka zalet | `header`, `items[]` (`icon` or `media`, `heading`, `text`, `link`), `links`, `settings` | `cards`, `list`, `numbered`; columns 2 / 3 / 4 | covers USP lists, service cards, category cards; whole card clickable when `link` has no label |
| `gallery` | Gallery / Galeria | `header`, `items[]` (`media`, `caption`), `links`, `settings` | `grid`, `masonry`; columns | every image a `LightboxTrigger` (group = block id); labels from Form messages → Image viewer; no own prev/next fields |
| `faq` | FAQ / Pytania i odpowiedzi | `header`, `items[]` (`question`, `answer`), `links`, `settings` | `single`, `twoColumn` | `<details>`/`<summary>`; FAQPage JSON-LD through `getPageJsonLd({ faq })` with the exported `faqItemsFromLayout()` |
| `cta` | Call to action / Wezwanie do działania | `header`, `links`, `media` (optional), `settings` | `band`, `card`, `split` | wrap in `<NoSnippet>` when the project repeats it on every page (option) |
| `cta` | Call to action / `Wezwanie do działania` | `header`, `links`, `media` (optional), `settings` | `band`, `card`, `split` | wrap in `<NoSnippet>` when the project repeats it on every page (option) |
| `contact` | Contact / Kontakt | `header`, `form` (relation to `forms`), `details` (from the company global, toggle), `content`, `settings` | `formOnly`, `formWithDetails` | form through `RenderForm` (`sendForm`, `formTexts` from `blockProps`); `classNames` from the shared form tokens; contact details from a project-supplied resolver, never typed into the block |
| `team` | Team / Zespół | `header`, `items[]` (`media`, `heading` = name, `text` = role, `link` = profile), `settings` | `grid`, `list` | profile link label = screen-reader text |
| `team` | Team / `Zespół` | `header`, `items[]` (`media`, `heading` = name, `text` = role, `link` = profile), `settings` | `grid`, `list` | profile link label = screen-reader text |
| `pricing` | Pricing / Cennik | `header`, `items[]` (`heading`, `price`, `period`, `text`, `features[]`, `highlighted`, `link`), `note`, `settings` | — | highlighted plan: label text from the block (`highlightLabel`), not colour only |
| `logos` | Logos / Logotypy | `header`, `items[]` (`media`, `heading` = name, `link`), `settings` | `row`, `grid` | alt = name when the media alt is empty; no marquee by default (reduced motion) |
| `testimonials` | Testimonials / Opinie | `header`, `source` (`inline` / `collection`), `items[]` (`quote`, `heading` = author, `text` = role, `media`, `rating`) or `entries` (relation), `settings` | `grid`, `single` | `<figure>` + `<blockquote>` + `<figcaption>`; rating has a text equivalent; `collection` mode only when the project passes the collection slug |
| `stats` | Key figures / Liczby | `header`, `items[]` (`value`, `heading` = label, `text`), `settings` | `row`, `cards` | static numbers; count-up animation off by default and never under reduced motion. Panel name avoids "statistics" (glossary: visit counting) |
| `richText` | Text / Tekst | `header`, `content`, `tableOfContents` (`buildTableOfContentsField`), `settings` | `narrow` (measure), `wide` | used by legal pages and posts; heading anchors from `richtext/headings` |
| `steps` | Steps / Kroki | `header`, `items[]` (`heading`, `text`, `media`), `links`, `settings` | `numbered`, `timeline` | ordered list `<ol>` |
| `entryList` | Entry list / Lista wpisów | `header`, `collection` (select from the project's `content.collections`), `mode` (`latest` / `selected`), `entries`, `limit`, `links`, `settings` | `cards`, `list` | blog teasers, projects, products; data loaded on the server through `createContentHelpers` |
| `entryList` | Entry list / `Lista wpisów` | `header`, `collection` (select from the project's `content.collections`), `mode` (`latest` / `selected`), `entries`, `limit`, `links`, `settings` | `cards`, `list` | blog teasers, projects, products; data loaded on the server through `createContentHelpers` |
| *phase 2* `video`, `tabs`, `map`, `cookieTable`, `comparisonTable` | | | | `video` = `YouTubeEmbed`/`Media player`; `map` behind consent; `cookieTable` wraps `CookieTable` |
Field names follow AGENT.md §6.5 (`header`, `items`, `heading`, `text`, `content`, `media`, `link(s)`,
@@ -302,7 +302,7 @@ names**, compiled by the project through `@source "…/node_modules/@intecion/ip
(the line projects already have). All seven sites use Tailwind v4. Each element also gets a
`data-ipal-block` / `data-ipal-part` attribute, and each block takes a `classNames` map (like
`RenderForm`) that replaces the default classes per part. Alternative: a plain CSS file
(`@intecion/ipal-kit/blocks.css`) on CSS variables — works without Tailwind, but is harder to
(a `blocks.css` file in the package) on CSS variables — works without Tailwind, but is harder to
change per project.
## 7. How a project uses, changes and extends it
@@ -489,3 +489,21 @@ The owner accepted every recommendation below on 2026-10-29 ("Accept all three",
| D8 | Move existing sites onto the library, or new sites only | **new sites + the reference site now**; old sites move block by block when they get work, with ipal-migrate-fields recipes, never as a big-bang |
| D9 | Testimonials: inline items only, or also a relation to a `testimonials` collection | **both**, collection mode only when the project names the collection |
| D10 | Panel name for the stats block ("Statistics" is the glossary word for visit counting) | **"Key figures" / "Liczby"** |
## 13. As built — differences from this proposal
- **No `/blocks/client` entry.** No block needed its own client code: FAQ is `<details>`, the gallery uses the
lightbox's `LightboxTrigger`, the table of contents is the rich-text module's.
- **`next/image` and `next/link` are passed in** (`createBlockRegistry(content, { Image, Link })`), because the plugin
never imports `next/*`. Without them the blocks render a plain `<img>` (width, height, lazy, focal point) and `<a>`.
- **No pinned `dbName`.** A fixed table name would clash when one block is used in two collections. Database names
come only from slugs and field names (never labels), and the schema snapshot test guards them.
- **Contact needs no `blockProps`:** the block reads the form texts and link options from lib/content itself; only
`sendForm` is passed to the registry.
- **`ui` primitives:** `Button` is the `buttonClass` function (a look, not an element); `Anchor` and `TitleLink` were
added so internal links can use next/link and a card title stays text when its link is dead.
- **Admin wording:** the new admin-ux test over the library found two 4-word labels in existing builders —
the link checkbox is now "New tab" (with a description) and the table-of-contents switch "Show contents".
- **Seeder:** `{ $form: 'title' }` references are deferred to the second pass like `$page`, so a page with a form
never reaches the database with an unresolved reference.
+6 -2
View File
@@ -194,11 +194,14 @@ process.exit(seed.summary().errors ? 1 : 0)
**Seed values.** Write each value once, every language side by side. An object whose keys are all
locale codes is one value per locale (`{ pl: 'Kontakt', en: 'Contact' }`); anything else is the same
in every locale. A locale missing from such an object is left untouched in that locale.
`{ $page: 'kontakt' }` becomes the ID of the page whose default-locale slug is `kontakt`.
`{ $page: 'kontakt' }` becomes the ID of the page whose default-locale slug is `kontakt`;
`{ $form: 'Contact form' }` becomes the ID of the form with that title (seed the form first). A missing form
is an error for that record, never an empty relation. Ready pages made of library blocks:
`pageTemplates` in [block-library.md](./block-library.md#page-templates).
| Method | What it does |
|---|---|
| `upsertBySlug(collection, data \| data[], { slugField })` | matches by the default-locale slug (`slugField`, default `slug`). With an array, missing records are created first (without fields that hold `$page` links), then every record gets its full content, so pages can link to each other in any order |
| `upsertBySlug(collection, data \| data[], { slugField })` | matches by the default-locale slug (`slugField`, default `slug`). With an array, missing records are created first (without fields that hold `$page` / `$form` links), then every record gets its full content, so pages can link to each other in any order |
| `upsertBy(collection, key, data)` | matches by other natural keys, e.g. `{ title: 'Contact form' }` (all keys must match, default locale) |
| `fillGlobal(slug, data)` | fills only the global's empty fields (the default locale decides). With `update` and an untouched global: every seeded field |
| `summary()` | prints the summary and returns `{ created, skipped, updated, skippedEdited, errors }` |
@@ -245,6 +248,7 @@ the script:
| `SEED_HASH_FIELD` | `editCheck.hashField` | `seedHash` | the hash field name; empty / `false` = timestamps only |
| — | `context` | `{ ipalSeed, disableRevalidate, ipalSkipIndexNow }` all `true` | merged over the defaults; set a key to `false` to drop it |
| — | `pagesCollection` | `pages` | the collection `{ $page }` links resolve in |
| — | `formsCollection` | `forms` | the collection `{ $form }` links resolve in (by `title`) |
| — | `label`, `log` | `[seed]`, stdout | line prefix and where lines go |
| `SEED_NOTIFY_EMAIL` | — | — | form seed: notification address for a first run when the company global is still empty |
+19 -2
View File
@@ -22,7 +22,7 @@ import { buildTeamBlock } from './blocks/team/config.js'
import { buildTestimonialsBlock } from './blocks/testimonials/config.js'
import { buildTextMediaBlock } from './blocks/textMedia/config.js'
/** Every library block builder, by default slug, in the order of the block picker. */
/** Every library block builder, by default slug. */
export const LIBRARY_BLOCK_BUILDERS = {
contact: buildContactBlock,
cta: buildCtaBlock,
@@ -41,7 +41,24 @@ export const LIBRARY_BLOCK_BUILDERS = {
textMedia: buildTextMediaBlock,
} satisfies Record<LibraryBlockSlug, BlockBuilder<never>>
export const LIBRARY_BLOCK_SLUGS = Object.keys(LIBRARY_BLOCK_BUILDERS) as LibraryBlockSlug[]
/** The 15 slugs in the order of the block picker: the sections every site needs first. */
export const LIBRARY_BLOCK_SLUGS: readonly LibraryBlockSlug[] = [
'hero',
'textMedia',
'featureGrid',
'cta',
'richText',
'faq',
'contact',
'gallery',
'testimonials',
'stats',
'steps',
'logos',
'team',
'pricing',
'entryList',
]
/** What `libraryBlocks` takes: a setting per block. Blocks not listed are off. */
export type LibraryBlocksOptions = {
+3
View File
@@ -16,12 +16,15 @@ const read = (p: string) => readFileSync(path.join(root, p), 'utf8')
const ENTRIES: Record<string, string> = {
'': 'src/index.ts',
'/admin': 'src/exports/admin.ts',
'/blocks': 'src/exports/blocks.ts',
'/blocks/rsc': 'src/exports/blocks-rsc.ts',
'/client': 'src/exports/client.ts',
'/env': 'src/exports/env.ts',
'/next/middleware': 'src/exports/next-middleware.ts',
'/rsc': 'src/exports/rsc.ts',
'/seed': 'src/exports/seed.ts',
'/server': 'src/exports/server.ts',
'/templates': 'src/exports/templates.ts',
}
/** Names an entry file exports — `export { a, b as c } from …`, `export type { … }`. */