sanity-plugin-seo-copilot 0.2.13 → 0.2.15
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/index.js +1283 -883
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1254 -854
- package/dist/index.mjs.map +1 -1
- package/package.json +64 -61
- package/src/components/KeywordPanel.tsx +4 -3
- package/src/components/ReportProblemButton.tsx +212 -0
- package/src/components/SEOCopilotPanel.tsx +8 -0
- package/src/components/tabs/AEOTab.tsx +2 -0
- package/src/components/tabs/LinkingTab.tsx +39 -13
- package/src/components/tabs/MetaTab.tsx +122 -24
- package/src/components/tabs/SummaryTab.tsx +21 -15
- package/src/components/tabs/TechnicalTab.tsx +276 -269
- package/src/index.ts +18 -16
- package/src/lib/api.ts +30 -12
- package/src/lib/apiKey.ts +30 -0
- package/src/lib/documentExtract.ts +168 -14
- package/src/lib/scoring.ts +4 -4
- package/src/lib/summary.ts +22 -13
- package/src/lib/types.ts +12 -0
|
@@ -329,9 +329,15 @@ function imageTitleAudit(titles: string[], imageCount: number): TechnicalAuditIt
|
|
|
329
329
|
};
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
// Audits the body's heading structure: density (H2s per word count),
|
|
333
|
-
// heading
|
|
334
|
-
function computeHeadingStructureAudits(
|
|
332
|
+
// Audits the body's heading structure: density (H2s per word count), heading-level
|
|
333
|
+
// skips, empty heading blocks, and whether a target keyword appears in a subheading.
|
|
334
|
+
function computeHeadingStructureAudits(
|
|
335
|
+
headings: HeadingItem[],
|
|
336
|
+
wordCount: number,
|
|
337
|
+
primaryKeyword?: string,
|
|
338
|
+
secondaryKeyword?: string,
|
|
339
|
+
unstyledHeadings?: string[]
|
|
340
|
+
): TechnicalAuditItem[] {
|
|
335
341
|
const audits: TechnicalAuditItem[] = [];
|
|
336
342
|
// Count H2 AND H3 as section headings: an article sectioned only with H3s is
|
|
337
343
|
// still sectioned, so it shouldn't be told it has "no section headings".
|
|
@@ -371,6 +377,19 @@ function computeHeadingStructureAudits(headings: HeadingItem[], wordCount: numbe
|
|
|
371
377
|
densityFired = true;
|
|
372
378
|
}
|
|
373
379
|
|
|
380
|
+
// Lines that look like section headings but were typed as plain text (not styled as H2).
|
|
381
|
+
// Surfaced before the no-headings early-return so it fires exactly when it's most useful.
|
|
382
|
+
if (unstyledHeadings && unstyledHeadings.length > 0) {
|
|
383
|
+
const n = unstyledHeadings.length;
|
|
384
|
+
const examples = unstyledHeadings.slice(0, 2).map((t) => `"${t}"`).join(", ");
|
|
385
|
+
audits.push({
|
|
386
|
+
label: "Looks Like a Heading",
|
|
387
|
+
value: `${n} line${n === 1 ? "" : "s"} read${n === 1 ? "s" : ""} like a heading but ${n === 1 ? "isn't" : "aren't"} styled`,
|
|
388
|
+
status: "warning",
|
|
389
|
+
recommendation: `${examples}${n > 2 ? ", and more," : ""} ${n === 1 ? "looks" : "look"} like a section heading typed as plain text. In Sanity, select the line and apply the "Heading 2" style so it counts as a real heading.`,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
|
|
374
393
|
// If the body has no headings at all and density didn't already flag it (short article),
|
|
375
394
|
// surface a generic structure note so the editor still sees a hint.
|
|
376
395
|
if (headings.length === 0) {
|
|
@@ -379,22 +398,14 @@ function computeHeadingStructureAudits(headings: HeadingItem[], wordCount: numbe
|
|
|
379
398
|
label: "Heading Structure",
|
|
380
399
|
value: "No headings in body",
|
|
381
400
|
status: "warning",
|
|
382
|
-
recommendation: "
|
|
401
|
+
recommendation: "Consider adding H2-H6 subheadings to structure the article into scannable sections.",
|
|
383
402
|
});
|
|
384
403
|
}
|
|
385
404
|
return audits;
|
|
386
405
|
}
|
|
387
406
|
|
|
388
|
-
// H1
|
|
389
|
-
|
|
390
|
-
if (h1s.length > 0) {
|
|
391
|
-
audits.push({
|
|
392
|
-
label: "H1 in body",
|
|
393
|
-
value: `${h1s.length} H1 heading${h1s.length === 1 ? "" : "s"} in the body`,
|
|
394
|
-
status: "warning",
|
|
395
|
-
recommendation: "The article title is your H1. Body headings should start at H2 so the outline isn't ambiguous.",
|
|
396
|
-
});
|
|
397
|
-
}
|
|
407
|
+
// (No "H1 in body" warning. The article title IS the page H1, and the Heading Outline
|
|
408
|
+
// below now shows it explicitly - so a stray body H1 is displayed there, not scolded.)
|
|
398
409
|
|
|
399
410
|
// Skipped levels (e.g. H2 followed by H4 with no H3 between them).
|
|
400
411
|
let prevLevel = 0;
|
|
@@ -426,7 +437,7 @@ function computeHeadingStructureAudits(headings: HeadingItem[], wordCount: numbe
|
|
|
426
437
|
});
|
|
427
438
|
}
|
|
428
439
|
|
|
429
|
-
// Clean bill of health.
|
|
440
|
+
// Clean structural bill of health (density + hierarchy + empties all passed).
|
|
430
441
|
if (audits.length === 0) {
|
|
431
442
|
audits.push({
|
|
432
443
|
label: "Heading Structure",
|
|
@@ -435,11 +446,49 @@ function computeHeadingStructureAudits(headings: HeadingItem[], wordCount: numbe
|
|
|
435
446
|
});
|
|
436
447
|
}
|
|
437
448
|
|
|
449
|
+
// Keyword-in-headings nudge (separate from structural health). Reinforce relevance by
|
|
450
|
+
// working the primary and/or secondary keyword into at least one subheading. Only fires
|
|
451
|
+
// when subheadings actually exist - otherwise the "no headings" / density notes cover it.
|
|
452
|
+
const subheads = headings.filter((h) => h.level >= 2);
|
|
453
|
+
const subheadingText = subheads.map((h) => h.text).join(" ");
|
|
454
|
+
const hasPrimaryInHeads = primaryKeyword ? containsKeywordTokens(subheadingText, primaryKeyword) : false;
|
|
455
|
+
const hasSecondaryInHeads = secondaryKeyword ? containsKeywordTokens(subheadingText, secondaryKeyword) : false;
|
|
456
|
+
if (subheads.length > 0 && (primaryKeyword || secondaryKeyword) && !hasPrimaryInHeads && !hasSecondaryInHeads) {
|
|
457
|
+
const kw = [
|
|
458
|
+
primaryKeyword ? `primary keyword "${primaryKeyword}"` : "",
|
|
459
|
+
secondaryKeyword ? `secondary keyword "${secondaryKeyword}"` : "",
|
|
460
|
+
].filter(Boolean).join(" or ");
|
|
461
|
+
audits.push({
|
|
462
|
+
label: "Keywords in Headings",
|
|
463
|
+
value: "No subheading uses your target keyword",
|
|
464
|
+
status: "warning",
|
|
465
|
+
recommendation: `Work your ${kw} into at least one H2 or H3. Keywords in headers reinforce relevance for readers and search engines.`,
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
|
|
438
469
|
return audits;
|
|
439
470
|
}
|
|
440
471
|
|
|
472
|
+
// Small health badge for a checked URL (OK / 301 / 404 / BLOCKED ...).
|
|
473
|
+
function HealthBadge({ result }: { result: LinkCheckResult }) {
|
|
474
|
+
const map = {
|
|
475
|
+
ok: { color: "#16a34a", label: "OK" },
|
|
476
|
+
redirect: { color: "#8B7310", label: result.status > 0 ? String(result.status) : "REDIR" },
|
|
477
|
+
broken: { color: "#dc2626", label: result.status > 0 ? String(result.status) : "404" },
|
|
478
|
+
unverified: { color: "#b45309", label: result.status > 0 ? String(result.status) : "BLOCKED" },
|
|
479
|
+
error: { color: "#dc2626", label: "ERR" },
|
|
480
|
+
} as const;
|
|
481
|
+
const c = map[result.category];
|
|
482
|
+
return (
|
|
483
|
+
<span style={{ fontSize: 9, fontWeight: 700, letterSpacing: "0.04em", padding: "2px 6px", borderRadius: 99, background: "#ffffff", color: c.color, fontVariantNumeric: "tabular-nums", flexShrink: 0, marginTop: 1 }}>
|
|
484
|
+
{c.label}
|
|
485
|
+
</span>
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
|
|
441
489
|
function LinkCheckCard({
|
|
442
490
|
urls,
|
|
491
|
+
linksDetailed,
|
|
443
492
|
results,
|
|
444
493
|
isLoading,
|
|
445
494
|
error,
|
|
@@ -447,22 +496,74 @@ function LinkCheckCard({
|
|
|
447
496
|
onCheck,
|
|
448
497
|
}: {
|
|
449
498
|
urls: string[];
|
|
499
|
+
linksDetailed?: { url: string; hyperlinked: boolean; anchorText?: string }[];
|
|
450
500
|
results: LinkCheckResult[];
|
|
451
501
|
isLoading: boolean;
|
|
452
502
|
error: string | null;
|
|
453
503
|
hasRun: boolean;
|
|
454
504
|
onCheck: () => void;
|
|
455
505
|
}) {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
506
|
+
// Which tile's link list is expanded.
|
|
507
|
+
const [openBucket, setOpenBucket] = useState<string | null>(null);
|
|
508
|
+
|
|
509
|
+
// Whether we can distinguish real hyperlinks from plain-text URLs (Portable Text only).
|
|
510
|
+
const haveTypes = !!linksDetailed;
|
|
511
|
+
const detailByUrl = useMemo(
|
|
512
|
+
() => new Map((linksDetailed || []).map((d) => [d.url, d])),
|
|
513
|
+
[linksDetailed]
|
|
514
|
+
);
|
|
515
|
+
const resultByUrl = useMemo(() => new Map(results.map((r) => [r.url, r])), [results]);
|
|
516
|
+
|
|
517
|
+
// Build the tiles. Hyperlink-type tiles are available immediately; health tiles appear
|
|
518
|
+
// after the broken-link check runs. Each tile is clickable to reveal its links.
|
|
519
|
+
// Two independent axes, shown as paired tiles so a 2-column grid stacks opposites:
|
|
520
|
+
// - Whether a URL is a real link: "Linked" (top) vs "Not linked" (bottom, RED = needs fixing)
|
|
521
|
+
// - Whether the link works: "Working" (top) vs "Broken" (bottom) [after the check]
|
|
522
|
+
// "Working" includes redirects (they still resolve - the 301 shows on the link's badge), so
|
|
523
|
+
// we don't surface the jargon word "redirect" as its own count. Order is interleaved
|
|
524
|
+
// (Working, Linked, Broken, Not linked) so the grid renders Working/Broken in the left
|
|
525
|
+
// column and Linked/Not-linked in the right column.
|
|
526
|
+
const blockedUrls = results.filter((r) => r.category === "unverified").map((r) => r.url);
|
|
527
|
+
const tiles = useMemo(() => {
|
|
528
|
+
const hyper = (linksDetailed || []).filter((l) => l.hyperlinked).map((l) => l.url);
|
|
529
|
+
const plain = (linksDetailed || []).filter((l) => !l.hyperlinked).map((l) => l.url);
|
|
530
|
+
const working = results.filter((r) => r.category === "ok" || r.category === "redirect").map((r) => r.url);
|
|
531
|
+
const broken = results.filter((r) => r.category === "broken" || r.category === "error").map((r) => r.url);
|
|
532
|
+
const t: { key: string; label: string; color: string; urls: string[]; note?: string }[] = [];
|
|
533
|
+
if (hasRun) t.push({ key: "working", label: "Working", color: "#16a34a", urls: working });
|
|
534
|
+
if (haveTypes) t.push({ key: "linked", label: "Linked", color: "#16a34a", urls: hyper });
|
|
535
|
+
if (hasRun) t.push({ key: "broken", label: "Broken", color: "#dc2626", urls: broken });
|
|
536
|
+
if (haveTypes) t.push({ key: "notlinked", label: "Not linked", color: "#dc2626", urls: plain, note: "Not links yet - hyperlink these so readers can click them and search engines can follow them." });
|
|
537
|
+
return t;
|
|
538
|
+
}, [haveTypes, linksDetailed, hasRun, results]);
|
|
539
|
+
|
|
540
|
+
const open = tiles.find((t) => t.key === openBucket) || null;
|
|
541
|
+
|
|
542
|
+
const renderLinkRow = (url: string) => {
|
|
543
|
+
const d = detailByUrl.get(url);
|
|
544
|
+
const r = resultByUrl.get(url);
|
|
545
|
+
return (
|
|
546
|
+
<a
|
|
547
|
+
key={url}
|
|
548
|
+
href={url}
|
|
549
|
+
target="_blank"
|
|
550
|
+
rel="noopener noreferrer"
|
|
551
|
+
style={{ display: "flex", gap: 8, alignItems: "flex-start", padding: "6px 8px", background: "rgba(0,0,0,0.025)", borderRadius: 6, textDecoration: "none", marginTop: 4 }}
|
|
552
|
+
>
|
|
553
|
+
{r && <HealthBadge result={r} />}
|
|
554
|
+
<div style={{ minWidth: 0, flex: 1 }}>
|
|
555
|
+
{d?.anchorText && (
|
|
556
|
+
<div style={{ fontSize: 11, color: "#1f2937", fontWeight: 600, lineHeight: 1.3, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>
|
|
557
|
+
“{d.anchorText}”
|
|
558
|
+
</div>
|
|
559
|
+
)}
|
|
560
|
+
<div style={{ fontSize: 10, color: "#4b5563", fontFamily: "ui-monospace, SFMono-Regular, monospace", wordBreak: "break-all", lineHeight: 1.35 }}>
|
|
561
|
+
{url}
|
|
562
|
+
</div>
|
|
563
|
+
</div>
|
|
564
|
+
</a>
|
|
565
|
+
);
|
|
566
|
+
};
|
|
466
567
|
|
|
467
568
|
return (
|
|
468
569
|
<div id="anchor-link-check" style={cardStyle}>
|
|
@@ -471,145 +572,94 @@ function LinkCheckCard({
|
|
|
471
572
|
Link Health
|
|
472
573
|
</span>
|
|
473
574
|
{hasRun && !isLoading && (
|
|
474
|
-
<button
|
|
475
|
-
onClick={onCheck}
|
|
476
|
-
style={{
|
|
477
|
-
background: "none",
|
|
478
|
-
border: "none",
|
|
479
|
-
fontSize: 10,
|
|
480
|
-
fontWeight: 600,
|
|
481
|
-
color: MJH_BLUE,
|
|
482
|
-
cursor: "pointer",
|
|
483
|
-
padding: "2px 4px",
|
|
484
|
-
}}
|
|
485
|
-
title="Run again"
|
|
486
|
-
>
|
|
575
|
+
<button onClick={onCheck} style={{ background: "none", border: "none", fontSize: 10, fontWeight: 600, color: MJH_BLUE, cursor: "pointer", padding: "2px 4px" }} title="Run again">
|
|
487
576
|
Re-check
|
|
488
577
|
</button>
|
|
489
578
|
)}
|
|
490
579
|
</div>
|
|
491
580
|
|
|
492
|
-
|
|
493
|
-
{
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
581
|
+
{urls.length === 0 ? (
|
|
582
|
+
<div style={{ fontSize: 11, color: "#4b5563", lineHeight: 1.5 }}>No links found in the body.</div>
|
|
583
|
+
) : (
|
|
584
|
+
<>
|
|
585
|
+
<div style={{ fontSize: 11, color: "#4b5563", lineHeight: 1.5, marginBottom: 10 }}>
|
|
586
|
+
{urls.length} link{urls.length === 1 ? "" : "s"} in the body.{tiles.length > 0 ? " Tap a box to see which." : ""}
|
|
587
|
+
</div>
|
|
497
588
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
589
|
+
{/* Clickable count tiles - 2 columns so opposites stack (Working/Broken on the
|
|
590
|
+
left, Linked/Not-linked on the right). Each opens a list of its links below. */}
|
|
591
|
+
{tiles.length > 0 && (
|
|
592
|
+
<div style={{ display: "grid", gridTemplateColumns: "repeat(2, 1fr)", gap: 6 }}>
|
|
593
|
+
{tiles.map((t) => {
|
|
594
|
+
const empty = t.urls.length === 0;
|
|
595
|
+
const active = openBucket === t.key && !empty;
|
|
596
|
+
return (
|
|
597
|
+
<button
|
|
598
|
+
key={t.key}
|
|
599
|
+
type="button"
|
|
600
|
+
onClick={() => !empty && setOpenBucket(active ? null : t.key)}
|
|
601
|
+
aria-expanded={active}
|
|
602
|
+
aria-label={`${t.urls.length} ${t.label} links`}
|
|
603
|
+
style={{
|
|
604
|
+
padding: "8px 4px",
|
|
605
|
+
background: active ? "rgba(0,93,172,0.08)" : "rgba(0,0,0,0.025)",
|
|
606
|
+
border: active ? `1px solid ${MJH_BLUE}55` : "1px solid transparent",
|
|
607
|
+
borderRadius: 8,
|
|
608
|
+
textAlign: "center",
|
|
609
|
+
cursor: empty ? "default" : "pointer",
|
|
610
|
+
opacity: empty ? 0.5 : 1,
|
|
611
|
+
}}
|
|
612
|
+
>
|
|
613
|
+
<div style={{ fontSize: 18, fontWeight: 700, color: t.color, fontVariantNumeric: "tabular-nums", lineHeight: 1 }}>{t.urls.length}</div>
|
|
614
|
+
<div style={{ fontSize: 9, fontWeight: 700, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.05em", marginTop: 4 }}>{t.label}</div>
|
|
615
|
+
</button>
|
|
616
|
+
);
|
|
617
|
+
})}
|
|
618
|
+
</div>
|
|
619
|
+
)}
|
|
517
620
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
621
|
+
{/* Expanded link list for the selected tile. */}
|
|
622
|
+
{open && open.urls.length > 0 && (
|
|
623
|
+
<div style={{ marginTop: 8 }}>
|
|
624
|
+
{open.note && (
|
|
625
|
+
<div style={{ fontSize: 10.5, color: "#92400e", background: "rgba(245,158,11,0.08)", border: "1px solid rgba(245,158,11,0.25)", borderRadius: 6, padding: "6px 9px", lineHeight: 1.45, marginBottom: 2 }}>
|
|
626
|
+
{open.note}
|
|
627
|
+
</div>
|
|
628
|
+
)}
|
|
629
|
+
{open.urls.map(renderLinkRow)}
|
|
630
|
+
</div>
|
|
631
|
+
)}
|
|
524
632
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
borderRadius: 8,
|
|
532
|
-
fontSize: 11,
|
|
533
|
-
color: "#b91c1c",
|
|
534
|
-
lineHeight: 1.5,
|
|
535
|
-
}}
|
|
536
|
-
>
|
|
537
|
-
{error}
|
|
538
|
-
<button
|
|
539
|
-
onClick={onCheck}
|
|
540
|
-
style={{
|
|
541
|
-
display: "block",
|
|
542
|
-
marginTop: 6,
|
|
543
|
-
padding: "4px 10px",
|
|
544
|
-
fontSize: 11,
|
|
545
|
-
fontWeight: 700,
|
|
546
|
-
color: "#ffffff",
|
|
547
|
-
background: "#dc2626",
|
|
548
|
-
border: "none",
|
|
549
|
-
borderRadius: 5,
|
|
550
|
-
cursor: "pointer",
|
|
551
|
-
}}
|
|
552
|
-
>
|
|
553
|
-
Try again
|
|
554
|
-
</button>
|
|
555
|
-
</div>
|
|
556
|
-
)}
|
|
633
|
+
{/* Links we couldn't auto-check (anti-bot walls) - not counted working or broken. */}
|
|
634
|
+
{hasRun && blockedUrls.length > 0 && (
|
|
635
|
+
<div style={{ marginTop: 8, padding: "6px 10px", background: "rgba(245,158,11,0.08)", border: "1px solid rgba(245,158,11,0.25)", borderRadius: 6, fontSize: 10.5, color: "#92400e", lineHeight: 1.45 }}>
|
|
636
|
+
{blockedUrls.length} link{blockedUrls.length === 1 ? "" : "s"} couldn't be auto-checked (the destination blocks our checker) - open them to confirm.
|
|
637
|
+
</div>
|
|
638
|
+
)}
|
|
557
639
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
<StatTile label="Valid" value={counts.valid} color="#16a34a" />
|
|
564
|
-
<StatTile label="Redirects" value={counts.redirects} color="#8B7310" />
|
|
565
|
-
<StatTile label="Broken" value={counts.broken + counts.errored} color="#dc2626" />
|
|
566
|
-
{counts.unverified > 0 && (
|
|
567
|
-
<StatTile label="Blocked" value={counts.unverified} color="#b45309" />
|
|
568
|
-
)}
|
|
569
|
-
</div>
|
|
570
|
-
{counts.unverified > 0 && (
|
|
571
|
-
<div
|
|
572
|
-
style={{
|
|
573
|
-
marginTop: 8,
|
|
574
|
-
padding: "6px 10px",
|
|
575
|
-
background: "rgba(245,158,11,0.08)",
|
|
576
|
-
border: "1px solid rgba(245,158,11,0.25)",
|
|
577
|
-
borderRadius: 6,
|
|
578
|
-
fontSize: 10.5,
|
|
579
|
-
color: "#92400e",
|
|
580
|
-
lineHeight: 1.45,
|
|
581
|
-
}}
|
|
640
|
+
{/* Check button (pre-run). */}
|
|
641
|
+
{!hasRun && !isLoading && (
|
|
642
|
+
<button
|
|
643
|
+
onClick={onCheck}
|
|
644
|
+
style={{ width: "100%", marginTop: 10, padding: "8px 12px", fontSize: 11, fontWeight: 700, color: "#1f2937", background: MJH_GOLD, border: "none", borderRadius: 6, cursor: "pointer", letterSpacing: "0.01em" }}
|
|
582
645
|
>
|
|
583
|
-
{
|
|
584
|
-
|
|
585
|
-
</div>
|
|
646
|
+
Check {urls.length} link{urls.length === 1 ? "" : "s"} for broken / redirects
|
|
647
|
+
</button>
|
|
586
648
|
)}
|
|
587
649
|
|
|
588
|
-
{
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
<
|
|
592
|
-
{counts.issues.length} link{counts.issues.length === 1 ? "" : "s"} need{counts.issues.length === 1 ? "s" : ""} attention
|
|
593
|
-
</div>
|
|
594
|
-
{counts.issues.map((r) => (
|
|
595
|
-
<LinkIssueRow key={r.url} result={r} />
|
|
596
|
-
))}
|
|
650
|
+
{isLoading && (
|
|
651
|
+
<div style={{ display: "flex", alignItems: "center", justifyContent: "center", gap: 8, padding: "16px 0" }}>
|
|
652
|
+
<LoadingBars size="xs" color={MJH_BLUE} />
|
|
653
|
+
<span style={{ fontSize: 11, color: "#4b5563" }}>Checking {urls.length} link{urls.length === 1 ? "" : "s"}...</span>
|
|
597
654
|
</div>
|
|
598
|
-
)
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
fontSize: 11,
|
|
607
|
-
color: "#16a34a",
|
|
608
|
-
fontWeight: 600,
|
|
609
|
-
textAlign: "center",
|
|
610
|
-
}}
|
|
611
|
-
>
|
|
612
|
-
All {counts.total} link{counts.total === 1 ? "" : "s"} resolve cleanly.
|
|
655
|
+
)}
|
|
656
|
+
|
|
657
|
+
{error && !isLoading && (
|
|
658
|
+
<div style={{ marginTop: 10, padding: "10px 12px", background: "rgba(220,38,38,0.04)", border: "1px solid rgba(220,38,38,0.18)", borderRadius: 8, fontSize: 11, color: "#b91c1c", lineHeight: 1.5 }}>
|
|
659
|
+
{error}
|
|
660
|
+
<button onClick={onCheck} style={{ display: "block", marginTop: 6, padding: "4px 10px", fontSize: 11, fontWeight: 700, color: "#ffffff", background: "#dc2626", border: "none", borderRadius: 5, cursor: "pointer" }}>
|
|
661
|
+
Try again
|
|
662
|
+
</button>
|
|
613
663
|
</div>
|
|
614
664
|
)}
|
|
615
665
|
</>
|
|
@@ -618,86 +668,6 @@ function LinkCheckCard({
|
|
|
618
668
|
);
|
|
619
669
|
}
|
|
620
670
|
|
|
621
|
-
function StatTile({ label, value, color }: { label: string; value: number; color: string }) {
|
|
622
|
-
return (
|
|
623
|
-
<div
|
|
624
|
-
style={{
|
|
625
|
-
padding: "8px 4px",
|
|
626
|
-
background: "rgba(0,0,0,0.025)",
|
|
627
|
-
borderRadius: 8,
|
|
628
|
-
textAlign: "center",
|
|
629
|
-
}}
|
|
630
|
-
>
|
|
631
|
-
<div style={{ fontSize: 18, fontWeight: 700, color, fontVariantNumeric: "tabular-nums", lineHeight: 1 }}>{value}</div>
|
|
632
|
-
<div style={{ fontSize: 9, fontWeight: 700, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.06em", marginTop: 4 }}>
|
|
633
|
-
{label}
|
|
634
|
-
</div>
|
|
635
|
-
</div>
|
|
636
|
-
);
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
function LinkIssueRow({ result }: { result: LinkCheckResult }) {
|
|
640
|
-
const map = {
|
|
641
|
-
ok: { bg: "rgba(22,163,74,0.06)", color: "#16a34a", label: "OK" },
|
|
642
|
-
redirect: { bg: "rgba(230,192,27,0.12)", color: "#8B7310", label: result.status > 0 ? String(result.status) : "REDIR" },
|
|
643
|
-
broken: { bg: "rgba(220,38,38,0.06)", color: "#dc2626", label: result.status > 0 ? String(result.status) : "404" },
|
|
644
|
-
// Amber for unverified - the link may work fine, our server just couldn't confirm.
|
|
645
|
-
unverified: { bg: "rgba(245,158,11,0.10)", color: "#b45309", label: result.status > 0 ? String(result.status) : "BLOCKED" },
|
|
646
|
-
error: { bg: "rgba(220,38,38,0.06)", color: "#dc2626", label: "ERR" },
|
|
647
|
-
} as const;
|
|
648
|
-
const c = map[result.category];
|
|
649
|
-
const tooltip = result.category === "unverified"
|
|
650
|
-
? `${result.url} (couldn't auto-check; likely anti-bot blocking - open manually to verify)`
|
|
651
|
-
: result.error ? `${result.url} (${result.error})` : result.url;
|
|
652
|
-
return (
|
|
653
|
-
<a
|
|
654
|
-
href={result.url}
|
|
655
|
-
target="_blank"
|
|
656
|
-
rel="noopener noreferrer"
|
|
657
|
-
style={{
|
|
658
|
-
display: "flex",
|
|
659
|
-
alignItems: "center",
|
|
660
|
-
gap: 8,
|
|
661
|
-
padding: "6px 10px",
|
|
662
|
-
background: c.bg,
|
|
663
|
-
borderRadius: 6,
|
|
664
|
-
textDecoration: "none",
|
|
665
|
-
}}
|
|
666
|
-
>
|
|
667
|
-
<span
|
|
668
|
-
style={{
|
|
669
|
-
fontSize: 9,
|
|
670
|
-
fontWeight: 700,
|
|
671
|
-
letterSpacing: "0.04em",
|
|
672
|
-
padding: "2px 6px",
|
|
673
|
-
borderRadius: 99,
|
|
674
|
-
background: "#ffffff",
|
|
675
|
-
color: c.color,
|
|
676
|
-
fontVariantNumeric: "tabular-nums",
|
|
677
|
-
flexShrink: 0,
|
|
678
|
-
}}
|
|
679
|
-
>
|
|
680
|
-
{c.label}
|
|
681
|
-
</span>
|
|
682
|
-
<span
|
|
683
|
-
style={{
|
|
684
|
-
fontSize: 11,
|
|
685
|
-
color: "#1f2937",
|
|
686
|
-
fontFamily: "ui-monospace, SFMono-Regular, monospace",
|
|
687
|
-
flex: 1,
|
|
688
|
-
minWidth: 0,
|
|
689
|
-
overflow: "hidden",
|
|
690
|
-
textOverflow: "ellipsis",
|
|
691
|
-
whiteSpace: "nowrap",
|
|
692
|
-
}}
|
|
693
|
-
title={tooltip}
|
|
694
|
-
>
|
|
695
|
-
{result.url}
|
|
696
|
-
</span>
|
|
697
|
-
</a>
|
|
698
|
-
);
|
|
699
|
-
}
|
|
700
|
-
|
|
701
671
|
export function TechnicalTab({
|
|
702
672
|
text,
|
|
703
673
|
documentFields,
|
|
@@ -729,8 +699,8 @@ export function TechnicalTab({
|
|
|
729
699
|
const wordCount = text ? text.split(/\s+/).filter(Boolean).length : 0;
|
|
730
700
|
|
|
731
701
|
const structureAudits = useMemo(
|
|
732
|
-
() => computeHeadingStructureAudits(headingsForStructure, wordCount),
|
|
733
|
-
[headingsForStructure, wordCount]
|
|
702
|
+
() => computeHeadingStructureAudits(headingsForStructure, wordCount, primaryKeyword, secondaryKeyword, documentFields?.unstyledHeadings),
|
|
703
|
+
[headingsForStructure, wordCount, primaryKeyword, secondaryKeyword, documentFields?.unstyledHeadings]
|
|
734
704
|
);
|
|
735
705
|
|
|
736
706
|
const imageNames = documentFields?.imageNames || [];
|
|
@@ -795,6 +765,7 @@ export function TechnicalTab({
|
|
|
795
765
|
: { label: "Word Count", value: `${wordCount} words`, status: "good" };
|
|
796
766
|
|
|
797
767
|
const bodyLinks = documentFields?.bodyLinks || [];
|
|
768
|
+
const bodyLinksDetailed = documentFields?.bodyLinksDetailed;
|
|
798
769
|
|
|
799
770
|
// Show a loading placeholder while document fields are still loading and we don't
|
|
800
771
|
// have anything yet (avoids a flash of "Missing" cards from prior doc state).
|
|
@@ -824,6 +795,17 @@ export function TechnicalTab({
|
|
|
824
795
|
footer={<SlugRedirectNotice />}
|
|
825
796
|
/>
|
|
826
797
|
|
|
798
|
+
{/* Link Health sits right under URL Slug - both are about the page's links. */}
|
|
799
|
+
<LinkCheckCard
|
|
800
|
+
urls={bodyLinks}
|
|
801
|
+
linksDetailed={bodyLinksDetailed}
|
|
802
|
+
results={linkCheckResults}
|
|
803
|
+
isLoading={isLinkCheckLoading}
|
|
804
|
+
error={linkCheckError}
|
|
805
|
+
hasRun={hasRunLinkCheck}
|
|
806
|
+
onCheck={onCheckLinks}
|
|
807
|
+
/>
|
|
808
|
+
|
|
827
809
|
{wordAudit && (
|
|
828
810
|
<AuditCard
|
|
829
811
|
anchorId="anchor-word-count"
|
|
@@ -834,45 +816,79 @@ export function TechnicalTab({
|
|
|
834
816
|
/>
|
|
835
817
|
)}
|
|
836
818
|
|
|
837
|
-
{
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
819
|
+
{(() => {
|
|
820
|
+
// anchor-headings-structure must land on the first STRUCTURAL card (the target of the
|
|
821
|
+
// Summary deep-links for skips/empties/density) - not on the "Keywords in Headings" or
|
|
822
|
+
// "Looks Like a Heading" cards, which have their own anchors and can sort first.
|
|
823
|
+
const structIdx = structureAudits.findIndex(
|
|
824
|
+
(a) => a.label !== "Keywords in Headings" && a.label !== "Looks Like a Heading"
|
|
825
|
+
);
|
|
826
|
+
return structureAudits.map((a, i) => (
|
|
827
|
+
<AuditCard
|
|
828
|
+
key={`structure-${i}`}
|
|
829
|
+
anchorId={
|
|
830
|
+
a.label === "Keywords in Headings"
|
|
831
|
+
? "anchor-headings-keyword"
|
|
832
|
+
: a.label === "Looks Like a Heading"
|
|
833
|
+
? "anchor-headings-unstyled"
|
|
834
|
+
: i === structIdx
|
|
835
|
+
? "anchor-headings-structure"
|
|
836
|
+
: undefined
|
|
837
|
+
}
|
|
838
|
+
label={a.label}
|
|
839
|
+
value={a.value}
|
|
840
|
+
status={a.status}
|
|
841
|
+
recommendation={a.recommendation}
|
|
842
|
+
/>
|
|
843
|
+
));
|
|
844
|
+
})()}
|
|
845
|
+
|
|
846
|
+
{(headings.length > 0 || !!documentFields?.title) && (
|
|
849
847
|
<div id="anchor-headings-outline" style={{ ...cardStyle, padding: "8px 14px" }}>
|
|
850
848
|
<div style={{ fontSize: 10, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.06em", fontWeight: 600, marginBottom: 6 }}>
|
|
851
849
|
Heading Outline
|
|
852
850
|
</div>
|
|
853
851
|
<div style={{ display: "flex", flexDirection: "column", gap: 4 }}>
|
|
852
|
+
{/* The article title renders as the page H1 - show it first so editors can see
|
|
853
|
+
exactly what their H1 is, then the body headings the tool scanned below it. */}
|
|
854
|
+
{documentFields?.title && (
|
|
855
|
+
<div style={{ fontSize: 11, color: MJH_BLUE, fontWeight: 700, lineHeight: 1.4 }}>
|
|
856
|
+
<span style={{ fontSize: 9, fontWeight: 700, color: MJH_BLUE, marginRight: 6 }}>H1</span>
|
|
857
|
+
{documentFields.title}
|
|
858
|
+
<span style={{ fontSize: 9, color: "#6b7280", fontWeight: 500, marginLeft: 6 }}>(article title)</span>
|
|
859
|
+
</div>
|
|
860
|
+
)}
|
|
854
861
|
{(headingsDetailed
|
|
855
862
|
? headingsDetailed.slice(0, 12)
|
|
856
863
|
: headings.slice(0, 12).map((h) => ({ text: h, level: 2 }))
|
|
857
|
-
).map((h, i) =>
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
864
|
+
).map((h, i) => {
|
|
865
|
+
const isH1 = h.level === 1;
|
|
866
|
+
return (
|
|
867
|
+
<div
|
|
868
|
+
key={i}
|
|
869
|
+
style={{
|
|
870
|
+
fontSize: 11,
|
|
871
|
+
color: !h.text ? "#dc2626" : isH1 ? MJH_BLUE : "#4b5563",
|
|
872
|
+
fontWeight: isH1 ? 700 : 400,
|
|
873
|
+
fontStyle: h.text ? "normal" : "italic",
|
|
874
|
+
lineHeight: 1.4,
|
|
875
|
+
paddingLeft: Math.max(0, (h.level - 2) * 12),
|
|
876
|
+
}}
|
|
877
|
+
>
|
|
878
|
+
<span style={{ fontSize: 9, fontWeight: 700, color: isH1 ? MJH_BLUE : "#4b5563", marginRight: 6 }}>H{h.level}</span>
|
|
879
|
+
{h.text || "(empty)"}
|
|
880
|
+
</div>
|
|
881
|
+
);
|
|
882
|
+
})}
|
|
872
883
|
{(headingsDetailed ?? headings).length > 12 && (
|
|
873
884
|
<div style={{ fontSize: 10, color: "#4b5563" }}>+ {(headingsDetailed ?? headings).length - 12} more</div>
|
|
874
885
|
)}
|
|
875
886
|
</div>
|
|
887
|
+
<div style={{ fontSize: 10, color: "#6b7280", marginTop: 8, lineHeight: 1.4 }}>
|
|
888
|
+
{headings.length > 0
|
|
889
|
+
? "The title above is your H1; the tool scans the H2-H6 tags below it. Tip: work your primary and/or secondary keyword into a header where it reads naturally."
|
|
890
|
+
: "The title above is your H1, and there are no H2-H6 subheadings yet. Tip: work your primary and/or secondary keyword into the title where it reads naturally."}
|
|
891
|
+
</div>
|
|
876
892
|
</div>
|
|
877
893
|
)}
|
|
878
894
|
|
|
@@ -912,15 +928,6 @@ export function TechnicalTab({
|
|
|
912
928
|
recommendation={imgTitleAudit.recommendation}
|
|
913
929
|
/>
|
|
914
930
|
)}
|
|
915
|
-
|
|
916
|
-
<LinkCheckCard
|
|
917
|
-
urls={bodyLinks}
|
|
918
|
-
results={linkCheckResults}
|
|
919
|
-
isLoading={isLinkCheckLoading}
|
|
920
|
-
error={linkCheckError}
|
|
921
|
-
hasRun={hasRunLinkCheck}
|
|
922
|
-
onCheck={onCheckLinks}
|
|
923
|
-
/>
|
|
924
931
|
</div>
|
|
925
932
|
);
|
|
926
933
|
}
|