Found by ipal-doctor live-seo on the reference archive pages (entry list under a
page header without a picture): cards jumped h1 → h3, and the first card image
was lazy.
- itemHeadingLevel: items one below the section heading (h3 under h2, h2 under the
page h1, h2 when the block shows no heading); createBlockRegistry({ itemHeadings })
fixes a level per block. featureGrid, entryList, pricing, steps, team.
- blockPosition / blockHasImage (root): createPageRoute and the 404 view pass
firstImage next to isFirst; leadsWithImage marks the first image of the leading
block eager + fetchPriority high (hero, textMedia, featureGrid, gallery, team,
entryList); priorityImage: false turns it off.
- reference/ipal-doctor.json: the two live-seo silences removed; reference skills
and docs/agent/reference-site/INDEX.md refreshed.
- bin/ipal-blocks.mjs executable like the other bins.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
84 lines
4.3 KiB
TypeScript
84 lines
4.3 KiB
TypeScript
import type { ComponentType, ReactNode } from 'react'
|
|
|
|
import type { ArchiveEntries } from '../content/getArchiveEntries.js'
|
|
import type { BuilderFormClassNames } from '../forms/BuilderForm.js'
|
|
import type { SendFormAction } from '../forms/RenderForm.js'
|
|
import type { ResolveLinkHrefOptions } from '../links/resolveLinkHref.js'
|
|
import type { BlockTexts } from './texts.js'
|
|
import type { LibraryBlockSlug } from './types.js'
|
|
import type { LinkComponent } from './ui/Anchor.js'
|
|
import type { CardProps } from './ui/Card.js'
|
|
import type { CMSLinkProps, ResolveLink } from './ui/CMSLink.js'
|
|
import type { ContainerProps } from './ui/Container.js'
|
|
import type { PartClasses } from './ui/cx.js'
|
|
import type { ImageComponent, MediaProps } from './ui/Media.js'
|
|
import type { SectionProps } from './ui/Section.js'
|
|
import type { SectionHeaderProps } from './ui/SectionHeader.js'
|
|
|
|
/** The UI primitives every library block is built from. Swap any of them with createBlockRegistry({ ui }). */
|
|
export type BlockUi = {
|
|
buttonClass: (appearance?: null | string) => string
|
|
Card: ComponentType<CardProps>
|
|
CMSLink: (props: CMSLinkProps) => Promise<ReactNode> | ReactNode
|
|
Container: ComponentType<ContainerProps>
|
|
Media: ComponentType<MediaProps>
|
|
Section: ComponentType<SectionProps>
|
|
SectionHeader: ComponentType<SectionHeaderProps>
|
|
}
|
|
|
|
/** One line of contact details beside the contact form. */
|
|
export type ContactDetail = { href?: string; label: string; value: string }
|
|
|
|
/** One testimonial as the component renders it. */
|
|
export type TestimonialItem = { heading: string; id?: null | string; media?: unknown; quote: string; rating?: null | number; text?: null | string }
|
|
|
|
/** One entry card of the entry list. */
|
|
export type EntryCard = { date?: null | string; media?: unknown; text?: null | string; title: string }
|
|
|
|
/** What the blocks may need from lib/content (createContentHelpers). Only resolveLink is required. */
|
|
export type BlockContent = {
|
|
getEntries?: (collection: string, locale: string, page: number, perPage: number) => Promise<ArchiveEntries>
|
|
getFormTexts?: (locale: string) => Promise<unknown>
|
|
getLinkOptions?: (locale: string) => Promise<ResolveLinkHrefOptions>
|
|
resolveLink: ResolveLink
|
|
}
|
|
|
|
/** Everything a block gets from the registry besides its data. */
|
|
export type BlockContext = {
|
|
/** Contact details beside the form (from the project's company global). */
|
|
contactDetails?: (locale: string) => ContactDetail[] | Promise<ContactDetail[]>
|
|
content: BlockContent
|
|
/** Turns a collection document into an entry card. Default: title, excerpt/description, media/image, publishedAt. */
|
|
entryCard?: (doc: Record<string, unknown>, collection: string) => EntryCard | null
|
|
formClassNames?: BuilderFormClassNames
|
|
/** The project's icon components by name (the names of buildFeatureGridBlock({ icons })). */
|
|
icons?: Record<string, ComponentType<{ 'aria-hidden'?: boolean; className?: string }>>
|
|
/** next/image — optimized images with blur-up. Without it: a plain <img>. */
|
|
Image?: ImageComponent
|
|
/** Heading level of a block's items (cards, plans, steps), per block. Default: one below the section heading (itemHeadingLevel). */
|
|
itemHeadings?: Partial<Record<LibraryBlockSlug, 'h2' | 'h3' | 'h4'>>
|
|
/** Lightbox triggers on gallery images. Default true (needs <SiteProviders lightbox>). */
|
|
lightbox: boolean
|
|
/** next/link — client-side navigation for internal links. Without it: a plain <a>. */
|
|
Link?: LinkComponent
|
|
/** Turns a testimonials-collection document into an item. Default: quote, heading/author/name, text/role, media, rating. */
|
|
mapTestimonial?: (doc: Record<string, unknown>) => null | TestimonialItem
|
|
/** The first image of the leading block loads eagerly with high priority (LCP). Default true; `false` = never. */
|
|
priorityImage?: boolean
|
|
richText?: { className?: string }
|
|
/** The project's sendForm server action (createSubmitAction) — the contact block needs it. */
|
|
sendForm?: SendFormAction
|
|
texts?: Partial<Record<string, Partial<BlockTexts>>>
|
|
}
|
|
|
|
/** Props of every library block component: its data + locale + what the registry binds. */
|
|
export type LibraryBlockProps<D> = {
|
|
classNames?: PartClasses
|
|
ctx: BlockContext
|
|
/** No block before this one shows an image (createPageRoute, blockPosition). */
|
|
firstImage?: boolean
|
|
isFirst?: boolean
|
|
locale: string
|
|
ui: BlockUi
|
|
} & D
|