- blocksToMarkdown: the library's section header (heading → ##, then intro; eyebrow skipped), intro, quote and bio are content. Pages whose text sat only in a hero (archive pages, quote, 404) auto-filled no meta description and fell back to the site description; /md and llms-full.txt also missed every section heading. - legal() template: the placeholder names its page, so unfilled privacy/terms pages don't share a description. - reference: every demo page has its own meta description (pl/en), posts and case studies use their excerpt; fuller made-up text on services, contact, quote and the archives (all pages >= 150 words); no seeding of allowThemeToggle (its default, fillGlobal rewrote it on every run). The two content silences are gone. ipal-doctor --strict --offline --deep --url: 0/0/0 (4 silenced: 2 permanent, 2 entryList follow-ups of the block-library track). Smoke tests 15/15. Co-Authored-By: Claude Opus 5.5 <[email protected]>
56 lines
3.2 KiB
TypeScript
56 lines
3.2 KiB
TypeScript
/**
|
|
* blocksToMarkdown reads the library blocks' section header (eyebrow, heading, intro). Without it a page whose text
|
|
* is only in its hero (an archive, a quote page, a 404) got no auto-filled meta description and fell back to the
|
|
* site description, and /md pages and llms-full.txt missed every section heading and intro.
|
|
*/
|
|
import { describe, expect, test } from 'vitest'
|
|
|
|
import { blocksToMarkdown } from '../src/modules/content/blocksToMarkdown.js'
|
|
import { buildAutoFillMetaHook } from '../src/modules/seo/autoFillMeta.js'
|
|
|
|
const hero = { blockType: 'hero', header: { eyebrow: 'Studio', heading: 'Case studies', intro: 'Houses, interiors and conversions we designed.' }, variant: 'page' }
|
|
|
|
describe('blocksToMarkdown — section header', () => {
|
|
test('heading becomes ## and the intro follows; the eyebrow is left out', () => {
|
|
expect(blocksToMarkdown([hero])).toBe('## Case studies\n\nHouses, interiors and conversions we designed.')
|
|
})
|
|
|
|
test('the header leads the block even when other keys come first in the stored object', () => {
|
|
// eslint-disable-next-line perfectionist/sort-objects -- the stored key order (question → answer, header last) is what this test checks
|
|
const faq = { blockType: 'faq', items: [{ question: 'How long?', answer: 'Two to four months.' }], header: { heading: 'Questions' } }
|
|
expect(blocksToMarkdown([faq])).toBe('## Questions\n\n**How long?**\n\nTwo to four months.')
|
|
})
|
|
|
|
test('team bios and gallery captions are text', () => {
|
|
const team = { blockType: 'team', items: [{ bio: 'Founder, designs houses.', heading: 'Anna' }] }
|
|
const gallery = { blockType: 'gallery', items: [{ caption: 'The courtyard at dusk.' }] }
|
|
expect(blocksToMarkdown([team, gallery])).toContain('Founder, designs houses.')
|
|
expect(blocksToMarkdown([gallery])).toBe('The courtyard at dusk.')
|
|
})
|
|
|
|
test('testimonial quotes and intros are text', () => {
|
|
const t = { blockType: 'testimonials', items: [{ heading: 'Marta K.', quote: 'Morning sun in the kitchen.' }] }
|
|
expect(blocksToMarkdown([t])).toContain('Morning sun in the kitchen.')
|
|
})
|
|
|
|
test('an empty or missing header adds nothing', () => {
|
|
expect(blocksToMarkdown([{ blockType: 'cta', header: {} }, { blockType: 'cta', header: null }])).toBe('')
|
|
})
|
|
})
|
|
|
|
describe('autoFillMeta — a page with only a hero gets its own description', () => {
|
|
test('meta.description comes from the hero intro, not the site description', () => {
|
|
const hook = buildAutoFillMetaHook()
|
|
const data = hook({ context: {}, data: { layout: [hero, { blockType: 'entryList', entryCollection: 'posts' }], title: 'Case studies' } } as never) as { meta: { description: string } }
|
|
expect(data.meta.description).toBe('Houses, interiors and conversions we designed.')
|
|
})
|
|
})
|
|
|
|
describe('page templates — unfilled pages still differ', () => {
|
|
test('the privacy policy and terms placeholders name their page (no shared meta description)', async () => {
|
|
const { pageTemplates } = await import('../src/modules/block-library/templates/index.js')
|
|
const text = (page: { layout: Record<string, unknown>[] }) => JSON.stringify(page.layout.find((b) => b.blockType === 'richText'))
|
|
expect(text(pageTemplates.legal('privacyPolicy'))).not.toBe(text(pageTemplates.legal('termsOfService')))
|
|
})
|
|
})
|