You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rules(content): article-toc does not read JSON-LD nested in @graph, so a Yoast-style ItemList reports as missing #339
Found while fixing #317, which covered the seven schema/* rules with the same defect. content/article-toc has it too and was outside that issue's stated scope, so it was left alone rather than folded into #338.
checkTocSchema in packages/rules/src/content/article-toc.ts:118 reads each JSON-LD script and then does:
constdata=JSON.parse(script.textContent||"");constschemas: ItemListSchema[]=Array.isArray(data) ? data : [data];
So the only nodes it ever sees are the top level of each script. On a site whose JSON-LD is one {"@context":…,"@graph":[…]} wrapper, which is what Yoast, Rank Math and Slim SEO all emit and therefore most of the WordPress web, the wrapper is the only node and it has no @type. An ItemList describing the page's table of contents is nested inside and is never found.
The consequence is narrower than the seven rules in #317, because this is one input to a heuristic rather than the finding itself: the rule concludes the page has no TOC schema and reports accordingly. Still a false negative on correct markup.
The fix is the same one-line change that closed #317. flattenJsonLdNodes is exported from @squirrelscan/utils and already used by schema/local-business, the entity-map builder and, since #338, the seven schema rules:
Per script rather than over the joined schema.raw, because that join can mis-split a pretty-printed block (#1099). The helper returns an empty list for unparseable input, so the surrounding try/catch goes with it. Note that #338 also gave the helper a depth cap, so this is safe against a hostile @graph chain.
Acceptance Criteria
content/article-toc finds an ItemList nested in an @graph wrapper
The rule produces the same verdict from @graph markup as from the equivalent flat markup
A test proves it, and fails against the current implementation
Unparseable JSON-LD is still skipped rather than thrown on
A repo-wide check confirms no other rule still does Array.isArray(data) ? data : [data] on a parsed JSON-LD script
Activity
fix(rules): read @graph ItemList in content/article-toc (#339)
fix(rules): read @graph ItemList in content/article-toc (#339)
fix(rules): read @graph ItemList in content/article-toc (#339) (#609)