# Section code — ready files for the project > Resources of the **iapl-block** skill. The rules (why, and what not to do) are in > `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md` §6 — this file is only the code > to create in the project **1:1**. Links (`buildLinkField`, `buildLinksField`, > `resolveLink`), section fields (`buildSectionHeaderField`, `buildSectionSettingsField`) and the menu > (`resolveNav`) come from the plugin — do not copy them. ## Layer 1 — shared fields **Link / CTA — from the plugin, do not copy the code** (`docs/links.md`): ```ts import { buildLinkField, buildLinksField } from '@intecion/ipal-kit' buildLinksField() // 0–2 section buttons → `links` field buildLinksField({ maxRows: 3, appearances: ['primary', 'secondary'] }) buildLinkField() // single link → `link` field buildLinkField({ disableLabel: true, appearances: false }) // whole card clickable ``` One link shape: type (`internal` page / `external` URL, mailto, tel, #anchor / `file` upload), `label` (localized), `newTab`, `appearance`. `payload-types.ts` gets a `CmsLink` type (without style: `CmsLinkPlain`, without label: `CmsLinkNoLabel`; all fit `CmsLink`; custom name: `interfaceName`). Options: `relationTo` (default `'pages'`), `uploadTo` (default `'media'`), `required`. **Files and images:** `{ name: 'media', type: 'upload', relationTo: 'media' }`. The `media` collection accepts PDF (`upload.mimeTypes: ['image/*', 'application/pdf', 'video/mp4']`), has `alt` (required, localized) and `normalizeFilenameHook`. "Download price list (PDF)" is a **link of type `file`**, not a separate `pdf`/`pdfUrl` field. **Section header and settings — from the plugin, do not copy the code** (`docs/blocks.md`): ```ts import { buildSectionHeaderField, buildSectionSettingsField } from '@intecion/ipal-kit' buildSectionHeaderField() // `header` group: eyebrow, heading, intro (localized) — type SectionHeaderData buildSectionSettingsField() // sidebar `settings`: anchor, background (default/muted/inverted) — type SectionSettings buildSectionSettingsField({ backgrounds: [{ label: 'Default', value: 'default' }, { label: 'Brand', value: 'brand' }] }) ``` Every section has `buildSectionSettingsField()` — no `bgColor`, `darkMode`, `sectionId` in individual blocks. Field labels in English (the panel is EN). ## Layer 2 — UI primitives `src/components/ui/CMSLink.tsx` — **every** link/button from the panel: ```tsx import Link from 'next/link' import type { ReactNode } from 'react' import type { CmsLink } from '@/payload-types' import { resolveLink } from '@/lib/content' import { buttonClass } from './Button' import type { LinkAppearance } from '@intecion/ipal-kit' type Props = { link: CmsLink | null | undefined locale: string className?: string /** For wrapping links (cards): content instead of link.label. */ children?: ReactNode } // href, new tab, rel, internal/external — from the plugin. Here: the element and the classes. export async function CMSLink({ link, locale, className, children }: Props) { const l = await resolveLink(link, locale) const content = children ?? l?.label if (!l || !content) return null const cls = [l.appearance ? buttonClass(l.appearance as LinkAppearance) : '', className].filter(Boolean).join(' ') || undefined return l.internal ? {content} : {content} } ``` `src/components/ui/Button.tsx` — variants as a map, not a ternary: ```ts import type { LinkAppearance } from '@intecion/ipal-kit' // design-token utilities only (design-tokens.md) — a brand changes src/design/tokens.ts, never this file const BASE = 'inline-flex items-center gap-2 rounded-control px-5 py-2.5 font-medium transition-colors duration-fast ease-out' const VARIANTS: Record = { primary: `${BASE} bg-primary text-on-primary hover:bg-primary-hover`, secondary: `${BASE} bg-secondary text-on-secondary hover:bg-secondary-hover`, link: 'text-link underline-offset-4 hover:text-link-hover hover:underline', } export function buttonClass(appearance: LinkAppearance): string { return VARIANTS[appearance] } ``` `src/components/ui/Media.tsx` — **every** image/video from the panel. The plugin handles speed (`mediaImageProps`, `videoProps`), the look stays here: ```tsx import Image from 'next/image' import { mediaImageProps, MEDIA_SIZES, videoProps, type VideoMode } from '@intecion/ipal-kit' import type { Media as MediaDoc } from '@/payload-types' type Props = { resource: MediaDoc | string | number | null | undefined /** Width ON SCREEN — MEDIA_SIZES.half / .third / a custom string. Without it the full width downloads. */ sizes?: string /** Only the first visible image of the page (hero, LCP). The rest load lazily. */ priority?: boolean className?: string /** Video: 'background' (muted loop) or 'player' (controls, loads on click). */ videoMode?: VideoMode /** Video poster — upload from the panel. */ poster?: MediaDoc | string | number | null } export function Media({ resource, sizes = MEDIA_SIZES.full, priority = false, className, videoMode = 'player', poster }: Props) { const video = videoProps(resource, { mode: videoMode, poster }) if (video) return