seo-graph icon indicating copy to clipboard operation
seo-graph copied to clipboard

fix(seo-graph-core): accept Reference array for buildArticle isPartOf

Open schlessera opened this issue 5 months ago • 0 comments

Problem

ArticleInput.isPartOf is typed as a single Reference:

// packages/seo-graph-core/src/pieces/article.ts
isPartOf: Reference;

But the shipped "Personal blog" recipe in AGENTS.md links a posting to both its WebPage and the Blog:

buildArticle({
    ...
    isPartOf: [{ '@id': ids.webPage(url) }, { '@id': blogId }],
}, ids, 'BlogPosting');

(AGENTS.md L681 and L827 — the only array isPartOf recipes in the guide, both buildArticle.)

The builder already emits the value verbatim — isPartOf: input.isPartOf (article.ts L74) — so the array is correct at runtime. Only the type rejects it, so following the documented recipe requires an as cast under strict TS.

Fix

Widen the input type to Reference | Reference[]. Pure type change — no runtime difference; single-reference callers are unaffected.

  • src/pieces/article.ts — widen isPartOf type + expand the JSDoc with the array example.
  • test/pieces.test.ts — add a case asserting an array is emitted verbatim.
  • changeset: minor (widens a public input type, non-breaking).

Verification

pnpm build && pnpm typecheck && pnpm test && pnpm format:check all green locally (core 59 tests, +1 new).

Open question — scope

isPartOf: Reference also appears on buildWebPage, buildVideoObject, and buildSiteNavigationElement. schema.org allows arrays there too, but no in-repo recipe passes one, so I kept this PR scoped to buildArticle (the documented, demonstrated case). Happy to widen the others in this PR if you'd prefer consistency across all builders — just say the word.

schlessera avatar Jun 15 '26 13:06 schlessera