Skip to content

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

Open
schlessera wants to merge 1 commit into
jdevalk:mainfrom
schlessera:fix/seo-graph-core-article-ispartof-array
Open

fix(seo-graph-core): accept Reference array for buildArticle isPartOf#54
schlessera wants to merge 1 commit into
jdevalk:mainfrom
schlessera:fix/seo-graph-core-article-ispartof-array

Conversation

@schlessera

Copy link
Copy Markdown

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.

ArticleInput.isPartOf was typed as a single `Reference`, but the shipped
AGENTS.md "Personal blog" recipe links a posting to both its WebPage and
the Blog via `isPartOf: [{ '@id': webPage }, { '@id': blog }]`. The
builder already passes the value through verbatim (`isPartOf:
input.isPartOf`), so the array worked at runtime — but the type rejected
it, forcing an `as` cast.

Widen the input type to `Reference | Reference[]`. Pure type change; no
runtime difference. Add a test asserting the array is emitted verbatim.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant