- docs, AGENT.md, the 16 skills, PROGRAMISTA and README use the preferred names (scripted, same list of forms); past CHANGELOG entries and the proposals in docs/dev are not rewritten - AGENT.md: 'Names: IAPL and ipal-kit' — old name, new name, state in 1.x; what is not renamed; storageNames - iapl-upgrade '→ 1.17.0', PROGRAMISTA §6 item 72, CHANGELOG 1.17.0 (draft): nothing required - env.md, doctor.md (legacy-names, storage-names), stats.md, security.md, project-starter.md, iapl-reference, iapl-setup - skill scripts read ipal-audit-skip and IPAL_IP_HEADER too; audit rule ids stay what they were - reference site: iapl(), iapl-doctor.json, iapl-* skills, storageNames: 'iapl'; INDEX.md regenerated Co-Authored-By: Claude Fable 5.2 <[email protected]>
5.4 KiB
blocks
Ready sections: the plugin ships fifteen standard blocks (hero, FAQ, gallery, contact…) and page templates — 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
(schema + components) in your project.
Config
No options in payload.config — you define blocks in your collections
(a blocks type field). The plugin provides only the rendering engine.
⚠️ Do NOT write your own block renderer (switch)
The block renderer is RenderBlocks from the plugin — NEVER your own switch/if.
Common mistake: the project writes its own BlockRenderer with switch (block.blockType)
and 20 cases. That breaks A0 — the plugin has the engine, the project provides only the
component MAP.
// WRONG — own switch in the project (verbose, no enhanceProps, grows linearly)
switch (block.blockType) {
case 'hero': return <Hero {...block} />
case 'faq': return <FAQ {...block} />
// ...20 cases
}
// RIGHT — map + RenderBlocks (engine from the plugin)
const registry = { hero: Hero, faq: FAQ, /* ... */ }
<RenderBlocks blocks={page.layout} components={registry} />
Why RenderBlocks, not a switch: enhanceProps (nav anchors, etc.), guards, nesting support, consistency across projects. A switch has none of this and grows with every block. The map is flat and declarative.
Front — RenderBlocks
Import from @intecion/ipal-kit/rsc (it is a server component):
import { RenderBlocks } from '@intecion/ipal-kit/rsc'
// Your registry: blockType → component (the components are yours)
import { Hero } from '@/blocks/Hero'
import { FormBlock } from '@/blocks/FormBlock'
const registry = { hero: Hero, formBlock: FormBlock }
export default async function Page() {
const page = await payload.findByID({ collection: 'pages', id })
return <RenderBlocks blocks={page.layout} components={registry} />
}
- unknown
blockType→ skipped (null), does not crash blocksempty /null→null- nested blocks: the parent component renders
<RenderBlocks>itself and imports the registry itself — the engine does NOT pass the map in props (functions do not cross the server→client boundary in RSC)
enhanceProps — per-block logic without the plugin knowing
When a block needs data from other blocks (e.g. a nav collecting anchors
from sections), pass enhanceProps. The plugin calls it without knowing your blocks:
// arguments: { block, allBlocks, index }
const enhanceProps = ({ block, allBlocks }) => {
if (block.blockType !== 'sectionNav') return {}
const sections = allBlocks
.filter((b) => b.blockType === 'anchoredSection')
.map((b) => ({ anchor: b.anchor, label: b.navLabel }))
return { _sections: sections }
}
<RenderBlocks blocks={page.layout} components={registry} enhanceProps={enhanceProps} />
Shared section fields — buildSectionHeaderField, buildSectionSettingsField
import { buildLinksField, buildSectionHeaderField, buildSectionSettingsField } from '@intecion/ipal-kit'
fields: [
buildSectionHeaderField(), // `header` group: eyebrow, heading, intro (localized) — type SectionHeaderData
…block fields…,
buildLinksField(),
buildSectionSettingsField(), // `settings` sidebar: anchor, background — type SectionSettings
]
Default: header (interface SectionHeaderData), settings in the sidebar (interface SectionSettings)
with anchor and background (default / muted / inverted, the first value by default).
Everything can be changed: buildSectionSettingsField({ backgrounds: [{ label: 'Brand', value: 'brand' }], anchor: false, fields: [{ name: 'spacing', … }] }), backgrounds: false (no background choice), buildSectionHeaderField({ name, fields, interfaceName }). The project maps the background values to its <Section> classes. The data shape matches the former
src/fields/sectionHeader.ts / sectionSettings.ts from section-code.md — swapping the import needs no migration.
Block component
Each component gets the block data as props (plus whatever enhanceProps returns;
in createPageRoute also locale, isFirst, firstImage and blockProps — frontend.md; blockPosition computes the
two for your own enhanceProps). Spacing/layout are yours — the engine does not wrap
blocks in any markup.
export function Hero(props) {
return <section className="py-16">{/* ... */}</section>
}
Types: BlockComponentMap, BlockData, EnhanceProps, RenderBlocksProps (/rsc),
SectionHeaderFieldOptions, SectionSettingsFieldOptions (root).
Turn off, override, extend
- The module has no options in
iapl()— it adds nothing to the schema; you either useRenderBlocksor not. - The project keeps the component map and the block schemas; add per-block logic through
enhanceProps. buildSectionHeaderField/buildSectionSettingsField:name,fields(extra fields),interfaceName,anchor: false,backgrounds: […] | false.- The engine does not wrap blocks in markup and has no wrapper option — the project component does the wrapping.