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
+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' } } }] } },