pagegraph 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audit.d.ts +3 -3
- package/dist/audit.js +1928 -1
- package/dist/audit.js.map +1 -0
- package/dist/cli.js +33482 -35
- package/dist/cli.js.map +1 -1
- package/dist/index.js +449 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/audit-B96V1x3q.js +0 -1929
- package/dist/audit-B96V1x3q.js.map +0 -1
- package/dist/inspect-html-CHuoiO2s.js +0 -452
- package/dist/inspect-html-CHuoiO2s.js.map +0 -1
- package/dist/main-GFEobQTH.js +0 -750
- package/dist/main-GFEobQTH.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { a as contentSignal, c as renderSitemap, i as hasStructuralViolations, n as inspectHtml, o as inspectNode, r as checkGraph, s as renderRobots, t as hasBlockingIssues } from "./inspect-html-CHuoiO2s.js";
|
|
2
1
|
//#region src/core/graph.ts
|
|
3
2
|
/** Kind for instances whose collection route carries no declaration to inherit. */
|
|
4
3
|
const FALLBACK_KIND = "page";
|
|
@@ -135,6 +134,455 @@ function buildSeoGraph(input) {
|
|
|
135
134
|
};
|
|
136
135
|
}
|
|
137
136
|
//#endregion
|
|
137
|
+
//#region src/core/projections.ts
|
|
138
|
+
const escapeXml = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
139
|
+
/**
|
|
140
|
+
* A node belongs in the sitemap when it declares a positive sitemap policy, is not
|
|
141
|
+
* a redirect, is not robots-noindexed, and is not a param template (a route whose
|
|
142
|
+
* path still contains a `$` segment — those exist only so their instances inherit).
|
|
143
|
+
*/
|
|
144
|
+
function isSitemapEligible(node) {
|
|
145
|
+
if (node.policy.redirectTo !== void 0) return false;
|
|
146
|
+
if (node.policy.robots?.includes("noindex")) return false;
|
|
147
|
+
if (!node.policy.sitemap) return false;
|
|
148
|
+
if (node.path.includes("$")) return false;
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
/** Canonical absolute URL for a node under the given origin. */
|
|
152
|
+
function urlForNode(origin, node) {
|
|
153
|
+
return node.path === "/" ? origin : `${origin}${node.path}`;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Instance lastmod: the most recent date the page's frontmatter carries. A
|
|
157
|
+
* collection whose instances carry no dates (docs, a manifest-driven gallery)
|
|
158
|
+
* emits no `<lastmod>` at all.
|
|
159
|
+
*/
|
|
160
|
+
function instanceLastmod(node) {
|
|
161
|
+
const instance = node.instance;
|
|
162
|
+
if (!instance) return void 0;
|
|
163
|
+
const date = instance.modifiedAt ?? instance.publishedAt;
|
|
164
|
+
return date ? new Date(date).toISOString() : void 0;
|
|
165
|
+
}
|
|
166
|
+
function renderUrlEntry(url, lastmod, node) {
|
|
167
|
+
const { changeFrequency, priority } = node.policy.sitemap;
|
|
168
|
+
const lines = [` <url>`, ` <loc>${escapeXml(url)}</loc>`];
|
|
169
|
+
if (lastmod) lines.push(` <lastmod>${lastmod}</lastmod>`);
|
|
170
|
+
lines.push(` <changefreq>${changeFrequency}</changefreq>`, ` <priority>${priority.toFixed(1)}</priority>`, ` </url>`);
|
|
171
|
+
return lines.join("\n");
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Render sitemap.xml from the graph. Structural route entries emit no `<lastmod>`
|
|
175
|
+
* (a route has no publish date); content instances emit it from their frontmatter.
|
|
176
|
+
* Route entries are sorted by path, then instances follow in collection order.
|
|
177
|
+
* `indexable` is intentionally unused — the sitemap body is host-independent;
|
|
178
|
+
* robots.txt is what gates crawling.
|
|
179
|
+
*/
|
|
180
|
+
function renderSitemap(graph, cfg) {
|
|
181
|
+
const nodes = [...graph.nodes.values()];
|
|
182
|
+
const staticNodes = nodes.filter((node) => node.source === "route" && isSitemapEligible(node)).sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
183
|
+
const instanceNodes = nodes.filter((node) => node.source !== "route" && isSitemapEligible(node));
|
|
184
|
+
const seen = /* @__PURE__ */ new Set();
|
|
185
|
+
const entries = [];
|
|
186
|
+
for (const node of [...staticNodes, ...instanceNodes]) {
|
|
187
|
+
const url = urlForNode(cfg.origin, node);
|
|
188
|
+
const key = url.toLowerCase().replace(/\/$/, "");
|
|
189
|
+
if (seen.has(key)) continue;
|
|
190
|
+
seen.add(key);
|
|
191
|
+
entries.push(renderUrlEntry(url, instanceLastmod(node), node));
|
|
192
|
+
}
|
|
193
|
+
return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${entries.join("\n")}\n</urlset>\n`;
|
|
194
|
+
}
|
|
195
|
+
/** Format a Content-Signal robots.txt directive from the preference list. */
|
|
196
|
+
function contentSignal(value) {
|
|
197
|
+
return `Content-Signal: ${value}`;
|
|
198
|
+
}
|
|
199
|
+
const groupLines = (cfg) => {
|
|
200
|
+
const lines = [];
|
|
201
|
+
if (cfg.contentSignal !== void 0 && cfg.contentSignal !== "") lines.push(contentSignal(cfg.contentSignal));
|
|
202
|
+
for (const directive of cfg.directives ?? []) if (directive !== "") lines.push(directive);
|
|
203
|
+
return lines;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Render robots.txt. A non-indexable host (previews) gets a disallow-all
|
|
207
|
+
* with no Sitemap line; an indexable host disallows exactly the prefixes the caller
|
|
208
|
+
* passes. Pages that declare `robots: noindex` are intentionally NOT added as
|
|
209
|
+
* Disallow entries — a Disallow would stop crawlers reaching the page to read its
|
|
210
|
+
* `noindex, follow` meta, so the graph's per-node robots policy never feeds this
|
|
211
|
+
* list. `graph` is unused — kept for signature parity with the other projections,
|
|
212
|
+
* which callers load the graph once for and pass to each.
|
|
213
|
+
*
|
|
214
|
+
* Origin-wide group directives (`contentSignal`, `directives`) are indexable-host
|
|
215
|
+
* only. {@link RobotsConfig.transform} always runs last so a consumer can override
|
|
216
|
+
* the whole file.
|
|
217
|
+
*/
|
|
218
|
+
function renderRobots(_graph, cfg) {
|
|
219
|
+
const rendered = cfg.indexable ? [
|
|
220
|
+
"User-agent: *",
|
|
221
|
+
...groupLines(cfg),
|
|
222
|
+
"Allow: /",
|
|
223
|
+
...cfg.disallow.map((path) => `Disallow: ${path}`),
|
|
224
|
+
"",
|
|
225
|
+
`Sitemap: ${cfg.origin}/sitemap.xml`,
|
|
226
|
+
`Host: ${cfg.origin}`,
|
|
227
|
+
""
|
|
228
|
+
].join("\n") : [
|
|
229
|
+
"User-agent: *",
|
|
230
|
+
"Disallow: /",
|
|
231
|
+
""
|
|
232
|
+
].join("\n");
|
|
233
|
+
return cfg.transform === void 0 ? rendered : cfg.transform(rendered);
|
|
234
|
+
}
|
|
235
|
+
/** Inspect a single node: its declaration, sitemap eligibility, and edges. */
|
|
236
|
+
function inspectNode(graph, path) {
|
|
237
|
+
const node = graph.nodes.get(path);
|
|
238
|
+
if (!node) return void 0;
|
|
239
|
+
return {
|
|
240
|
+
node,
|
|
241
|
+
inSitemap: isSitemapEligible(node),
|
|
242
|
+
incoming: graph.edges.filter((edge) => edge.to === path),
|
|
243
|
+
outgoing: graph.edges.filter((edge) => edge.from === path)
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/core/checks.ts
|
|
248
|
+
/** A positive sitemap policy — the author asked for this page to be indexed. */
|
|
249
|
+
const hasPositiveSitemap = (sitemap) => sitemap !== void 0 && sitemap !== false;
|
|
250
|
+
/** Content and manifest instances carry page-level title/description. */
|
|
251
|
+
const isInstance = (node) => node.source !== "route";
|
|
252
|
+
/** Group instance nodes by a present, non-empty string field for duplicate detection. */
|
|
253
|
+
const groupInstancesBy = (graph, field) => {
|
|
254
|
+
const groups = /* @__PURE__ */ new Map();
|
|
255
|
+
for (const node of graph.nodes.values()) {
|
|
256
|
+
if (!isInstance(node)) continue;
|
|
257
|
+
const value = field(node)?.trim();
|
|
258
|
+
if (!value) continue;
|
|
259
|
+
const bucket = groups.get(value);
|
|
260
|
+
if (bucket) bucket.push(node);
|
|
261
|
+
else groups.set(value, [node]);
|
|
262
|
+
}
|
|
263
|
+
return groups;
|
|
264
|
+
};
|
|
265
|
+
const DESCRIPTION_MAX = 160;
|
|
266
|
+
const DESCRIPTION_MIN = 50;
|
|
267
|
+
/**
|
|
268
|
+
* Every check, in one place. `checkGraph` runs them in order and stamps each
|
|
269
|
+
* finding with its rule name and severity, so the output is grouped by rule and
|
|
270
|
+
* deterministic (nodes iterate in graph insertion order, edges in array order).
|
|
271
|
+
*/
|
|
272
|
+
const CHECK_RULES = [
|
|
273
|
+
{
|
|
274
|
+
name: "path-owner-collision",
|
|
275
|
+
severity: "structural",
|
|
276
|
+
evaluate: (graph) => (graph.collisions ?? []).map((collision) => ({
|
|
277
|
+
path: collision.path,
|
|
278
|
+
message: `Canonical path "${collision.path}" is owned by multiple sources: ${collision.sources.join(", ")}.`,
|
|
279
|
+
fix: "Give every concrete page one canonical path and one graph owner."
|
|
280
|
+
}))
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: "canonical-path-collision",
|
|
284
|
+
severity: "structural",
|
|
285
|
+
evaluate: (graph) => {
|
|
286
|
+
const groups = /* @__PURE__ */ new Map();
|
|
287
|
+
for (const path of graph.nodes.keys()) {
|
|
288
|
+
const canonical = path.toLowerCase().replace(/\/$/, "") || "/";
|
|
289
|
+
const paths = groups.get(canonical);
|
|
290
|
+
if (paths) paths.push(path);
|
|
291
|
+
else groups.set(canonical, [path]);
|
|
292
|
+
}
|
|
293
|
+
return [...groups.values()].filter((paths) => paths.length > 1).flatMap((paths) => paths.map((path) => ({
|
|
294
|
+
path,
|
|
295
|
+
message: `Canonical path collides with ${paths.filter((candidate) => candidate !== path).join(", ")}.`,
|
|
296
|
+
fix: "Use one lowercase, trailing-slash-normalized canonical path."
|
|
297
|
+
})));
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
name: "self-edge",
|
|
302
|
+
severity: "structural",
|
|
303
|
+
evaluate: (graph) => graph.edges.filter((edge) => edge.from === edge.to).map((edge) => ({
|
|
304
|
+
path: edge.from,
|
|
305
|
+
message: `${edge.type} edge points back to its own source node.`,
|
|
306
|
+
fix: "Remove the self-reference from the canonical manifest or route declaration."
|
|
307
|
+
}))
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: "duplicate-edge",
|
|
311
|
+
severity: "structural",
|
|
312
|
+
evaluate: (graph) => {
|
|
313
|
+
const seen = /* @__PURE__ */ new Set();
|
|
314
|
+
const duplicates = [];
|
|
315
|
+
for (const edge of graph.edges) {
|
|
316
|
+
const key = `${edge.from}\u0000${edge.to}\u0000${edge.type}`;
|
|
317
|
+
if (seen.has(key)) duplicates.push({
|
|
318
|
+
path: edge.from,
|
|
319
|
+
message: `Duplicate ${edge.type} edge from "${edge.from}" to "${edge.to}".`,
|
|
320
|
+
fix: "Declare each graph relationship exactly once."
|
|
321
|
+
});
|
|
322
|
+
else seen.add(key);
|
|
323
|
+
}
|
|
324
|
+
return duplicates;
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: "dead-edge",
|
|
329
|
+
severity: "structural",
|
|
330
|
+
evaluate: (graph) => graph.edges.filter((edge) => edge.type !== "crumb-parent" && !graph.nodes.has(edge.to)).map((edge) => ({
|
|
331
|
+
path: edge.from,
|
|
332
|
+
message: `${edge.type} edge from "${edge.from}" points at "${edge.to}", which is not a node in the graph.`,
|
|
333
|
+
fix: `Update the ${edge.type === "redirect" ? "redirectTo" : "related"} target on the "${edge.from}" route, or restore "${edge.to}".`
|
|
334
|
+
}))
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: "instance-missing-title",
|
|
338
|
+
severity: "structural",
|
|
339
|
+
evaluate: (graph) => [...graph.nodes.values()].filter((node) => isInstance(node) && !node.instance?.title.trim()).map((node) => ({
|
|
340
|
+
path: node.path,
|
|
341
|
+
message: `Content page "${node.path}" has no title.`,
|
|
342
|
+
fix: "Add a `title` to the page frontmatter."
|
|
343
|
+
}))
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
name: "sitemap-noindex-contradiction",
|
|
347
|
+
severity: "structural",
|
|
348
|
+
evaluate: (graph) => [...graph.nodes.values()].filter((node) => hasPositiveSitemap(node.policy.sitemap) && node.policy.robots?.toLowerCase().includes("noindex")).map((node) => ({
|
|
349
|
+
path: node.path,
|
|
350
|
+
message: `"${node.path}" declares a sitemap policy but its robots value is "${node.policy.robots}".`,
|
|
351
|
+
fix: "Drop the sitemap policy (or set `sitemap: false`) on a noindex page, or remove the noindex robots value."
|
|
352
|
+
}))
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: "robots-not-lowercase",
|
|
356
|
+
severity: "structural",
|
|
357
|
+
evaluate: (graph) => [...graph.nodes.values()].filter((node) => node.policy.robots !== void 0 && node.policy.robots !== node.policy.robots.toLowerCase()).map((node) => ({
|
|
358
|
+
path: node.path,
|
|
359
|
+
message: `"${node.path}" declares robots "${node.policy.robots}" — robots values must be lowercase.`,
|
|
360
|
+
fix: "Lowercase the robots declaration (e.g. \"noindex, follow\")."
|
|
361
|
+
}))
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "related-target-missing-link",
|
|
365
|
+
severity: "structural",
|
|
366
|
+
evaluate: (graph) => {
|
|
367
|
+
const linklessTargets = /* @__PURE__ */ new Set();
|
|
368
|
+
for (const edge of graph.edges) {
|
|
369
|
+
if (edge.type !== "related") continue;
|
|
370
|
+
const target = graph.nodes.get(edge.to);
|
|
371
|
+
if (target && target.source === "route" && target.policy.link === void 0) linklessTargets.add(edge.to);
|
|
372
|
+
}
|
|
373
|
+
return [...linklessTargets].map((path) => ({
|
|
374
|
+
path,
|
|
375
|
+
message: `Route "${path}" is a related-link target but declares no link metadata; its card would render empty.`,
|
|
376
|
+
fix: `Add \`link: { title, description }\` to the "${path}" route's staticData.seo.`
|
|
377
|
+
}));
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
name: "redirect-in-sitemap",
|
|
382
|
+
severity: "structural",
|
|
383
|
+
evaluate: (graph) => [...graph.nodes.values()].filter((node) => node.policy.redirectTo !== void 0 && hasPositiveSitemap(node.policy.sitemap)).map((node) => ({
|
|
384
|
+
path: node.path,
|
|
385
|
+
message: `Redirect "${node.path}" (→ "${node.policy.redirectTo}") also declares a sitemap policy.`,
|
|
386
|
+
fix: "Remove the sitemap policy from the redirect route; only its target belongs in the sitemap."
|
|
387
|
+
}))
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
name: "duplicate-title",
|
|
391
|
+
severity: "editorial",
|
|
392
|
+
evaluate: (graph) => [...groupInstancesBy(graph, (node) => node.instance?.title).entries()].filter(([, nodes]) => nodes.length > 1).flatMap(([title, nodes]) => nodes.map((node) => ({
|
|
393
|
+
path: node.path,
|
|
394
|
+
message: `Title "${title}" is shared by ${nodes.length} pages.`,
|
|
395
|
+
fix: "Give each page a distinct title."
|
|
396
|
+
})))
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
name: "duplicate-description",
|
|
400
|
+
severity: "editorial",
|
|
401
|
+
evaluate: (graph) => [...groupInstancesBy(graph, (node) => node.instance?.description).entries()].filter(([, nodes]) => nodes.length > 1).flatMap(([, nodes]) => nodes.map((node) => ({
|
|
402
|
+
path: node.path,
|
|
403
|
+
message: `Description is shared by ${nodes.length} pages.`,
|
|
404
|
+
fix: "Write a distinct meta description for each page."
|
|
405
|
+
})))
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
name: "description-length",
|
|
409
|
+
severity: "editorial",
|
|
410
|
+
evaluate: (graph) => [...graph.nodes.values()].flatMap((node) => {
|
|
411
|
+
if (!isInstance(node)) return [];
|
|
412
|
+
const description = node.instance?.description?.trim();
|
|
413
|
+
if (!description) return [];
|
|
414
|
+
if (description.length > DESCRIPTION_MAX) return [{
|
|
415
|
+
path: node.path,
|
|
416
|
+
message: `Description is ${description.length} chars (max ${DESCRIPTION_MAX}); it will be truncated in results.`,
|
|
417
|
+
fix: `Trim the description to ${DESCRIPTION_MAX} characters or fewer.`
|
|
418
|
+
}];
|
|
419
|
+
if (description.length < DESCRIPTION_MIN) return [{
|
|
420
|
+
path: node.path,
|
|
421
|
+
message: `Description is ${description.length} chars (min ${DESCRIPTION_MIN}); it reads as thin.`,
|
|
422
|
+
fix: `Expand the description to at least ${DESCRIPTION_MIN} characters.`
|
|
423
|
+
}];
|
|
424
|
+
return [];
|
|
425
|
+
})
|
|
426
|
+
}
|
|
427
|
+
];
|
|
428
|
+
/** Run every rule against the graph and return the flat list of violations. */
|
|
429
|
+
function checkGraph(graph) {
|
|
430
|
+
return CHECK_RULES.flatMap((rule) => rule.evaluate(graph).map((raw) => ({
|
|
431
|
+
severity: rule.severity,
|
|
432
|
+
rule: rule.name,
|
|
433
|
+
path: raw.path,
|
|
434
|
+
message: raw.message,
|
|
435
|
+
fix: raw.fix
|
|
436
|
+
})));
|
|
437
|
+
}
|
|
438
|
+
/** Structural violations fail `pagegraph check`; editorial-only stays green. */
|
|
439
|
+
const hasStructuralViolations = (violations) => violations.some((violation) => violation.severity === "structural");
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/core/inspect-html.ts
|
|
442
|
+
const ENTITIES = {
|
|
443
|
+
"&": "&",
|
|
444
|
+
"<": "<",
|
|
445
|
+
">": ">",
|
|
446
|
+
""": "\"",
|
|
447
|
+
"'": "'",
|
|
448
|
+
"'": "'"
|
|
449
|
+
};
|
|
450
|
+
const decodeEntities = (value) => value.replace(/&(?:amp|lt|gt|quot|#39|apos);/g, (match) => ENTITIES[match] ?? match);
|
|
451
|
+
/** Pull double/single-quoted attributes off a single tag string. */
|
|
452
|
+
const parseAttrs = (tag) => {
|
|
453
|
+
const attrs = {};
|
|
454
|
+
const re = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
|
|
455
|
+
let match;
|
|
456
|
+
while ((match = re.exec(tag)) !== null) attrs[match[1].toLowerCase()] = decodeEntities(match[2] ?? match[3] ?? "");
|
|
457
|
+
return attrs;
|
|
458
|
+
};
|
|
459
|
+
/** Normalize a JSON-LD `@type` (string or array) to a single readable label. */
|
|
460
|
+
const typeName = (value) => {
|
|
461
|
+
if (typeof value === "string") return value;
|
|
462
|
+
if (Array.isArray(value)) return value.filter((v) => typeof v === "string").join(", ") || "unknown";
|
|
463
|
+
return "unknown";
|
|
464
|
+
};
|
|
465
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
466
|
+
/** Flatten a parsed JSON-LD payload (single object, array, or `@graph`) to items. */
|
|
467
|
+
const collectItems = (parsed) => {
|
|
468
|
+
if (Array.isArray(parsed)) return parsed.filter(isObject);
|
|
469
|
+
if (isObject(parsed)) {
|
|
470
|
+
if (Array.isArray(parsed["@graph"])) return parsed["@graph"].filter(isObject);
|
|
471
|
+
return [parsed];
|
|
472
|
+
}
|
|
473
|
+
return [];
|
|
474
|
+
};
|
|
475
|
+
const countQuestions = (mainEntity) => {
|
|
476
|
+
if (!Array.isArray(mainEntity)) return 0;
|
|
477
|
+
return mainEntity.filter((entry) => isObject(entry) && typeName(entry["@type"]) === "Question").length;
|
|
478
|
+
};
|
|
479
|
+
const validateItemListElements = (value) => {
|
|
480
|
+
if (!Array.isArray(value) || value.length < 1) return ["ItemList needs at least one `itemListElement` entry."];
|
|
481
|
+
const errors = [];
|
|
482
|
+
value.forEach((entry, index) => {
|
|
483
|
+
if (!isObject(entry) || typeName(entry["@type"]) !== "ListItem") {
|
|
484
|
+
errors.push(`ItemList entry ${index + 1} is not a ListItem.`);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
if (entry["position"] !== index + 1) errors.push(`ItemList entry ${index + 1} has an invalid position.`);
|
|
488
|
+
if (!entry["name"] || !entry["url"]) errors.push(`ItemList entry ${index + 1} needs a name and URL.`);
|
|
489
|
+
});
|
|
490
|
+
return errors;
|
|
491
|
+
};
|
|
492
|
+
/** Minimal per-type validation — enough to catch an empty or malformed block. */
|
|
493
|
+
const validateItem = (item) => {
|
|
494
|
+
const type = typeName(item["@type"]);
|
|
495
|
+
const errors = [];
|
|
496
|
+
if (type === "Article" || type === "NewsArticle" || type === "BlogPosting") {
|
|
497
|
+
if (!item["headline"]) errors.push("Article is missing `headline`.");
|
|
498
|
+
if (!item["datePublished"]) errors.push("Article is missing `datePublished`.");
|
|
499
|
+
} else if (type === "FAQPage") {
|
|
500
|
+
if (countQuestions(item["mainEntity"]) < 1) errors.push("FAQPage needs at least one Question in `mainEntity`.");
|
|
501
|
+
} else if (type === "BreadcrumbList") {
|
|
502
|
+
const items = item["itemListElement"];
|
|
503
|
+
if (!Array.isArray(items) || items.length < 2) errors.push("BreadcrumbList needs at least two `itemListElement` entries.");
|
|
504
|
+
} else if (type === "ItemList") {
|
|
505
|
+
errors.push(...validateItemListElements(item["itemListElement"]));
|
|
506
|
+
const items = item["itemListElement"];
|
|
507
|
+
if (Array.isArray(items) && item["numberOfItems"] !== items.length) errors.push("ItemList `numberOfItems` does not match its entries.");
|
|
508
|
+
}
|
|
509
|
+
return {
|
|
510
|
+
type,
|
|
511
|
+
valid: errors.length === 0,
|
|
512
|
+
errors
|
|
513
|
+
};
|
|
514
|
+
};
|
|
515
|
+
const validateLdJson = (raw) => {
|
|
516
|
+
let parsed;
|
|
517
|
+
try {
|
|
518
|
+
parsed = JSON.parse(raw);
|
|
519
|
+
} catch (cause) {
|
|
520
|
+
return [{
|
|
521
|
+
type: "unparseable",
|
|
522
|
+
valid: false,
|
|
523
|
+
errors: [`JSON parse error: ${cause instanceof Error ? cause.message : String(cause)}`]
|
|
524
|
+
}];
|
|
525
|
+
}
|
|
526
|
+
const items = collectItems(parsed);
|
|
527
|
+
if (items.length === 0) return [{
|
|
528
|
+
type: "unknown",
|
|
529
|
+
valid: false,
|
|
530
|
+
errors: ["No JSON-LD object found in block."]
|
|
531
|
+
}];
|
|
532
|
+
return items.map(validateItem);
|
|
533
|
+
};
|
|
534
|
+
/** Parse a rendered HTML document's `<head>` into a report. Pure. */
|
|
535
|
+
const inspectHtml = (url, status, html) => {
|
|
536
|
+
const headMatch = html.match(/<head[^>]*>([\s\S]*?)<\/head>/i);
|
|
537
|
+
const head = headMatch ? headMatch[1] : html;
|
|
538
|
+
const titleMatch = head.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
|
|
539
|
+
const title = titleMatch ? decodeEntities(titleMatch[1].trim()) : void 0;
|
|
540
|
+
const og = {};
|
|
541
|
+
const twitter = {};
|
|
542
|
+
let description;
|
|
543
|
+
let robots;
|
|
544
|
+
for (const tag of head.match(/<meta\b[^>]*>/gi) ?? []) {
|
|
545
|
+
const attrs = parseAttrs(tag);
|
|
546
|
+
const content = attrs["content"];
|
|
547
|
+
if (content === void 0) continue;
|
|
548
|
+
const property = attrs["property"];
|
|
549
|
+
const name = attrs["name"];
|
|
550
|
+
if (property?.startsWith("og:")) og[property] = content;
|
|
551
|
+
else if (name?.startsWith("twitter:")) twitter[name] = content;
|
|
552
|
+
else if (name === "description") description = content;
|
|
553
|
+
else if (name === "robots") robots = content;
|
|
554
|
+
}
|
|
555
|
+
let canonical;
|
|
556
|
+
for (const tag of head.match(/<link\b[^>]*>/gi) ?? []) {
|
|
557
|
+
const attrs = parseAttrs(tag);
|
|
558
|
+
if (attrs["rel"] === "canonical") canonical = attrs["href"];
|
|
559
|
+
}
|
|
560
|
+
const jsonLd = [];
|
|
561
|
+
const scriptRe = /<script\b[^>]*type=["']application\/ld\+json["'][^>]*>([\s\S]*?)<\/script>/gi;
|
|
562
|
+
let scriptMatch;
|
|
563
|
+
while ((scriptMatch = scriptRe.exec(head)) !== null) jsonLd.push(...validateLdJson(scriptMatch[1].trim()));
|
|
564
|
+
const issues = [];
|
|
565
|
+
if (status >= 400) issues.push(`Fetch returned HTTP ${status}.`);
|
|
566
|
+
if (!title) issues.push("Missing <title>.");
|
|
567
|
+
if (!description) issues.push("Missing meta description.");
|
|
568
|
+
if (!canonical) issues.push("Missing canonical link.");
|
|
569
|
+
for (const block of jsonLd) if (!block.valid) issues.push(...block.errors.map((error) => `JSON-LD (${block.type}): ${error}`));
|
|
570
|
+
return {
|
|
571
|
+
url,
|
|
572
|
+
status,
|
|
573
|
+
title,
|
|
574
|
+
description,
|
|
575
|
+
canonical,
|
|
576
|
+
robots,
|
|
577
|
+
og,
|
|
578
|
+
twitter,
|
|
579
|
+
jsonLd,
|
|
580
|
+
issues
|
|
581
|
+
};
|
|
582
|
+
};
|
|
583
|
+
/** A non-empty `issues` list fails `pagegraph inspect --live` (exit 1). */
|
|
584
|
+
const hasBlockingIssues = (report) => report.issues.length > 0;
|
|
585
|
+
//#endregion
|
|
138
586
|
//#region src/core/resolve-route-link.ts
|
|
139
587
|
/**
|
|
140
588
|
* Resolve a route's declared `seo.link` card (title + description) by its full
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/core/graph.ts","../src/core/resolve-route-link.ts"],"sourcesContent":["/**\n * SEO graph — the derived model that projections (sitemap, robots), the CLI, and\n * the check engine all read from. Built from route declarations (`staticData.seo`)\n * plus consumer-supplied content collections. This module is pure: no React, no\n * env, no knowledge of where instances come from. Origins and env-derived values\n * are injected by the callers of the projections, never read here.\n *\n * A node is one of:\n * - a structural route (`source: \"route\"`), keyed by its normalized full path,\n * merging a layout route's declaration (crumb) with its index child's (kind,\n * sitemap policy) when both resolve to the same URL;\n * - a content instance (`source` = the collection's label), keyed by the page URL\n * and carrying page-level metadata.\n *\n * Edges: `crumb-parent` (breadcrumb ancestry), `related` (deliberate cross-links),\n * `collection-member` (membership in a curated set), and `redirect` (route aliases).\n * The route walk emits crumb/related/redirect edges from declarations; a collection\n * may declare any additional edges its instances need.\n */\n\nimport type { AnyRoute } from \"@tanstack/react-router\";\n\nimport type { PublicPath, RouteSeo, SeoKind } from \"./declare\";\n\n/**\n * Where a node came from: `\"route\"` for a structural route declaration, or the\n * `source` label of the collection that produced the instance (e.g. \"blog\").\n */\nexport type SeoSource = string;\n\nexport interface SeoNode {\n /** Canonical path, no origin (e.g. \"/pricing\", \"/blog/my-post\"). */\n path: string;\n kind: SeoKind;\n source: SeoSource;\n /** Route-declared policy, or synthesized (kind + inherited sitemap) for instances. */\n policy: RouteSeo;\n instance?:\n | {\n title: string;\n description?: string | undefined;\n publishedAt?: string | undefined;\n modifiedAt?: string | undefined;\n }\n | undefined;\n}\n\nexport type SeoEdgeType = \"crumb-parent\" | \"related\" | \"redirect\" | \"collection-member\";\n\nexport interface SeoEdge {\n from: string;\n to: string;\n type: SeoEdgeType;\n}\n\nexport interface SeoGraph {\n nodes: Map<string, SeoNode>;\n edges: Array<SeoEdge>;\n /** Exact-path ownership conflicts encountered while assembling graph sources. */\n collisions?: ReadonlyArray<{ path: string; sources: ReadonlyArray<SeoSource> }> | undefined;\n}\n\n/** One concrete page produced by a collection. */\nexport interface SeoInstance {\n /** Canonical path of the page (e.g. \"/blog/my-post\"). */\n readonly path: string;\n readonly title: string;\n readonly description?: string | undefined;\n readonly publishedAt?: string | undefined;\n readonly modifiedAt?: string | undefined;\n}\n\nexport interface SeoCollection {\n /**\n * The param route these instances render through (e.g. \"/blog/$slug\"). Instances\n * inherit this route's declared policy (kind + sitemap) — the graph reads it from\n * the structural node, so declarations stay the single source of truth.\n */\n readonly route: PublicPath;\n /** The `source` stamped on every node this collection produces (e.g. \"blog\"). */\n readonly source: SeoSource;\n readonly instances: ReadonlyArray<SeoInstance>;\n /** Edges the collection declares between its instances and the rest of the graph. */\n readonly edges?: ReadonlyArray<SeoEdge> | undefined;\n}\n\nexport interface BuildSeoGraphInput {\n readonly routeTree: AnyRoute;\n readonly collections?: ReadonlyArray<SeoCollection> | undefined;\n}\n\n/** Kind for instances whose collection route carries no declaration to inherit. */\nconst FALLBACK_KIND: SeoKind = \"page\";\n\n/** Structural view of a route we walk — the fields present before router init(). */\ninterface WalkableRoute {\n readonly options: {\n readonly path?: string | undefined;\n readonly staticData?: { readonly seo?: RouteSeo | undefined } | undefined;\n };\n readonly children?: ReadonlyArray<WalkableRoute> | undefined;\n}\n\n/**\n * Join a child's local path onto its parent's computed full path with the same\n * semantics as TanStack's route init (relative segments, index \"/\" inherits the\n * parent, pathless/group routes are transparent), then normalize trailing slashes.\n */\nfunction joinPath(parent: string, seg: string | undefined): string {\n if (seg === undefined) return parent; // pathless layout / route group\n if (seg === \"/\") return parent; // index route resolves to its parent's URL\n const trimmed = seg.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n const joined = `${parent === \"/\" ? \"\" : parent}/${trimmed}`;\n return joined.replace(/\\/{2,}/g, \"/\");\n}\n\n/** Merge a route's declaration into an existing same-path node (deeper route wins). */\nfunction mergeSeo(base: RouteSeo, override: RouteSeo): RouteSeo {\n return {\n kind: override.kind,\n crumb: override.crumb ?? base.crumb,\n sitemap: override.sitemap ?? base.sitemap,\n robots: override.robots ?? base.robots,\n related: override.related ?? base.related,\n link: override.link ?? base.link,\n redirectTo: override.redirectTo ?? base.redirectTo,\n };\n}\n\n/**\n * Walk the route tree building structural nodes and crumb-parent edges. `crumbStack`\n * holds the paths of crumb-declaring ancestors so each crumb node links to its nearest\n * crumb ancestor down the real route-parent chain (matching render-time breadcrumbs).\n */\nfunction walkRoutes(\n route: WalkableRoute,\n parentPath: string,\n isRoot: boolean,\n nodes: Map<string, SeoNode>,\n edges: Array<SeoEdge>,\n crumbStack: Array<string>,\n): void {\n const path = isRoot ? \"/\" : joinPath(parentPath, route.options.path);\n const seo = route.options.staticData?.seo;\n\n if (seo) {\n const existing = nodes.get(path);\n if (existing) {\n existing.policy = mergeSeo(existing.policy, seo);\n existing.kind = existing.policy.kind;\n } else {\n nodes.set(path, { path, kind: seo.kind, source: \"route\", policy: { ...seo } });\n }\n\n const nearestCrumbAncestor = crumbStack[crumbStack.length - 1];\n if (seo.crumb !== undefined && nearestCrumbAncestor !== undefined) {\n edges.push({ from: path, to: nearestCrumbAncestor, type: \"crumb-parent\" });\n }\n }\n\n const pushedCrumb = seo?.crumb !== undefined;\n if (pushedCrumb) crumbStack.push(path);\n for (const child of route.children ?? []) {\n walkRoutes(child, path, false, nodes, edges, crumbStack);\n }\n if (pushedCrumb) crumbStack.pop();\n}\n\n/**\n * Add one collection's instance nodes, inheriting kind + sitemap policy from the\n * collection route's declaration, then append the edges it declares. A path already\n * owned by another node is a collision: the first owner keeps the path and the\n * conflict is reported (the `path-owner-collision` check turns it into a violation).\n */\nfunction addCollection(\n nodes: Map<string, SeoNode>,\n edges: Array<SeoEdge>,\n collisions: Array<{ path: string; sources: ReadonlyArray<SeoSource> }>,\n collection: SeoCollection,\n): void {\n const collectionNode = nodes.get(collection.route);\n const kind = collectionNode?.kind ?? FALLBACK_KIND;\n const sitemap = collectionNode?.policy.sitemap;\n\n /**\n * Paths this collection lost to an earlier owner. Their instances never enter\n * the graph, so any edge declared out of them would dangle — and the dead-edge\n * check only validates an edge's `to`, so nothing downstream would catch it.\n */\n const rejected = new Set<string>();\n\n for (const instance of collection.instances) {\n const existing = nodes.get(instance.path);\n if (existing) {\n collisions.push({ path: instance.path, sources: [existing.source, collection.source] });\n rejected.add(instance.path);\n continue;\n }\n nodes.set(instance.path, {\n path: instance.path,\n kind,\n source: collection.source,\n policy: { kind, sitemap },\n instance: {\n title: instance.title,\n description: instance.description,\n publishedAt: instance.publishedAt,\n modifiedAt: instance.modifiedAt,\n },\n });\n }\n\n for (const edge of collection.edges ?? []) {\n if (rejected.has(edge.from)) continue;\n edges.push(edge);\n }\n}\n\n/**\n * Build the SEO graph from route declarations and content collections.\n *\n * Synchronous: the caller materializes its collections before calling, so there is\n * no async work here. Callers own the origin.\n */\nexport function buildSeoGraph(input: BuildSeoGraphInput): SeoGraph {\n const nodes = new Map<string, SeoNode>();\n const edges: Array<SeoEdge> = [];\n const collisions: Array<{ path: string; sources: ReadonlyArray<SeoSource> }> = [];\n\n walkRoutes(input.routeTree as unknown as WalkableRoute, \"/\", true, nodes, edges, []);\n\n for (const collection of input.collections ?? []) {\n addCollection(nodes, edges, collisions, collection);\n }\n\n for (const node of nodes.values()) {\n if (node.source !== \"route\") continue;\n for (const to of node.policy.related ?? []) {\n edges.push({ from: node.path, to, type: \"related\" });\n }\n if (node.policy.redirectTo !== undefined) {\n edges.push({ from: node.path, to: node.policy.redirectTo, type: \"redirect\" });\n }\n }\n\n return { nodes, edges, collisions };\n}\n","import type { AnyRoute, AnyRouter } from \"@tanstack/react-router\";\n\nimport type { RouteSeo } from \"./declare\";\n\ninterface RouteMaps {\n routesByPath: Record<string, AnyRoute | undefined>;\n routesById: Record<string, AnyRoute>;\n}\n\n/**\n * Resolve a route's declared `seo.link` card (title + description) by its full\n * path.\n *\n * `useRouter()` returns a Router typed to this app's exact route tree, so\n * `routesByPath` is keyed by the literal `FileRouteTypes[\"fullPaths\"]` union —\n * but callers here (declared `related` targets) hold arbitrary runtime path\n * strings, not that literal type. `routesByPath` and `routesById` are plain\n * Records on every Router instance regardless of which route tree it's\n * parameterized over, so this narrows to that structural shape once, at this\n * boundary, instead of threading an `AnyRoute` cast through every call site.\n */\nexport function resolveRouteLink(router: AnyRouter, path: string): RouteSeo[\"link\"] {\n const { routesByPath, routesById } = router as unknown as RouteMaps;\n\n const direct = routesByPath[path];\n if (direct) return direct.options.staticData?.seo?.link;\n\n const byFullPath = Object.values(routesById).find((route) => route.fullPath === path);\n return byFullPath?.options.staticData?.seo?.link;\n}\n"],"mappings":";;;AA4FA,MAAM,gBAAyB;;;;;;AAgB/B,SAAS,SAAS,QAAgB,KAAiC;CACjE,IAAI,QAAQ,KAAA,GAAW,OAAO;CAC9B,IAAI,QAAQ,KAAK,OAAO;CACxB,MAAM,UAAU,IAAI,QAAQ,QAAQ,EAAE,CAAC,CAAC,QAAQ,QAAQ,EAAE;CAE1D,OAAO,GADW,WAAW,MAAM,KAAK,OAAO,GAAG,UACpC,Q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AgB,iBAAiB,QAAmB,MAAgC;CAClF,MAAM,EAAE,cAAc,eAAe;CAErC,MAAM,SAAS,aAAa;CAC5B,IAAI,QAAQ,OAAO,OAAO,QAAQ,YAAY,KAAK;CAGnD,OADmB,OAAO,OAAO,UAAU,CAAC,CAAC,MAAM,UAAU,MAAM,aAAa,IAChE,CAAC,EAAE,QAAQ,YAAY,KAAK;AAC9C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/core/graph.ts","../src/core/projections.ts","../src/core/checks.ts","../src/core/inspect-html.ts","../src/core/resolve-route-link.ts"],"sourcesContent":["/**\n * SEO graph — the derived model that projections (sitemap, robots), the CLI, and\n * the check engine all read from. Built from route declarations (`staticData.seo`)\n * plus consumer-supplied content collections. This module is pure: no React, no\n * env, no knowledge of where instances come from. Origins and env-derived values\n * are injected by the callers of the projections, never read here.\n *\n * A node is one of:\n * - a structural route (`source: \"route\"`), keyed by its normalized full path,\n * merging a layout route's declaration (crumb) with its index child's (kind,\n * sitemap policy) when both resolve to the same URL;\n * - a content instance (`source` = the collection's label), keyed by the page URL\n * and carrying page-level metadata.\n *\n * Edges: `crumb-parent` (breadcrumb ancestry), `related` (deliberate cross-links),\n * `collection-member` (membership in a curated set), and `redirect` (route aliases).\n * The route walk emits crumb/related/redirect edges from declarations; a collection\n * may declare any additional edges its instances need.\n */\n\nimport type { AnyRoute } from \"@tanstack/react-router\";\n\nimport type { PublicPath, RouteSeo, SeoKind } from \"./declare\";\n\n/**\n * Where a node came from: `\"route\"` for a structural route declaration, or the\n * `source` label of the collection that produced the instance (e.g. \"blog\").\n */\nexport type SeoSource = string;\n\nexport interface SeoNode {\n /** Canonical path, no origin (e.g. \"/pricing\", \"/blog/my-post\"). */\n path: string;\n kind: SeoKind;\n source: SeoSource;\n /** Route-declared policy, or synthesized (kind + inherited sitemap) for instances. */\n policy: RouteSeo;\n instance?:\n | {\n title: string;\n description?: string | undefined;\n publishedAt?: string | undefined;\n modifiedAt?: string | undefined;\n }\n | undefined;\n}\n\nexport type SeoEdgeType = \"crumb-parent\" | \"related\" | \"redirect\" | \"collection-member\";\n\nexport interface SeoEdge {\n from: string;\n to: string;\n type: SeoEdgeType;\n}\n\nexport interface SeoGraph {\n nodes: Map<string, SeoNode>;\n edges: Array<SeoEdge>;\n /** Exact-path ownership conflicts encountered while assembling graph sources. */\n collisions?: ReadonlyArray<{ path: string; sources: ReadonlyArray<SeoSource> }> | undefined;\n}\n\n/** One concrete page produced by a collection. */\nexport interface SeoInstance {\n /** Canonical path of the page (e.g. \"/blog/my-post\"). */\n readonly path: string;\n readonly title: string;\n readonly description?: string | undefined;\n readonly publishedAt?: string | undefined;\n readonly modifiedAt?: string | undefined;\n}\n\nexport interface SeoCollection {\n /**\n * The param route these instances render through (e.g. \"/blog/$slug\"). Instances\n * inherit this route's declared policy (kind + sitemap) — the graph reads it from\n * the structural node, so declarations stay the single source of truth.\n */\n readonly route: PublicPath;\n /** The `source` stamped on every node this collection produces (e.g. \"blog\"). */\n readonly source: SeoSource;\n readonly instances: ReadonlyArray<SeoInstance>;\n /** Edges the collection declares between its instances and the rest of the graph. */\n readonly edges?: ReadonlyArray<SeoEdge> | undefined;\n}\n\nexport interface BuildSeoGraphInput {\n readonly routeTree: AnyRoute;\n readonly collections?: ReadonlyArray<SeoCollection> | undefined;\n}\n\n/** Kind for instances whose collection route carries no declaration to inherit. */\nconst FALLBACK_KIND: SeoKind = \"page\";\n\n/** Structural view of a route we walk — the fields present before router init(). */\ninterface WalkableRoute {\n readonly options: {\n readonly path?: string | undefined;\n readonly staticData?: { readonly seo?: RouteSeo | undefined } | undefined;\n };\n readonly children?: ReadonlyArray<WalkableRoute> | undefined;\n}\n\n/**\n * Join a child's local path onto its parent's computed full path with the same\n * semantics as TanStack's route init (relative segments, index \"/\" inherits the\n * parent, pathless/group routes are transparent), then normalize trailing slashes.\n */\nfunction joinPath(parent: string, seg: string | undefined): string {\n if (seg === undefined) return parent; // pathless layout / route group\n if (seg === \"/\") return parent; // index route resolves to its parent's URL\n const trimmed = seg.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n const joined = `${parent === \"/\" ? \"\" : parent}/${trimmed}`;\n return joined.replace(/\\/{2,}/g, \"/\");\n}\n\n/** Merge a route's declaration into an existing same-path node (deeper route wins). */\nfunction mergeSeo(base: RouteSeo, override: RouteSeo): RouteSeo {\n return {\n kind: override.kind,\n crumb: override.crumb ?? base.crumb,\n sitemap: override.sitemap ?? base.sitemap,\n robots: override.robots ?? base.robots,\n related: override.related ?? base.related,\n link: override.link ?? base.link,\n redirectTo: override.redirectTo ?? base.redirectTo,\n };\n}\n\n/**\n * Walk the route tree building structural nodes and crumb-parent edges. `crumbStack`\n * holds the paths of crumb-declaring ancestors so each crumb node links to its nearest\n * crumb ancestor down the real route-parent chain (matching render-time breadcrumbs).\n */\nfunction walkRoutes(\n route: WalkableRoute,\n parentPath: string,\n isRoot: boolean,\n nodes: Map<string, SeoNode>,\n edges: Array<SeoEdge>,\n crumbStack: Array<string>,\n): void {\n const path = isRoot ? \"/\" : joinPath(parentPath, route.options.path);\n const seo = route.options.staticData?.seo;\n\n if (seo) {\n const existing = nodes.get(path);\n if (existing) {\n existing.policy = mergeSeo(existing.policy, seo);\n existing.kind = existing.policy.kind;\n } else {\n nodes.set(path, { path, kind: seo.kind, source: \"route\", policy: { ...seo } });\n }\n\n const nearestCrumbAncestor = crumbStack[crumbStack.length - 1];\n if (seo.crumb !== undefined && nearestCrumbAncestor !== undefined) {\n edges.push({ from: path, to: nearestCrumbAncestor, type: \"crumb-parent\" });\n }\n }\n\n const pushedCrumb = seo?.crumb !== undefined;\n if (pushedCrumb) crumbStack.push(path);\n for (const child of route.children ?? []) {\n walkRoutes(child, path, false, nodes, edges, crumbStack);\n }\n if (pushedCrumb) crumbStack.pop();\n}\n\n/**\n * Add one collection's instance nodes, inheriting kind + sitemap policy from the\n * collection route's declaration, then append the edges it declares. A path already\n * owned by another node is a collision: the first owner keeps the path and the\n * conflict is reported (the `path-owner-collision` check turns it into a violation).\n */\nfunction addCollection(\n nodes: Map<string, SeoNode>,\n edges: Array<SeoEdge>,\n collisions: Array<{ path: string; sources: ReadonlyArray<SeoSource> }>,\n collection: SeoCollection,\n): void {\n const collectionNode = nodes.get(collection.route);\n const kind = collectionNode?.kind ?? FALLBACK_KIND;\n const sitemap = collectionNode?.policy.sitemap;\n\n /**\n * Paths this collection lost to an earlier owner. Their instances never enter\n * the graph, so any edge declared out of them would dangle — and the dead-edge\n * check only validates an edge's `to`, so nothing downstream would catch it.\n */\n const rejected = new Set<string>();\n\n for (const instance of collection.instances) {\n const existing = nodes.get(instance.path);\n if (existing) {\n collisions.push({ path: instance.path, sources: [existing.source, collection.source] });\n rejected.add(instance.path);\n continue;\n }\n nodes.set(instance.path, {\n path: instance.path,\n kind,\n source: collection.source,\n policy: { kind, sitemap },\n instance: {\n title: instance.title,\n description: instance.description,\n publishedAt: instance.publishedAt,\n modifiedAt: instance.modifiedAt,\n },\n });\n }\n\n for (const edge of collection.edges ?? []) {\n if (rejected.has(edge.from)) continue;\n edges.push(edge);\n }\n}\n\n/**\n * Build the SEO graph from route declarations and content collections.\n *\n * Synchronous: the caller materializes its collections before calling, so there is\n * no async work here. Callers own the origin.\n */\nexport function buildSeoGraph(input: BuildSeoGraphInput): SeoGraph {\n const nodes = new Map<string, SeoNode>();\n const edges: Array<SeoEdge> = [];\n const collisions: Array<{ path: string; sources: ReadonlyArray<SeoSource> }> = [];\n\n walkRoutes(input.routeTree as unknown as WalkableRoute, \"/\", true, nodes, edges, []);\n\n for (const collection of input.collections ?? []) {\n addCollection(nodes, edges, collisions, collection);\n }\n\n for (const node of nodes.values()) {\n if (node.source !== \"route\") continue;\n for (const to of node.policy.related ?? []) {\n edges.push({ from: node.path, to, type: \"related\" });\n }\n if (node.policy.redirectTo !== undefined) {\n edges.push({ from: node.path, to: node.policy.redirectTo, type: \"redirect\" });\n }\n }\n\n return { nodes, edges, collisions };\n}\n","/**\n * Projections of the SEO graph: sitemap.xml, robots.txt, and single-node\n * inspection. Pure functions — the origin, the host's indexability, and the\n * robots disallow list are injected by the caller, never read from the\n * environment or a generated file.\n */\n\nimport type { SeoEdge, SeoGraph, SeoNode } from \"./graph\";\n\nexport interface ProjectionConfig {\n origin: string;\n indexable: boolean;\n}\n\nexport interface RobotsConfig extends ProjectionConfig {\n /** Path prefixes to disallow on an indexable host (e.g. the app-only groups). */\n disallow: ReadonlyArray<string>;\n /**\n * Origin-wide Content-Signal preferences\n * (https://contentsignals.org/), emitted as `Content-Signal: <value>` under\n * `User-agent: *` on an indexable host. Omit for none. The plugin never\n * invents a default — pass the policy you want, e.g.\n * `\"search=yes, ai-input=yes, ai-train=yes\"`.\n */\n contentSignal?: string | undefined;\n /**\n * Extra full lines in the indexable `User-agent: *` group, after\n * Content-Signal (if any) and before Allow/Disallow. Use for directives the\n * plugin does not model, or to compose {@link contentSignal} yourself.\n */\n directives?: ReadonlyArray<string> | undefined;\n /**\n * Last-mile override: receives the rendered robots.txt and returns the file\n * to emit. Runs for indexable and preview hosts. Use when you need to wrap\n * or replace the default body rather than add group lines.\n */\n transform?: ((robots: string) => string) | undefined;\n}\n\nexport interface NodeReport {\n node: SeoNode;\n inSitemap: boolean;\n incoming: Array<SeoEdge>;\n outgoing: Array<SeoEdge>;\n}\n\nconst escapeXml = (value: string): string =>\n value\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n\n/**\n * A node belongs in the sitemap when it declares a positive sitemap policy, is not\n * a redirect, is not robots-noindexed, and is not a param template (a route whose\n * path still contains a `$` segment — those exist only so their instances inherit).\n */\nfunction isSitemapEligible(node: SeoNode): boolean {\n if (node.policy.redirectTo !== undefined) return false;\n if (node.policy.robots?.includes(\"noindex\")) return false;\n if (!node.policy.sitemap) return false; // false or absent\n if (node.path.includes(\"$\")) return false;\n return true;\n}\n\n/** Canonical absolute URL for a node under the given origin. */\nfunction urlForNode(origin: string, node: SeoNode): string {\n return node.path === \"/\" ? origin : `${origin}${node.path}`;\n}\n\n/**\n * Instance lastmod: the most recent date the page's frontmatter carries. A\n * collection whose instances carry no dates (docs, a manifest-driven gallery)\n * emits no `<lastmod>` at all.\n */\nfunction instanceLastmod(node: SeoNode): string | undefined {\n const instance = node.instance;\n if (!instance) return undefined;\n const date = instance.modifiedAt ?? instance.publishedAt;\n return date ? new Date(date).toISOString() : undefined;\n}\n\nfunction renderUrlEntry(url: string, lastmod: string | undefined, node: SeoNode): string {\n const sitemap = node.policy.sitemap;\n // isSitemapEligible guarantees a positive policy before this runs.\n const { changeFrequency, priority } = sitemap as { changeFrequency: string; priority: number };\n const lines = [` <url>`, ` <loc>${escapeXml(url)}</loc>`];\n if (lastmod) lines.push(` <lastmod>${lastmod}</lastmod>`);\n lines.push(\n ` <changefreq>${changeFrequency}</changefreq>`,\n ` <priority>${priority.toFixed(1)}</priority>`,\n ` </url>`,\n );\n return lines.join(\"\\n\");\n}\n\n/**\n * Render sitemap.xml from the graph. Structural route entries emit no `<lastmod>`\n * (a route has no publish date); content instances emit it from their frontmatter.\n * Route entries are sorted by path, then instances follow in collection order.\n * `indexable` is intentionally unused — the sitemap body is host-independent;\n * robots.txt is what gates crawling.\n */\nexport function renderSitemap(graph: SeoGraph, cfg: ProjectionConfig): string {\n const nodes = [...graph.nodes.values()];\n const staticNodes = nodes\n .filter((node) => node.source === \"route\" && isSitemapEligible(node))\n .sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));\n const instanceNodes = nodes.filter((node) => node.source !== \"route\" && isSitemapEligible(node));\n\n const seen = new Set<string>();\n const entries: Array<string> = [];\n for (const node of [...staticNodes, ...instanceNodes]) {\n const url = urlForNode(cfg.origin, node);\n const key = url.toLowerCase().replace(/\\/$/, \"\");\n if (seen.has(key)) continue;\n seen.add(key);\n entries.push(renderUrlEntry(url, instanceLastmod(node), node));\n }\n\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\\n${entries.join(\n \"\\n\",\n )}\\n</urlset>\\n`;\n}\n\n/** Format a Content-Signal robots.txt directive from the preference list. */\nexport function contentSignal(value: string): string {\n return `Content-Signal: ${value}`;\n}\n\nconst groupLines = (cfg: RobotsConfig): Array<string> => {\n const lines: Array<string> = [];\n if (cfg.contentSignal !== undefined && cfg.contentSignal !== \"\") {\n lines.push(contentSignal(cfg.contentSignal));\n }\n for (const directive of cfg.directives ?? []) {\n if (directive !== \"\") lines.push(directive);\n }\n return lines;\n};\n\n/**\n * Render robots.txt. A non-indexable host (previews) gets a disallow-all\n * with no Sitemap line; an indexable host disallows exactly the prefixes the caller\n * passes. Pages that declare `robots: noindex` are intentionally NOT added as\n * Disallow entries — a Disallow would stop crawlers reaching the page to read its\n * `noindex, follow` meta, so the graph's per-node robots policy never feeds this\n * list. `graph` is unused — kept for signature parity with the other projections,\n * which callers load the graph once for and pass to each.\n *\n * Origin-wide group directives (`contentSignal`, `directives`) are indexable-host\n * only. {@link RobotsConfig.transform} always runs last so a consumer can override\n * the whole file.\n */\nexport function renderRobots(_graph: SeoGraph, cfg: RobotsConfig): string {\n const rendered = cfg.indexable\n ? [\n \"User-agent: *\",\n ...groupLines(cfg),\n \"Allow: /\",\n ...cfg.disallow.map((path) => `Disallow: ${path}`),\n \"\",\n `Sitemap: ${cfg.origin}/sitemap.xml`,\n `Host: ${cfg.origin}`,\n \"\",\n ].join(\"\\n\")\n : [\"User-agent: *\", \"Disallow: /\", \"\"].join(\"\\n\");\n return cfg.transform === undefined ? rendered : cfg.transform(rendered);\n}\n\n/** Inspect a single node: its declaration, sitemap eligibility, and edges. */\nexport function inspectNode(graph: SeoGraph, path: string): NodeReport | undefined {\n const node = graph.nodes.get(path);\n if (!node) return undefined;\n return {\n node,\n inSitemap: isSitemapEligible(node),\n incoming: graph.edges.filter((edge) => edge.to === path),\n outgoing: graph.edges.filter((edge) => edge.from === path),\n };\n}\n","/**\n * The SEO check engine: a set of rules run against the derived {@link SeoGraph}.\n * Pure — no I/O, no `clientEnv`, no React. The CLI's `pagegraph check` command and the\n * vitest suite both call {@link checkGraph}; nothing else derives correctness.\n *\n * Two severities, mapped to the CLI's exit contract:\n * - `structural` — a declaration is internally broken (a link points nowhere, a\n * card would render empty, a page contradicts its own robots/sitemap intent).\n * Any structural violation fails `pagegraph check` (exit 1); these must not ship.\n * - `editorial` — a quality smell (duplicate or mis-sized titles/descriptions).\n * Reported as warnings; `pagegraph check` still exits 0 when only these are present.\n *\n * The graph only knows what declarations and frontmatter carry, so the rules are\n * scoped to that: per-node title/description live only on collection *instances*,\n * never on structural route nodes (whose head tags are composed at render time and\n * are not in the graph). Rules are data-driven and listed once in\n * {@link CHECK_RULES}.\n */\n\nimport type { SitemapPolicy } from \"./declare\";\nimport type { SeoGraph, SeoNode } from \"./graph\";\n\nexport type Severity = \"structural\" | \"editorial\";\n\nexport interface Violation {\n severity: Severity;\n rule: string;\n path?: string | undefined;\n message: string;\n fix?: string | undefined;\n}\n\n/** A single finding before its rule's `severity`/`rule` name are attached. */\ninterface RawViolation {\n path?: string | undefined;\n message: string;\n fix?: string | undefined;\n}\n\ninterface CheckRule {\n readonly name: string;\n readonly severity: Severity;\n readonly evaluate: (graph: SeoGraph) => ReadonlyArray<RawViolation>;\n}\n\n/** A positive sitemap policy — the author asked for this page to be indexed. */\nconst hasPositiveSitemap = (sitemap: SitemapPolicy | false | undefined): sitemap is SitemapPolicy =>\n sitemap !== undefined && sitemap !== false;\n\n/** Content and manifest instances carry page-level title/description. */\nconst isInstance = (node: SeoNode): boolean => node.source !== \"route\";\n\n/** Group instance nodes by a present, non-empty string field for duplicate detection. */\nconst groupInstancesBy = (\n graph: SeoGraph,\n field: (node: SeoNode) => string | undefined,\n): Map<string, Array<SeoNode>> => {\n const groups = new Map<string, Array<SeoNode>>();\n for (const node of graph.nodes.values()) {\n if (!isInstance(node)) continue;\n const value = field(node)?.trim();\n if (!value) continue;\n const bucket = groups.get(value);\n if (bucket) bucket.push(node);\n else groups.set(value, [node]);\n }\n return groups;\n};\n\nconst DESCRIPTION_MAX = 160;\nconst DESCRIPTION_MIN = 50;\n\n/**\n * Every check, in one place. `checkGraph` runs them in order and stamps each\n * finding with its rule name and severity, so the output is grouped by rule and\n * deterministic (nodes iterate in graph insertion order, edges in array order).\n */\nconst CHECK_RULES: ReadonlyArray<CheckRule> = [\n {\n name: \"path-owner-collision\",\n severity: \"structural\",\n evaluate: (graph) =>\n (graph.collisions ?? []).map((collision) => ({\n path: collision.path,\n message: `Canonical path \"${collision.path}\" is owned by multiple sources: ${collision.sources.join(\", \")}.`,\n fix: \"Give every concrete page one canonical path and one graph owner.\",\n })),\n },\n {\n name: \"canonical-path-collision\",\n severity: \"structural\",\n evaluate: (graph) => {\n const groups = new Map<string, Array<string>>();\n for (const path of graph.nodes.keys()) {\n const canonical = path.toLowerCase().replace(/\\/$/, \"\") || \"/\";\n const paths = groups.get(canonical);\n if (paths) paths.push(path);\n else groups.set(canonical, [path]);\n }\n return [...groups.values()]\n .filter((paths) => paths.length > 1)\n .flatMap((paths) =>\n paths.map((path) => ({\n path,\n message: `Canonical path collides with ${paths.filter((candidate) => candidate !== path).join(\", \")}.`,\n fix: \"Use one lowercase, trailing-slash-normalized canonical path.\",\n })),\n );\n },\n },\n {\n name: \"self-edge\",\n severity: \"structural\",\n evaluate: (graph) =>\n graph.edges\n .filter((edge) => edge.from === edge.to)\n .map((edge) => ({\n path: edge.from,\n message: `${edge.type} edge points back to its own source node.`,\n fix: \"Remove the self-reference from the canonical manifest or route declaration.\",\n })),\n },\n {\n name: \"duplicate-edge\",\n severity: \"structural\",\n evaluate: (graph) => {\n const seen = new Set<string>();\n const duplicates: Array<RawViolation> = [];\n for (const edge of graph.edges) {\n const key = `${edge.from}\\u0000${edge.to}\\u0000${edge.type}`;\n if (seen.has(key)) {\n duplicates.push({\n path: edge.from,\n message: `Duplicate ${edge.type} edge from \"${edge.from}\" to \"${edge.to}\".`,\n fix: \"Declare each graph relationship exactly once.\",\n });\n } else {\n seen.add(key);\n }\n }\n return duplicates;\n },\n },\n {\n // A `related` or `redirect` edge points at a path with no node — the target\n // route/page was renamed or deleted and the declaration wasn't updated.\n name: \"dead-edge\",\n severity: \"structural\",\n evaluate: (graph) =>\n graph.edges\n .filter((edge) => edge.type !== \"crumb-parent\" && !graph.nodes.has(edge.to))\n .map((edge) => ({\n path: edge.from,\n message: `${edge.type} edge from \"${edge.from}\" points at \"${edge.to}\", which is not a node in the graph.`,\n fix: `Update the ${edge.type === \"redirect\" ? \"redirectTo\" : \"related\"} target on the \"${edge.from}\" route, or restore \"${edge.to}\".`,\n })),\n },\n {\n // A content instance with no usable title can't render a legible <title> or card.\n name: \"instance-missing-title\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()]\n .filter((node) => isInstance(node) && !node.instance?.title.trim())\n .map((node) => ({\n path: node.path,\n message: `Content page \"${node.path}\" has no title.`,\n fix: \"Add a `title` to the page frontmatter.\",\n })),\n },\n {\n // The declaration asks for the page to be in the sitemap yet also marks it\n // noindex — contradictory intent. The projection resolves it (noindex wins,\n // excluded), but the declaration should say one thing.\n name: \"sitemap-noindex-contradiction\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()]\n .filter(\n (node) =>\n hasPositiveSitemap(node.policy.sitemap) &&\n node.policy.robots?.toLowerCase().includes(\"noindex\"),\n )\n .map((node) => ({\n path: node.path,\n message: `\"${node.path}\" declares a sitemap policy but its robots value is \"${node.policy.robots}\".`,\n fix: \"Drop the sitemap policy (or set `sitemap: false`) on a noindex page, or remove the noindex robots value.\",\n })),\n },\n {\n // Robots declarations are house-convention lowercase: the sitemap projection\n // matches `includes(\"noindex\")` literally, so a miscased value (\"Noindex\")\n // would silently stay sitemap-eligible. This gate makes that unrepresentable.\n name: \"robots-not-lowercase\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()]\n .filter(\n (node) =>\n node.policy.robots !== undefined &&\n node.policy.robots !== node.policy.robots.toLowerCase(),\n )\n .map((node) => ({\n path: node.path,\n message: `\"${node.path}\" declares robots \"${node.policy.robots}\" — robots values must be lowercase.`,\n fix: 'Lowercase the robots declaration (e.g. \"noindex, follow\").',\n })),\n },\n {\n // A `related` card for a route target renders from that route's `link`\n // metadata; without it the card has no title/description and renders empty.\n // (Content-instance targets render from their frontmatter, so they're exempt.)\n name: \"related-target-missing-link\",\n severity: \"structural\",\n evaluate: (graph) => {\n const linklessTargets = new Set<string>();\n for (const edge of graph.edges) {\n if (edge.type !== \"related\") continue;\n const target = graph.nodes.get(edge.to);\n if (target && target.source === \"route\" && target.policy.link === undefined) {\n linklessTargets.add(edge.to);\n }\n }\n return [...linklessTargets].map((path) => ({\n path,\n message: `Route \"${path}\" is a related-link target but declares no link metadata; its card would render empty.`,\n fix: `Add \\`link: { title, description }\\` to the \"${path}\" route's staticData.seo.`,\n }));\n },\n },\n {\n // A redirect/alias node should never advertise itself in the sitemap.\n name: \"redirect-in-sitemap\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()]\n .filter(\n (node) => node.policy.redirectTo !== undefined && hasPositiveSitemap(node.policy.sitemap),\n )\n .map((node) => ({\n path: node.path,\n message: `Redirect \"${node.path}\" (→ \"${node.policy.redirectTo}\") also declares a sitemap policy.`,\n fix: \"Remove the sitemap policy from the redirect route; only its target belongs in the sitemap.\",\n })),\n },\n {\n name: \"duplicate-title\",\n severity: \"editorial\",\n evaluate: (graph) =>\n [...groupInstancesBy(graph, (node) => node.instance?.title).entries()]\n .filter(([, nodes]) => nodes.length > 1)\n .flatMap(([title, nodes]) =>\n nodes.map((node) => ({\n path: node.path,\n message: `Title \"${title}\" is shared by ${nodes.length} pages.`,\n fix: \"Give each page a distinct title.\",\n })),\n ),\n },\n {\n name: \"duplicate-description\",\n severity: \"editorial\",\n evaluate: (graph) =>\n [...groupInstancesBy(graph, (node) => node.instance?.description).entries()]\n .filter(([, nodes]) => nodes.length > 1)\n .flatMap(([, nodes]) =>\n nodes.map((node) => ({\n path: node.path,\n message: `Description is shared by ${nodes.length} pages.`,\n fix: \"Write a distinct meta description for each page.\",\n })),\n ),\n },\n {\n // Meta descriptions outside ~50–160 chars either get truncated in SERPs or\n // read as too thin.\n name: \"description-length\",\n severity: \"editorial\",\n evaluate: (graph) =>\n [...graph.nodes.values()].flatMap((node) => {\n if (!isInstance(node)) return [];\n const description = node.instance?.description?.trim();\n if (!description) return [];\n if (description.length > DESCRIPTION_MAX) {\n return [\n {\n path: node.path,\n message: `Description is ${description.length} chars (max ${DESCRIPTION_MAX}); it will be truncated in results.`,\n fix: `Trim the description to ${DESCRIPTION_MAX} characters or fewer.`,\n },\n ];\n }\n if (description.length < DESCRIPTION_MIN) {\n return [\n {\n path: node.path,\n message: `Description is ${description.length} chars (min ${DESCRIPTION_MIN}); it reads as thin.`,\n fix: `Expand the description to at least ${DESCRIPTION_MIN} characters.`,\n },\n ];\n }\n return [];\n }),\n },\n];\n\n/** Run every rule against the graph and return the flat list of violations. */\nexport function checkGraph(graph: SeoGraph): Array<Violation> {\n return CHECK_RULES.flatMap((rule) =>\n rule.evaluate(graph).map((raw) => ({\n severity: rule.severity,\n rule: rule.name,\n path: raw.path,\n message: raw.message,\n fix: raw.fix,\n })),\n );\n}\n\n/** Structural violations fail `pagegraph check`; editorial-only stays green. */\nexport const hasStructuralViolations = (violations: ReadonlyArray<Violation>): boolean =>\n violations.some((violation) => violation.severity === \"structural\");\n","/**\n * Read a rendered `<head>` and validate it: title, meta\n * (description/robots/og/twitter), canonical link, and `application/ld+json`\n * blocks, with a minimal per-type JSON-LD check.\n *\n * This is the pure half of `pagegraph inspect --live` — the half worth having on its\n * own. The CLI fetches a URL and hands the body here; a test suite can render a\n * page and hand *that* here, asserting the head it actually ships. Both get the\n * same verdict, because it is the same function.\n *\n * No HTML-parsing dependency, by design: a `<head>` is small and well-formed, so\n * string/regex scanning is enough, and the package's core stays zero-dependency\n * (which is also why the object guard below is hand-rolled — `effect/Predicate`\n * is not reachable from this entry). It is honest about its limits: it does not\n * build a DOM, so exotic markup (commented-out tags, CDATA, attributes spanning\n * constructs) is out of scope. This validates *rendered output*, not arbitrary\n * HTML.\n *\n * `issues` are blocking: a non-empty list makes `pagegraph inspect --live` exit 1.\n * Required tags are `<title>`, `meta[name=description]`, and\n * `link[rel=canonical]`; any JSON-LD that fails to parse or fails its minimal\n * schema is also blocking.\n */\n\nexport interface JsonLdReport {\n type: string;\n valid: boolean;\n errors: Array<string>;\n}\n\nexport interface LiveHeadReport {\n url: string;\n status: number;\n title?: string | undefined;\n description?: string | undefined;\n canonical?: string | undefined;\n robots?: string | undefined;\n og: Record<string, string>;\n twitter: Record<string, string>;\n jsonLd: Array<JsonLdReport>;\n issues: Array<string>;\n}\n\nconst ENTITIES: Record<string, string> = {\n \"&\": \"&\",\n \"<\": \"<\",\n \">\": \">\",\n \""\": '\"',\n \"'\": \"'\",\n \"'\": \"'\",\n};\n\nconst decodeEntities = (value: string): string =>\n value.replace(/&(?:amp|lt|gt|quot|#39|apos);/g, (match) => ENTITIES[match] ?? match);\n\n/** Pull double/single-quoted attributes off a single tag string. */\nconst parseAttrs = (tag: string): Record<string, string> => {\n const attrs: Record<string, string> = {};\n const re = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)')/g;\n let match: RegExpExecArray | null;\n while ((match = re.exec(tag)) !== null) {\n attrs[match[1]!.toLowerCase()] = decodeEntities(match[2] ?? match[3] ?? \"\");\n }\n return attrs;\n};\n\n/** Normalize a JSON-LD `@type` (string or array) to a single readable label. */\nconst typeName = (value: unknown): string => {\n if (typeof value === \"string\") return value;\n if (Array.isArray(value))\n return value.filter((v) => typeof v === \"string\").join(\", \") || \"unknown\";\n return \"unknown\";\n};\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n // NOTE: This zero-dependency core entry cannot import Effect; JSON-LD validation happens immediately after this shallow narrowing.\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/** Flatten a parsed JSON-LD payload (single object, array, or `@graph`) to items. */\nconst collectItems = (parsed: unknown): Array<Record<string, unknown>> => {\n if (Array.isArray(parsed)) return parsed.filter(isObject);\n if (isObject(parsed)) {\n if (Array.isArray(parsed[\"@graph\"])) return parsed[\"@graph\"].filter(isObject);\n return [parsed];\n }\n return [];\n};\n\nconst countQuestions = (mainEntity: unknown): number => {\n if (!Array.isArray(mainEntity)) return 0;\n return mainEntity.filter((entry) => isObject(entry) && typeName(entry[\"@type\"]) === \"Question\")\n .length;\n};\n\nconst validateItemListElements = (value: unknown): Array<string> => {\n if (!Array.isArray(value) || value.length < 1) {\n return [\"ItemList needs at least one `itemListElement` entry.\"];\n }\n const errors: Array<string> = [];\n value.forEach((entry, index) => {\n if (!isObject(entry) || typeName(entry[\"@type\"]) !== \"ListItem\") {\n errors.push(`ItemList entry ${index + 1} is not a ListItem.`);\n return;\n }\n if (entry[\"position\"] !== index + 1) {\n errors.push(`ItemList entry ${index + 1} has an invalid position.`);\n }\n if (!entry[\"name\"] || !entry[\"url\"]) {\n errors.push(`ItemList entry ${index + 1} needs a name and URL.`);\n }\n });\n return errors;\n};\n\n/** Minimal per-type validation — enough to catch an empty or malformed block. */\nconst validateItem = (item: Record<string, unknown>): JsonLdReport => {\n const type = typeName(item[\"@type\"]);\n const errors: Array<string> = [];\n\n if (type === \"Article\" || type === \"NewsArticle\" || type === \"BlogPosting\") {\n if (!item[\"headline\"]) errors.push(\"Article is missing `headline`.\");\n if (!item[\"datePublished\"]) errors.push(\"Article is missing `datePublished`.\");\n } else if (type === \"FAQPage\") {\n if (countQuestions(item[\"mainEntity\"]) < 1) {\n errors.push(\"FAQPage needs at least one Question in `mainEntity`.\");\n }\n } else if (type === \"BreadcrumbList\") {\n const items = item[\"itemListElement\"];\n if (!Array.isArray(items) || items.length < 2) {\n errors.push(\"BreadcrumbList needs at least two `itemListElement` entries.\");\n }\n } else if (type === \"ItemList\") {\n errors.push(...validateItemListElements(item[\"itemListElement\"]));\n const items = item[\"itemListElement\"];\n if (Array.isArray(items) && item[\"numberOfItems\"] !== items.length) {\n errors.push(\"ItemList `numberOfItems` does not match its entries.\");\n }\n }\n\n return { type, valid: errors.length === 0, errors };\n};\n\nconst validateLdJson = (raw: string): Array<JsonLdReport> => {\n let parsed: unknown;\n // NOTE: JSON.parse boundary: converts the native parse throw into an unparseable JsonLdReport value in a pure sync validator\n try {\n parsed = JSON.parse(raw);\n } catch (cause) {\n return [\n {\n type: \"unparseable\",\n valid: false,\n errors: [`JSON parse error: ${cause instanceof Error ? cause.message : String(cause)}`],\n },\n ];\n }\n const items = collectItems(parsed);\n if (items.length === 0) {\n return [{ type: \"unknown\", valid: false, errors: [\"No JSON-LD object found in block.\"] }];\n }\n return items.map(validateItem);\n};\n\n/** Parse a rendered HTML document's `<head>` into a report. Pure. */\nexport const inspectHtml = (url: string, status: number, html: string): LiveHeadReport => {\n const headMatch = html.match(/<head[^>]*>([\\s\\S]*?)<\\/head>/i);\n const head = headMatch ? headMatch[1]! : html;\n\n const titleMatch = head.match(/<title[^>]*>([\\s\\S]*?)<\\/title>/i);\n const title = titleMatch ? decodeEntities(titleMatch[1]!.trim()) : undefined;\n\n const og: Record<string, string> = {};\n const twitter: Record<string, string> = {};\n let description: string | undefined;\n let robots: string | undefined;\n\n for (const tag of head.match(/<meta\\b[^>]*>/gi) ?? []) {\n const attrs = parseAttrs(tag);\n const content = attrs[\"content\"];\n if (content === undefined) continue;\n const property = attrs[\"property\"];\n const name = attrs[\"name\"];\n if (property?.startsWith(\"og:\")) og[property] = content;\n else if (name?.startsWith(\"twitter:\")) twitter[name] = content;\n else if (name === \"description\") description = content;\n else if (name === \"robots\") robots = content;\n }\n\n let canonical: string | undefined;\n for (const tag of head.match(/<link\\b[^>]*>/gi) ?? []) {\n const attrs = parseAttrs(tag);\n if (attrs[\"rel\"] === \"canonical\") canonical = attrs[\"href\"];\n }\n\n const jsonLd: Array<JsonLdReport> = [];\n const scriptRe = /<script\\b[^>]*type=[\"']application\\/ld\\+json[\"'][^>]*>([\\s\\S]*?)<\\/script>/gi;\n let scriptMatch: RegExpExecArray | null;\n while ((scriptMatch = scriptRe.exec(head)) !== null) {\n jsonLd.push(...validateLdJson(scriptMatch[1]!.trim()));\n }\n\n const issues: Array<string> = [];\n if (status >= 400) issues.push(`Fetch returned HTTP ${status}.`);\n if (!title) issues.push(\"Missing <title>.\");\n if (!description) issues.push(\"Missing meta description.\");\n if (!canonical) issues.push(\"Missing canonical link.\");\n for (const block of jsonLd) {\n if (!block.valid)\n issues.push(...block.errors.map((error) => `JSON-LD (${block.type}): ${error}`));\n }\n\n return { url, status, title, description, canonical, robots, og, twitter, jsonLd, issues };\n};\n\n/** A non-empty `issues` list fails `pagegraph inspect --live` (exit 1). */\nexport const hasBlockingIssues = (report: LiveHeadReport): boolean => report.issues.length > 0;\n","import type { AnyRoute, AnyRouter } from \"@tanstack/react-router\";\n\nimport type { RouteSeo } from \"./declare\";\n\ninterface RouteMaps {\n routesByPath: Record<string, AnyRoute | undefined>;\n routesById: Record<string, AnyRoute>;\n}\n\n/**\n * Resolve a route's declared `seo.link` card (title + description) by its full\n * path.\n *\n * `useRouter()` returns a Router typed to this app's exact route tree, so\n * `routesByPath` is keyed by the literal `FileRouteTypes[\"fullPaths\"]` union —\n * but callers here (declared `related` targets) hold arbitrary runtime path\n * strings, not that literal type. `routesByPath` and `routesById` are plain\n * Records on every Router instance regardless of which route tree it's\n * parameterized over, so this narrows to that structural shape once, at this\n * boundary, instead of threading an `AnyRoute` cast through every call site.\n */\nexport function resolveRouteLink(router: AnyRouter, path: string): RouteSeo[\"link\"] {\n const { routesByPath, routesById } = router as unknown as RouteMaps;\n\n const direct = routesByPath[path];\n if (direct) return direct.options.staticData?.seo?.link;\n\n const byFullPath = Object.values(routesById).find((route) => route.fullPath === path);\n return byFullPath?.options.staticData?.seo?.link;\n}\n"],"mappings":";;AA4FA,MAAM,gBAAyB;;;;;;AAgB/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O,CAAC;CAGnF,OAAO;EAAE;EAAK;EAAQ;EAAO;EAAa;EAAW;EAAQ;EAAI;EAAS;EAAQ;CAAO;AAC3F;;AAGA,MAAa,qBAAqB,WAAoC,OAAO,OAAO,SAAS;;;;;;;;;;;;;;;AClM7F,SAAgB,iBAAiB,QAAmB,MAAgC;CAClF,MAAM,EAAE,cAAc,eAAe;CAErC,MAAM,SAAS,aAAa;CAC5B,IAAI,QAAQ,OAAO,OAAO,QAAQ,YAAY,KAAK;CAGnD,OADmB,OAAO,OAAO,UAAU,CAAC,CAAC,MAAM,UAAU,MAAM,aAAa,IAChE,CAAC,EAAE,QAAQ,YAAY,KAAK;AAC9C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pagegraph",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Route-declared SEO graph and audit toolkit for TanStack Start: sitemap/robots, React head, JSON-LD, Vite coverage gate, live audit, and Jev-backed link decisions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"seo",
|