Merge claude/reference-seo-content: own meta descriptions, fuller demo content
Reference site: every page has its own meta description, demo archive and service pages have real-length content; blocksToMarkdown reads section headers. Conflicts resolved: reference/ipal-doctor.json — both branches removed their own two live-seo silences, so the merged file keeps only the two permanent rules (audit:collections-present, i18n-literals); docs/agent/reference-site/INDEX.md regenerated with pnpm reference:index.
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* 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')))
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user