4.4 KiB
4.4 KiB
name, description
| name | description |
|---|---|
| ipal-block | 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. |
ipal-block
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.
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)
(and tell the user). Do not write your own versions.
1. Plan (write 3–5 points, then go straight to code — AGENT.md §0a)
- block slug (camelCase), folder name (PascalCase),
- the field list, only from the AGENT.md §6.5 vocabulary:
header,media,links,link,items(+heading,text,content),settings, - whether
itemsget a<Name>Card.tsxsubcomponent, - whether interaction is needed → a separate
'use client'file (try<details>/<dialog>first), - whether the section is a variant of an existing block (then a
variant: selectfield, not a new block).
2. Code
File patterns (Hero, FeatureGrid + FeatureCard): resources/section-code.md.
src/blocks/<Name>/config.ts—interfaceName: '<Name>Block', fields from the plan, alwaysbuildSectionSettingsField(). CTA =buildLinksField(), nevercta*/button*fields. A downloadable file = a link of typefile. Panel per AGENT.md §6.5a:- repeatable → an array with
labels: { singular, plural }+admin: { initCollapsed: true, components: rowLabel('heading', '<Singular>') },maxRowsfrom the design; - no numbered fields (
cta1,feature2Title,image3) and no spare fields "just in case"; - EN labels of 1–3 words,
descriptiononly when needed (≤ 80 chars, what/where, an example); - dependent fields use
admin.condition, a variant = avariantselect, > ~10 fields →tabs; - block:
labels: { singular: 'Feature grid', plural: 'Feature grids' }.
- repeatable → an array with
src/blocks/<Name>/Component.tsx— named export, type from@/payload-types(<Name>Block & { locale: string }), structure:<Section settings>→<SectionHeader header>→ content with<Media>,<CMSLink>,items.map(<Card/>). No text,href,<img>, hex colors or inline SVG.- Subcomponents go in the same folder; shared by 2+ sections →
src/components/ui/. An image the visitor can enlarge (gallery, card, product, certificate) → wrap the<Media>in<LightboxTrigger group={-${id}} image={lightboxImage(item.image, { size: 'hero' })}>(@intecion/ipal-kit/client; skip the trigger whenlightboxImagereturnsnull). NouseStatedialog, noglightbox— lightbox.md. - Add
config.tstolayoutinsrc/collections/Pages.ts, and the component tosrc/blocks/registry.ts(key = slug). pnpm generate:types.
3. Check
Component.tsx≤ ~80 lines of JSX.- Empty block test in the panel: ≤ 6 items at the start, every label and description
readable in English and Polish (switch the admin language in Account),
"+ Add Button / Add Feature", collapsed rows showing their content, every field shows something.
First
rowLabelin the project →pnpm payload generate:importmap. - Run the ipal-audit skill (
--quick), fix every[ERROR]. - Refactoring an existing block with renamed fields: migrate the data first (old field → new), and only then remove the old fields (AGENT.md §6.7).