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:
co-authored by
Claude Opus 5.5
parent
dd11bc8146
commit
6f56ef4205
@@ -4,6 +4,7 @@ import type { BaseBlockData } from '../../data.js'
|
||||
import { MEDIA_SIZES } from '../../../media/mediaProps.js'
|
||||
import { Buttons, headingId } from '../../ui/Buttons.js'
|
||||
import { cx, parts } from '../../ui/cx.js'
|
||||
import { itemHeadingLevel, leadsWithImage } from '../../ui/levels.js'
|
||||
import { TitleLink } from '../../ui/TitleLink.js'
|
||||
|
||||
export type EntryListBlockData = {
|
||||
@@ -53,6 +54,8 @@ export async function EntryListBlock(props: LibraryBlockProps<EntryListBlockData
|
||||
const c = parts(ENTRY_LIST_PARTS, classNames)
|
||||
const id = headingId(props)
|
||||
const dates = new Intl.DateTimeFormat(locale, { dateStyle: 'long' })
|
||||
const H = itemHeadingLevel('entryList', props)
|
||||
const lead = leadsWithImage(props)
|
||||
return (
|
||||
<ui.Section block={props.blockType} labelledBy={id} settings={settings}>
|
||||
<ui.SectionHeader as={isFirst ? 'h1' : 'h2'} header={header} id={id} />
|
||||
@@ -60,14 +63,14 @@ export async function EntryListBlock(props: LibraryBlockProps<EntryListBlockData
|
||||
{rows.map(({ card, collection: from, doc }, i) => (
|
||||
<li className="flex" key={typeof doc.id === 'string' || typeof doc.id === 'number' ? doc.id : i}>
|
||||
<ui.Card className={cx('w-full', c.card)} interactive>
|
||||
{variant === 'list' ? null : <ui.Media className={c.media} resource={card.media as never} sizes={MEDIA_SIZES.third} />}
|
||||
{variant === 'list' ? null : <ui.Media className={c.media} priority={lead && i === 0} resource={card.media as never} sizes={MEDIA_SIZES.third} />}
|
||||
<div className="flex flex-col gap-2 p-6 pt-0 first:pt-6">
|
||||
{card.date ? <time className={c.date} dateTime={card.date}>{dates.format(new Date(card.date))}</time> : null}
|
||||
<h3 className={c.title}>
|
||||
<H className={c.title}>
|
||||
<TitleLink link={{ type: 'internal', page: { relationTo: from, value: doc } }} Link={ctx.Link} locale={locale} resolve={ctx.content.resolveLink}>
|
||||
{card.title}
|
||||
</TitleLink>
|
||||
</h3>
|
||||
</H>
|
||||
{card.text ? <p className={c.text}>{card.text}</p> : null}
|
||||
</div>
|
||||
</ui.Card>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import type { BlockContext, BlockUi, LibraryBlockProps } from '../../context.js'
|
||||
import type { BaseBlockData, LinkData, MediaValue } from '../../data.js'
|
||||
import type { ItemHeadingLevel } from '../../ui/levels.js'
|
||||
|
||||
import { MEDIA_SIZES } from '../../../media/mediaProps.js'
|
||||
import { Buttons, GRID_COLUMNS, headingId } from '../../ui/Buttons.js'
|
||||
import { cx, parts } from '../../ui/cx.js'
|
||||
import { itemHeadingLevel, leadsWithImage } from '../../ui/levels.js'
|
||||
import { TitleLink } from '../../ui/TitleLink.js'
|
||||
|
||||
export type FeatureItem = { heading: string; icon?: null | string; id?: null | string; link?: LinkData; media?: MediaValue; text?: null | string }
|
||||
@@ -28,13 +30,15 @@ export function FeatureGridBlock(props: LibraryBlockProps<FeatureGridBlockData>)
|
||||
const id = headingId(props)
|
||||
const v = variant ?? 'cards'
|
||||
const List = v === 'numbered' ? 'ol' : 'ul'
|
||||
const H = itemHeadingLevel('featureGrid', props)
|
||||
const lead = leadsWithImage(props)
|
||||
return (
|
||||
<ui.Section block={props.blockType} labelledBy={id} settings={settings}>
|
||||
<ui.SectionHeader as={isFirst ? 'h1' : 'h2'} header={header} id={id} />
|
||||
<List className={cx(v === 'list' ? c.list : c.grid, GRID_COLUMNS[columns ?? 'three'])}>
|
||||
{items.map((item, i) => (
|
||||
<li className="flex" key={item.id ?? i}>
|
||||
<FeatureCard c={c} ctx={ctx} index={v === 'numbered' ? i + 1 : undefined} item={item} locale={locale} plain={v === 'list'} ui={ui} />
|
||||
<FeatureCard as={H} c={c} ctx={ctx} index={v === 'numbered' ? i + 1 : undefined} item={item} locale={locale} plain={v === 'list'} priority={lead && i === 0} ui={ui} />
|
||||
</li>
|
||||
))}
|
||||
</List>
|
||||
@@ -43,7 +47,7 @@ export function FeatureGridBlock(props: LibraryBlockProps<FeatureGridBlockData>)
|
||||
)
|
||||
}
|
||||
|
||||
function FeatureCard({ c, ctx, index, item, locale, plain, ui }: { c: typeof FEATURE_GRID_PARTS; ctx: BlockContext; index?: number; item: FeatureItem; locale: string; plain: boolean; ui: BlockUi }) {
|
||||
function FeatureCard({ as: H, c, ctx, index, item, locale, plain, priority, ui }: { as: ItemHeadingLevel; c: typeof FEATURE_GRID_PARTS; ctx: BlockContext; index?: number; item: FeatureItem; locale: string; plain: boolean; priority: boolean; ui: BlockUi }) {
|
||||
const Icon = item.icon ? ctx.icons?.[item.icon] : undefined
|
||||
const heading = item.link ? (
|
||||
<TitleLink link={item.link} Link={ctx.Link} locale={locale} resolve={ctx.content.resolveLink}>
|
||||
@@ -56,8 +60,8 @@ function FeatureCard({ c, ctx, index, item, locale, plain, ui }: { c: typeof FEA
|
||||
<>
|
||||
{index ? <span aria-hidden className={c.number}>{String(index).padStart(2, '0')}</span> : null}
|
||||
{Icon ? <Icon aria-hidden className={c.icon} /> : null}
|
||||
<ui.Media className={c.media} resource={item.media} sizes={MEDIA_SIZES.third} />
|
||||
<h3 className={c.heading}>{heading}</h3>
|
||||
<ui.Media className={c.media} priority={priority} resource={item.media} sizes={MEDIA_SIZES.third} />
|
||||
<H className={c.heading}>{heading}</H>
|
||||
{item.text ? <p className={c.text}>{item.text}</p> : null}
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ import { LightboxTrigger } from '../../../lightbox/LightboxProvider.js'
|
||||
import { MEDIA_SIZES } from '../../../media/mediaProps.js'
|
||||
import { Buttons, GRID_COLUMNS, headingId } from '../../ui/Buttons.js'
|
||||
import { cx, parts } from '../../ui/cx.js'
|
||||
import { leadsWithImage } from '../../ui/levels.js'
|
||||
|
||||
export type GalleryItem = { caption?: null | string; id?: null | string; media?: MediaValue }
|
||||
export type GalleryBlockData = { columns?: null | string; items?: GalleryItem[] | null } & BaseBlockData
|
||||
@@ -28,13 +29,14 @@ export function GalleryBlock(props: LibraryBlockProps<GalleryBlockData>) {
|
||||
const id = headingId(props)
|
||||
const group = `gallery-${props.id ?? 'block'}`
|
||||
const masonry = variant === 'masonry'
|
||||
const lead = leadsWithImage(props)
|
||||
const sizes = columns === 'two' ? MEDIA_SIZES.half : columns === 'four' ? MEDIA_SIZES.quarter : MEDIA_SIZES.third
|
||||
return (
|
||||
<ui.Section block={props.blockType} labelledBy={id} settings={settings} width="wide">
|
||||
<ui.SectionHeader as={isFirst ? 'h1' : 'h2'} header={header} id={id} />
|
||||
<ul className={masonry ? c.masonry : cx(c.grid, GRID_COLUMNS[columns ?? 'three'])}>
|
||||
{shown.map((item, i) => {
|
||||
const image = <ui.Media className={c.image} resource={item.media} sizes={sizes} />
|
||||
const image = <ui.Media className={c.image} priority={lead && i === 0} resource={item.media} sizes={sizes} />
|
||||
const large = ctx.lightbox ? lightboxImage(item.media, item.caption ? { caption: item.caption } : {}) : null
|
||||
return (
|
||||
<li key={item.id ?? i}>
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { BaseBlockData, MediaValue } from '../../data.js'
|
||||
import { MEDIA_SIZES } from '../../../media/mediaProps.js'
|
||||
import { Buttons, headingId } from '../../ui/Buttons.js'
|
||||
import { cx, parts } from '../../ui/cx.js'
|
||||
import { leadsWithImage } from '../../ui/levels.js'
|
||||
|
||||
export type HeroBlockData = { media?: MediaValue; poster?: MediaValue } & BaseBlockData
|
||||
|
||||
@@ -30,7 +31,7 @@ export function HeroBlock(props: LibraryBlockProps<HeroBlockData>) {
|
||||
if (v === 'background') {
|
||||
return (
|
||||
<ui.Section block={props.blockType} className={c.background} labelledBy={id} settings={{ ...settings, background: 'inverted' }}>
|
||||
<ui.Media alt="" className={c.backgroundMedia} poster={poster} priority={isFirst} resource={media} sizes={MEDIA_SIZES.full} videoMode="background" />
|
||||
<ui.Media alt="" className={c.backgroundMedia} poster={poster} priority={leadsWithImage({ ctx: props.ctx, firstImage: props.firstImage, isFirst })} resource={media} sizes={MEDIA_SIZES.full} videoMode="background" />
|
||||
<span aria-hidden className={c.backgroundOverlay} />
|
||||
<div className={c.page}>
|
||||
{title}
|
||||
@@ -47,7 +48,7 @@ export function HeroBlock(props: LibraryBlockProps<HeroBlockData>) {
|
||||
{title}
|
||||
{buttons}
|
||||
</div>
|
||||
{withMedia ? <ui.Media className={c.media} poster={poster} priority={isFirst} resource={media} sizes={MEDIA_SIZES.half} /> : null}
|
||||
{withMedia ? <ui.Media className={c.media} poster={poster} priority={leadsWithImage({ ctx: props.ctx, firstImage: props.firstImage, isFirst })} resource={media} sizes={MEDIA_SIZES.half} /> : null}
|
||||
</div>
|
||||
</ui.Section>
|
||||
)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import type { BlockUi, LibraryBlockProps } from '../../context.js'
|
||||
import type { BaseBlockData, LinkData } from '../../data.js'
|
||||
import type { ItemHeadingLevel } from '../../ui/levels.js'
|
||||
|
||||
import { headingId } from '../../ui/Buttons.js'
|
||||
import { cx, parts } from '../../ui/cx.js'
|
||||
import { itemHeadingLevel } from '../../ui/levels.js'
|
||||
|
||||
export type PricingPlan = {
|
||||
features?: { id?: null | string; text: string }[] | null
|
||||
@@ -35,13 +37,14 @@ export function PricingBlock(props: LibraryBlockProps<PricingBlockData>) {
|
||||
if (!items?.length) {return null}
|
||||
const c = parts(PRICING_PARTS, classNames)
|
||||
const id = headingId(props)
|
||||
const H = itemHeadingLevel('pricing', props)
|
||||
return (
|
||||
<ui.Section block={props.blockType} labelledBy={id} settings={settings}>
|
||||
<ui.SectionHeader as={isFirst ? 'h1' : 'h2'} header={header} id={id} />
|
||||
<ul className={c.grid}>
|
||||
{items.map((plan, i) => (
|
||||
<li className="flex" key={plan.id ?? i}>
|
||||
<Plan c={c} highlightLabel={highlightLabel} locale={locale} plan={plan} ui={ui} />
|
||||
<Plan as={H} c={c} highlightLabel={highlightLabel} locale={locale} plan={plan} ui={ui} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
@@ -50,11 +53,11 @@ export function PricingBlock(props: LibraryBlockProps<PricingBlockData>) {
|
||||
)
|
||||
}
|
||||
|
||||
function Plan({ c, highlightLabel, locale, plan, ui }: { c: typeof PRICING_PARTS; highlightLabel?: null | string; locale: string; plan: PricingPlan; ui: BlockUi }) {
|
||||
function Plan({ as: H, c, highlightLabel, locale, plan, ui }: { as: ItemHeadingLevel; c: typeof PRICING_PARTS; highlightLabel?: null | string; locale: string; plan: PricingPlan; ui: BlockUi }) {
|
||||
return (
|
||||
<ui.Card className={cx('w-full', c.plan, plan.highlighted && c.highlighted)}>
|
||||
{plan.highlighted && highlightLabel ? <p className={c.badge}>{highlightLabel}</p> : null}
|
||||
<h3 className={c.name}>{plan.heading}</h3>
|
||||
<H className={c.name}>{plan.heading}</H>
|
||||
<p>
|
||||
<span className={c.price}>{plan.price}</span> {plan.period ? <span className={c.period}>{plan.period}</span> : null}
|
||||
</p>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { MEDIA_SIZES } from '../../../media/mediaProps.js'
|
||||
import { blockTexts, fillText } from '../../texts.js'
|
||||
import { Buttons, headingId } from '../../ui/Buttons.js'
|
||||
import { cx, parts } from '../../ui/cx.js'
|
||||
import { itemHeadingLevel } from '../../ui/levels.js'
|
||||
|
||||
export type StepItem = { heading: string; id?: null | string; media?: MediaValue; text?: null | string }
|
||||
export type StepsBlockData = { items?: null | StepItem[] } & BaseBlockData
|
||||
@@ -26,6 +27,7 @@ export function StepsBlock(props: LibraryBlockProps<StepsBlockData>) {
|
||||
const c = parts(STEPS_PARTS, classNames)
|
||||
const texts = blockTexts(locale, ctx.texts)
|
||||
const id = headingId(props)
|
||||
const H = itemHeadingLevel('steps', props)
|
||||
return (
|
||||
<ui.Section block={props.blockType} labelledBy={id} settings={settings}>
|
||||
<ui.SectionHeader as={isFirst ? 'h1' : 'h2'} header={header} id={id} />
|
||||
@@ -34,10 +36,10 @@ export function StepsBlock(props: LibraryBlockProps<StepsBlockData>) {
|
||||
<li className={c.item} key={s.id ?? i}>
|
||||
<span aria-hidden className={cx(c.number, 'relative')}>{i + 1}</span>
|
||||
<div>
|
||||
<h3 className={c.heading}>
|
||||
<H className={c.heading}>
|
||||
<span className="sr-only">{fillText(texts.step, i + 1)}: </span>
|
||||
{s.heading}
|
||||
</h3>
|
||||
</H>
|
||||
{s.text ? <p className={c.text}>{s.text}</p> : null}
|
||||
<ui.Media className={c.media} resource={s.media} sizes={MEDIA_SIZES.half} />
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { BaseBlockData, LinkData, MediaValue } from '../../data.js'
|
||||
import { MEDIA_SIZES } from '../../../media/mediaProps.js'
|
||||
import { Buttons, headingId } from '../../ui/Buttons.js'
|
||||
import { cx, parts } from '../../ui/cx.js'
|
||||
import { itemHeadingLevel, leadsWithImage } from '../../ui/levels.js'
|
||||
import { TitleLink } from '../../ui/TitleLink.js'
|
||||
|
||||
export type TeamMember = { bio?: null | string; heading: string; id?: null | string; link?: LinkData; media?: MediaValue; text?: null | string }
|
||||
@@ -26,17 +27,19 @@ export function TeamBlock(props: LibraryBlockProps<TeamBlockData>) {
|
||||
const c = parts(TEAM_PARTS, classNames)
|
||||
const id = headingId(props)
|
||||
const list = variant === 'list'
|
||||
const H = itemHeadingLevel('team', props)
|
||||
const lead = leadsWithImage(props)
|
||||
return (
|
||||
<ui.Section block={props.blockType} labelledBy={id} settings={settings}>
|
||||
<ui.SectionHeader as={isFirst ? 'h1' : 'h2'} header={header} id={id} />
|
||||
<ul className={list ? c.list : c.grid}>
|
||||
{items.map((m, i) => (
|
||||
<li className={cx('flex flex-col gap-3', list && c.listItem)} key={m.id ?? i}>
|
||||
<ui.Media className={c.photo} resource={m.media} sizes={list ? '10rem' : MEDIA_SIZES.third} />
|
||||
<ui.Media className={c.photo} priority={lead && i === 0} resource={m.media} sizes={list ? '10rem' : MEDIA_SIZES.third} />
|
||||
<div className="flex flex-col gap-1">
|
||||
<h3 className={c.name}><TitleLink link={m.link} Link={ctx.Link} locale={locale} resolve={ctx.content.resolveLink} stretch={false}>
|
||||
<H className={c.name}><TitleLink link={m.link} Link={ctx.Link} locale={locale} resolve={ctx.content.resolveLink} stretch={false}>
|
||||
{m.heading}
|
||||
</TitleLink></h3>
|
||||
</TitleLink></H>
|
||||
{m.text ? <p className={c.role}>{m.text}</p> : null}
|
||||
{m.bio ? <p className={c.bio}>{m.bio}</p> : null}
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { MEDIA_SIZES } from '../../../media/mediaProps.js'
|
||||
import { RenderRichText } from '../../../richtext/RenderRichText.js'
|
||||
import { Buttons, headingId } from '../../ui/Buttons.js'
|
||||
import { cx, parts } from '../../ui/cx.js'
|
||||
import { leadsWithImage } from '../../ui/levels.js'
|
||||
|
||||
export type TextMediaBlockData = { content?: RichTextData; media?: MediaValue } & BaseBlockData
|
||||
|
||||
@@ -30,7 +31,7 @@ export function TextMediaBlock(props: LibraryBlockProps<TextMediaBlockData>) {
|
||||
</div>
|
||||
{media ? (
|
||||
<div className={variant === 'mediaLeft' ? c.mediaLeft : undefined}>
|
||||
<ui.Media className={c.media} priority={isFirst} resource={media} sizes={MEDIA_SIZES.half} />
|
||||
<ui.Media className={c.media} priority={leadsWithImage(props)} resource={media} sizes={MEDIA_SIZES.half} />
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user