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
@@ -41,7 +41,7 @@ const link = (label: string) => ({ type: 'internal' as const, appearance: 'prima
|
||||
const links = [{ id: 'l1', link: link('Contact us') }]
|
||||
|
||||
const content: BlockContent = {
|
||||
getEntries: vi.fn(async () => ({ docs: [{ id: 7, slug: 'first', publishedAt: '2026-10-01T00:00:00.000Z', title: 'First post' }], hasNextPage: false, hasPrevPage: false, page: 1, totalDocs: 1, totalPages: 1 })),
|
||||
getEntries: vi.fn(async () => ({ docs: [{ id: 7, slug: 'first', media: image('Cover'), publishedAt: '2026-10-01T00:00:00.000Z', title: 'First post' }, { id: 8, slug: 'second', media: image('Second'), title: 'Second post' }], hasNextPage: false, hasPrevPage: false, page: 1, totalDocs: 1, totalPages: 1 })),
|
||||
getFormTexts: vi.fn(async () => ({})),
|
||||
getLinkOptions: vi.fn(async () => ({ config: { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'PL' }] }, locale: 'pl' }) as never),
|
||||
resolveLink: (l) => {
|
||||
@@ -251,6 +251,37 @@ describe('block details', () => {
|
||||
expect(await render(block('cta'))).not.toContain('data-nosnippet')
|
||||
})
|
||||
|
||||
test('item headings follow the section: h3 under a section heading, h2 without one (no h1 → h3 jump)', async () => {
|
||||
const under = await render(block('entryList'))
|
||||
expect(under).toMatch(/<h3 class="font-heading text-h4[^"]*"><a /)
|
||||
const bare = await render(block('entryList', SAMPLES.entryList, { header: null }))
|
||||
expect(bare).not.toContain('<h3')
|
||||
expect(bare).toMatch(/<h2 class="font-heading text-h4[^"]*"><a /)
|
||||
// First section with a heading: section h1, items h2.
|
||||
const first = await render(block('featureGrid', SAMPLES.featureGrid, { isFirst: true }))
|
||||
expect(first).toContain('<h1')
|
||||
expect(first).toMatch(/<h2 class="font-heading text-h4/)
|
||||
for (const slug of ['featureGrid', 'pricing', 'steps', 'team']) {
|
||||
expect(await render(block(slug, SAMPLES[slug], { header: null })), slug).not.toContain('<h3')
|
||||
}
|
||||
const fixed = createBlockRegistry(content, { itemHeadings: { entryList: 'h4' } })
|
||||
expect(await render(h(fixed.entryList, { blockType: 'entryList', locale: 'en', ...SAMPLES.entryList }))).toContain('<h4')
|
||||
})
|
||||
|
||||
test('the first image of the block that leads the page loads first (LCP); one per block, can be turned off', async () => {
|
||||
const eager = /loading="eager"/g
|
||||
// An entry list under a page header without a picture: firstImage from createPageRoute.
|
||||
const lead = await render(block('entryList', SAMPLES.entryList, { firstImage: true, header: null }))
|
||||
expect(lead.match(eager)).toHaveLength(1)
|
||||
expect(lead).toContain('fetchPriority="high"')
|
||||
expect(await render(block('entryList'))).not.toMatch(eager)
|
||||
for (const slug of ['featureGrid', 'gallery', 'team', 'textMedia']) {
|
||||
expect((await render(block(slug, SAMPLES[slug], { firstImage: true }))).match(eager), slug).toHaveLength(1)
|
||||
}
|
||||
const off = createBlockRegistry(content, { priorityImage: false })
|
||||
expect(await render(h(off.hero, { blockType: 'hero', isFirst: true, locale: 'en', ...SAMPLES.hero }))).not.toMatch(eager)
|
||||
})
|
||||
|
||||
test('classNames replace one part’s classes', async () => {
|
||||
const map = createBlockRegistry(content, { classNames: { faq: { item: 'my-item' } } })
|
||||
const html = await render(h(map.faq, { blockType: 'faq', locale: 'en', ...SAMPLES.faq }))
|
||||
|
||||
Reference in New Issue
Block a user