Block library: item headings follow the section; the leading block's first image is the LCP image

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]>
This commit is contained in:
Radosław Smoliński
2026-10-29 16:38:04 +01:00
co-authored by Claude Opus 5.5
parent dd11bc8146
commit 6f56ef4205
27 changed files with 206 additions and 53 deletions
+6 -4
View File
@@ -4,6 +4,7 @@ import type { BlockComponentMap, BlockData } from '../blocks/types.js'
import type { ResolvedRoute } from '../content/index.js'
import type { ContentHelpers, PageJsonLdOptions } from './createContentHelpers.js'
import { blockPosition } from '../blocks/position.js'
import { RenderBlocks } from '../blocks/RenderBlocks.js'
import { constructionNoticeHref, isPathVisibleIn } from '../construction/logic.js'
import { LocaleView } from '../pages/LocaleView.js'
@@ -19,8 +20,9 @@ type BlockPropsContext = { doc: Record<string, unknown>; locale: string }
export type PageRouteOptions = {
/**
* Props for every block on top of `locale` and `isFirst` (true for the first
* section — its heading is the page's only h1), computed once per page —
* Props for every block on top of `locale`, `isFirst` (true for the first
* section — its heading is the page's only h1) and `firstImage` (no block before it
* shows an image — its first image is the LCP image, blockPosition), computed once per page —
* e.g. `{ formTexts, sendForm }` for form blocks.
*/
blockProps?: (ctx: BlockPropsContext) => Promise<Record<string, unknown>> | Record<string, unknown>
@@ -138,7 +140,7 @@ export function createPageRoute(helpers: Helpers, options: PageRouteOptions) {
<RenderBlocks
blocks={doc[layoutField] as BlockData[] | undefined}
components={blocks}
enhanceProps={({ index }) => ({ locale, ...extra, isFirst: index === 0 })}
enhanceProps={(at) => ({ locale, ...extra, ...blockPosition(at) })}
/>
)
const custom = render ? await render({ blocks: rendered, locale, route, segments }) : undefined
@@ -190,7 +192,7 @@ async function notFoundView(helpers: NotFoundHelpers, options: NotFoundViewOptio
const layout = doc?.[layoutField] as BlockData[] | undefined
if (!doc || !layout?.length) {return typeof fallback === 'function' ? fallback(locale) : fallback}
const extra = blockProps ? await blockProps({ doc, locale }) : {}
return <RenderBlocks blocks={layout} components={blocks} enhanceProps={({ index }) => ({ locale, ...extra, isFirst: index === 0 })} />
return <RenderBlocks blocks={layout} components={blocks} enhanceProps={(at) => ({ locale, ...extra, ...blockPosition(at) })} />
}
/**