diff --git a/seo-crawl-audit.mjs b/seo-crawl-audit.mjs index f623e1c..23ae19c 100644 --- a/seo-crawl-audit.mjs +++ b/seo-crawl-audit.mjs @@ -28,6 +28,14 @@ const norm = (href) => { return href; }; +const collectSchemaTypes = (node, acc) => { + if (!node || typeof node !== 'object') return acc; + if (Array.isArray(node)) { node.forEach((n) => collectSchemaTypes(n, acc)); return acc; } + if (node['@type']) acc.push(node['@type']); + Object.values(node).forEach((v) => collectSchemaTypes(v, acc)); + return acc; +}; + for (const f of files) { const rel = '/' + relative(DIST, f).replace(/index\.html$/, '').replace(/\.html$/, '/'); const html = readFileSync(f, 'utf8'); @@ -40,14 +48,7 @@ for (const f of files) { const schemaTypes = [...html.matchAll(/