sanity-plugin-seo-copilot 0.2.0 → 0.2.5
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 +300 -117
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +298 -115
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/KeywordPanel.tsx +6 -4
- package/src/components/SEOCopilotPanel.tsx +18 -7
- package/src/components/tabs/AEOTab.tsx +9 -3
- package/src/components/tabs/MetaTab.tsx +9 -6
- package/src/components/tabs/SummaryTab.tsx +2 -2
- package/src/components/tabs/TechnicalTab.tsx +70 -30
- package/src/hooks/useDocumentContent.ts +47 -216
- package/src/hooks/useKeywordAnalysis.ts +12 -0
- package/src/hooks/useSEOChat.ts +16 -7
- package/src/lib/documentExtract.ts +257 -0
- package/src/lib/geoAnalysis.ts +16 -3
- package/src/lib/scoring.ts +37 -14
- package/src/lib/summary.ts +59 -7
- package/src/lib/types.ts +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-seo-copilot",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "AI-powered SEO writing assistant for Sanity Studio",
|
|
5
5
|
"keywords": ["sanity", "sanity-plugin", "seo", "copilot"],
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@sanity/icons": "^3.0.0",
|
|
48
48
|
"@sanity/ui": "^2.0.0 || ^3.0.0",
|
|
49
49
|
"react": "^18.0.0 || ^19.0.0",
|
|
50
|
-
"sanity": "^3.0.0",
|
|
50
|
+
"sanity": "^3.0.0 || ^5.0.0",
|
|
51
51
|
"styled-components": "^6.0.0"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
@@ -96,7 +96,9 @@ function placementCount(p?: import("../lib/types").KeywordPlacement): number {
|
|
|
96
96
|
|
|
97
97
|
type PlacementKey = "inBody" | "inTitle" | "inMetaDescription" | "inImages" | "inUrl" | "none";
|
|
98
98
|
|
|
99
|
-
/** Merge supporting + missing into one list,
|
|
99
|
+
/** Merge supporting + missing into one list, sorted by placement count then volume desc.
|
|
100
|
+
* Note: 0-volume terms are intentionally KEPT - niche clinical long-tail terms often
|
|
101
|
+
* have no SEMrush data but are still worth targeting for topical authority. */
|
|
100
102
|
function buildSuggestedKeywords(
|
|
101
103
|
supporting: { term: string; volume: number | null; inContent: boolean; placement?: import("../lib/types").KeywordPlacement }[],
|
|
102
104
|
missing: { term: string; volume: number | null; reason: string; placement?: import("../lib/types").KeywordPlacement }[],
|
|
@@ -401,10 +403,10 @@ function PrimaryKeywordSelector({
|
|
|
401
403
|
{candidate.term}
|
|
402
404
|
</span>
|
|
403
405
|
{candidate.volume != null && (
|
|
404
|
-
<span style={{ fontSize: 11, fontWeight: 600, color: "#1f2937" }}>{abbrevVol(candidate.volume)}/mo</span>
|
|
406
|
+
<span style={{ fontSize: 11, fontWeight: 600, color: "#1f2937" }}>{candidate.volume === 0 ? "N/A" : `${abbrevVol(candidate.volume)}/mo`}</span>
|
|
405
407
|
)}
|
|
406
408
|
<span style={{ fontSize: 10, color: "#1f2937" }}>
|
|
407
|
-
{Math.round(candidate.confidence * 100)}% confidence
|
|
409
|
+
{Math.round((candidate.confidence ?? 0) * 100)}% confidence
|
|
408
410
|
</span>
|
|
409
411
|
</div>
|
|
410
412
|
{candidate.placement && (
|
|
@@ -821,7 +823,7 @@ function SuggestedKeywordsCard({
|
|
|
821
823
|
{enrichingTerms.has(kw.term) && <LoadingBars size="xs" color="#6b7280" />}
|
|
822
824
|
{/* Abbreviated monthly search volume - readable, not whisper-gray. */}
|
|
823
825
|
{!enrichingTerms.has(kw.term) && kw.volume != null && (
|
|
824
|
-
<span style={{ fontSize: 10.5, fontWeight: 600, color: "#1f2937", flexShrink: 0 }} title="Monthly searches">{abbrevVol(kw.volume)}/mo</span>
|
|
826
|
+
<span style={{ fontSize: 10.5, fontWeight: 600, color: "#1f2937", flexShrink: 0 }} title="Monthly searches">{kw.volume === 0 ? "N/A" : `${abbrevVol(kw.volume)}/mo`}</span>
|
|
825
827
|
)}
|
|
826
828
|
{/* Placement indicators */}
|
|
827
829
|
{kw.placement && <PlacementIndicators placement={kw.placement} />}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useState, useRef, useCallback, useEffect, useMemo, Suspense } from "react";
|
|
2
|
+
import { useWorkspace } from "sanity";
|
|
2
3
|
import { createPortal } from "react-dom";
|
|
3
4
|
import { useDocumentContent } from "../hooks/useDocumentContent";
|
|
4
5
|
import { useKeywordAnalysis } from "../hooks/useKeywordAnalysis";
|
|
@@ -598,6 +599,16 @@ function SEOCopilotInner({ config, onClose }: { config: SEOCopilotConfig; onClos
|
|
|
598
599
|
const { text, isLoading: docLoading, documentFields, documentId } = useDocumentContent();
|
|
599
600
|
const { apiUrl } = useConfig();
|
|
600
601
|
|
|
602
|
+
// Resolve which Sanity dataset (= MJH publication) to read from. Each Studio
|
|
603
|
+
// workspace is bound to exactly one dataset, so the CURRENT workspace's
|
|
604
|
+
// dataset IS the publication. Prefer an explicit config.publication override,
|
|
605
|
+
// otherwise use the live workspace dataset. This makes the plugin work on
|
|
606
|
+
// every publication (onclive, hcplive, ajmc, ...) with zero per-workspace
|
|
607
|
+
// config - without it, a plugin installed as `seoCopilot({ apiUrl })` sends
|
|
608
|
+
// no publication and the backend falls back to the wrong/empty dataset.
|
|
609
|
+
const workspace = useWorkspace();
|
|
610
|
+
const effectivePublication = config.publication || workspace?.dataset;
|
|
611
|
+
|
|
601
612
|
const seedCacheKey = documentId ? `seo-copilot-cache-${documentId}` : "seo-copilot-cache-v2";
|
|
602
613
|
const loadSeedsFromCache = useCallback((): string[] => {
|
|
603
614
|
try {
|
|
@@ -641,7 +652,7 @@ function SEOCopilotInner({ config, onClose }: { config: SEOCopilotConfig; onClos
|
|
|
641
652
|
const [chatOpen, setChatOpen] = usePersistentState<boolean>("seo-copilot-ui-chat-open-v35", false);
|
|
642
653
|
const [splitPercent, setSplitPercent] = usePersistentState<number>("seo-copilot-ui-split", 70);
|
|
643
654
|
|
|
644
|
-
const keywordAnalysisState = useKeywordAnalysis(text, apiUrl,
|
|
655
|
+
const keywordAnalysisState = useKeywordAnalysis(text, apiUrl, effectivePublication, seedKeywords, documentFields, selectedPrimary, documentId);
|
|
645
656
|
|
|
646
657
|
// Effective primary (matches PanelContent's resolution)
|
|
647
658
|
const effectivePrimary = selectedPrimary || keywordAnalysisState.analysis?.primaryKeyword?.term || "";
|
|
@@ -666,7 +677,7 @@ function SEOCopilotInner({ config, onClose }: { config: SEOCopilotConfig; onClos
|
|
|
666
677
|
}, [keywordAnalysisState.analysis, keywordAnalysisState.deepAnalysis]);
|
|
667
678
|
|
|
668
679
|
// Chat hook lifted here so in-flight streams survive PanelContent remount (undock)
|
|
669
|
-
const chatHookState = useSEOChat(apiUrl, text,
|
|
680
|
+
const chatHookState = useSEOChat(apiUrl, text, effectivePublication, keywordPanelData, documentId);
|
|
670
681
|
|
|
671
682
|
// AEO content suggestions - lifted to SEOCopilotInner so in-flight requests survive undock,
|
|
672
683
|
// and PERSISTED per-doc so generated suggestions come back after reload.
|
|
@@ -694,7 +705,7 @@ function SEOCopilotInner({ config, onClose }: { config: SEOCopilotConfig; onClos
|
|
|
694
705
|
setIsCSLoading(true);
|
|
695
706
|
setCsError(null);
|
|
696
707
|
try {
|
|
697
|
-
const data = await fetchContentSuggestions(apiUrl, text, effectivePrimary,
|
|
708
|
+
const data = await fetchContentSuggestions(apiUrl, text, effectivePrimary, effectivePublication);
|
|
698
709
|
if (aeoOpVersionRef.current !== myVersion) return;
|
|
699
710
|
if (
|
|
700
711
|
data.keyTakeaways.length === 0 &&
|
|
@@ -711,7 +722,7 @@ function SEOCopilotInner({ config, onClose }: { config: SEOCopilotConfig; onClos
|
|
|
711
722
|
}
|
|
712
723
|
if (aeoOpVersionRef.current !== myVersion) return;
|
|
713
724
|
setIsCSLoading(false);
|
|
714
|
-
}, [apiUrl, text, effectivePrimary,
|
|
725
|
+
}, [apiUrl, text, effectivePrimary, effectivePublication]);
|
|
715
726
|
|
|
716
727
|
// Smart Linking - lifted state, persisted per-doc so suggestions survive remount.
|
|
717
728
|
// Auto-runs when keywords stabilize; user can also refresh manually.
|
|
@@ -760,7 +771,7 @@ function SEOCopilotInner({ config, onClose }: { config: SEOCopilotConfig; onClos
|
|
|
760
771
|
effectivePrimary,
|
|
761
772
|
supportingKeywordsForLinking,
|
|
762
773
|
documentId,
|
|
763
|
-
|
|
774
|
+
effectivePublication
|
|
764
775
|
);
|
|
765
776
|
if (linkingVersionRef.current !== myVersion) return;
|
|
766
777
|
setLinkingSuggestions(suggestions);
|
|
@@ -771,7 +782,7 @@ function SEOCopilotInner({ config, onClose }: { config: SEOCopilotConfig; onClos
|
|
|
771
782
|
}
|
|
772
783
|
if (linkingVersionRef.current !== myVersion) return;
|
|
773
784
|
setIsLinkingLoading(false);
|
|
774
|
-
}, [apiUrl, text, effectivePrimary, supportingKeywordsForLinking, documentId,
|
|
785
|
+
}, [apiUrl, text, effectivePrimary, supportingKeywordsForLinking, documentId, effectivePublication]);
|
|
775
786
|
|
|
776
787
|
// Stale = the article changed materially since we last fetched suggestions.
|
|
777
788
|
const isLinkingStale = useMemo(() => {
|
|
@@ -900,7 +911,7 @@ function SEOCopilotInner({ config, onClose }: { config: SEOCopilotConfig; onClos
|
|
|
900
911
|
|
|
901
912
|
const panelContent = (
|
|
902
913
|
<PanelContent
|
|
903
|
-
initialPublication={
|
|
914
|
+
initialPublication={effectivePublication}
|
|
904
915
|
isFloating={isFloating}
|
|
905
916
|
isFullscreen={isFullscreen}
|
|
906
917
|
onToggleFloat={() => {
|
|
@@ -112,9 +112,13 @@ function CopyButton({ text }: { text: string }) {
|
|
|
112
112
|
function GEOCard({ geo, publication }: { geo: ReturnType<typeof analyzeGEO>; publication?: string }) {
|
|
113
113
|
const [showDetails, setShowDetails] = usePersistentState<boolean>("seo-copilot-ui-geo-details", false);
|
|
114
114
|
const fd = geo.factDensity;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
115
|
+
// Short-form content (news briefs, previews) naturally has low fact density,
|
|
116
|
+
// so don't show an alarming red "Weak" - present it neutrally instead.
|
|
117
|
+
const isShort = fd.totalWords > 0 && fd.totalWords < 600;
|
|
118
|
+
const effectiveStatus = fd.status === "weak" && isShort ? "moderate" : fd.status;
|
|
119
|
+
const fdColor = effectiveStatus === "strong" ? "#16a34a" : effectiveStatus === "moderate" ? "#8B7310" : "#dc2626";
|
|
120
|
+
const fdLabel = fd.status === "strong" ? "Strong" : fd.status === "moderate" ? "Moderate" : isShort ? "Light (short-form)" : "Weak";
|
|
121
|
+
const fdBg = effectiveStatus === "strong" ? "rgba(22,163,74,0.1)" : effectiveStatus === "moderate" ? "rgba(230,192,27,0.15)" : "rgba(220,38,38,0.08)";
|
|
118
122
|
|
|
119
123
|
const goodCount = geo.headingAudit.filter((h) => h.status === "good").length;
|
|
120
124
|
const totalHeadings = geo.headingAudit.length;
|
|
@@ -170,6 +174,8 @@ function GEOCard({ geo, publication }: { geo: ReturnType<typeof analyzeGEO>; pub
|
|
|
170
174
|
? "AI engines prefer this density."
|
|
171
175
|
: fd.status === "moderate"
|
|
172
176
|
? "Aim for 8+ per 1,000 words with named sources (NEJM, JAMA, FDA, trial numbers, p-values)."
|
|
177
|
+
: isShort
|
|
178
|
+
? "Short-form content naturally has fewer stats - fine for news and previews. Add a citation or two where you can."
|
|
173
179
|
: "Vague claims get skipped. Add specific numbers, trial citations, or dates."}
|
|
174
180
|
</div>
|
|
175
181
|
</div>
|
|
@@ -288,11 +288,11 @@ function daysSince(iso?: string): number | null {
|
|
|
288
288
|
|
|
289
289
|
function formatDateShort(iso?: string): string {
|
|
290
290
|
if (!iso) return "";
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
291
|
+
const d = new Date(iso);
|
|
292
|
+
// toLocaleDateString does NOT throw on a bad date - it returns "Invalid Date".
|
|
293
|
+
// Guard explicitly so we never render that (or a blank) inside a "Good" badge.
|
|
294
|
+
if (isNaN(d.getTime())) return "";
|
|
295
|
+
return d.toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" });
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
export function MetaTab({ documentFields, primaryKeyword, isLoading }: MetaTabProps) {
|
|
@@ -316,7 +316,7 @@ export function MetaTab({ documentFields, primaryKeyword, isLoading }: MetaTabPr
|
|
|
316
316
|
// Don't flag as missing - just note we can't audit it here.
|
|
317
317
|
items.push({ label: "Author Byline", value: "Set (reference)", status: "good", recommendation: "Author is linked as a reference, so we can't read credentials from this view. Open the linked author page to confirm name, credentials, and bio are set." });
|
|
318
318
|
} else if (!author) {
|
|
319
|
-
items.push({ label: "Author Byline", value: "Missing", status: "
|
|
319
|
+
items.push({ label: "Author Byline", value: "Missing", status: "warning", recommendation: "Add a named author with credentials - healthcare (YMYL) content with visible authorship earns more trust from Google's E-E-A-T signals. Wire or news briefs published without a byline can disregard this." });
|
|
320
320
|
} else if (!creds) {
|
|
321
321
|
items.push({ label: "Author Byline", value: author, status: "warning", recommendation: "Author shown but credentials (MD, PharmD, RN, etc.) aren't visible. Add credential suffixes." });
|
|
322
322
|
} else if (!bio) {
|
|
@@ -335,6 +335,9 @@ export function MetaTab({ documentFields, primaryKeyword, isLoading }: MetaTabPr
|
|
|
335
335
|
|
|
336
336
|
if (!published) {
|
|
337
337
|
items.push({ label: "Publish Date", value: "Missing", status: "error", recommendation: "Add a visible publish date. Required for healthcare content to be cited by Google and AI search." });
|
|
338
|
+
} else if (daysPub === null) {
|
|
339
|
+
// A date is set but couldn't be parsed - don't show a blank/garbage value in a green "Good" badge.
|
|
340
|
+
items.push({ label: "Publish Date", value: "Unrecognized format", status: "warning", recommendation: "A publish date is set but couldn't be read as a valid date. Check the field value." });
|
|
338
341
|
} else {
|
|
339
342
|
items.push({ label: "Publish Date", value: formatDateShort(published), status: "good" });
|
|
340
343
|
}
|
|
@@ -241,8 +241,8 @@ export function SummaryTab({
|
|
|
241
241
|
}: SummaryTabProps) {
|
|
242
242
|
const scoreDetail = useMemo(() => {
|
|
243
243
|
if (!analysis) return null;
|
|
244
|
-
return calculateContentScoreDetailed(text, analysis);
|
|
245
|
-
}, [text, analysis]);
|
|
244
|
+
return calculateContentScoreDetailed(text, analysis, documentFields);
|
|
245
|
+
}, [text, analysis, documentFields]);
|
|
246
246
|
const score = scoreDetail?.total ?? null;
|
|
247
247
|
|
|
248
248
|
const items = useMemo(
|
|
@@ -169,9 +169,11 @@ function imageFilenameAudit(filenames: string[]): TechnicalAuditItem | null {
|
|
|
169
169
|
function imageAltTextAudit(altTexts: string[]): TechnicalAuditItem | null {
|
|
170
170
|
if (altTexts.length === 0) return null;
|
|
171
171
|
const issues: { alt: string; reason: string }[] = [];
|
|
172
|
+
let audited = 0; // non-empty alt texts we actually evaluate (blank = decorative, skipped)
|
|
172
173
|
for (const alt of altTexts) {
|
|
173
174
|
const trimmed = alt.trim();
|
|
174
175
|
if (!trimmed) continue; // empty alt is intentional - skip
|
|
176
|
+
audited++;
|
|
175
177
|
const len = trimmed.length;
|
|
176
178
|
const wc = trimmed.split(/\s+/).filter(Boolean).length;
|
|
177
179
|
if (len > 125) {
|
|
@@ -180,10 +182,12 @@ function imageAltTextAudit(altTexts: string[]): TechnicalAuditItem | null {
|
|
|
180
182
|
issues.push({ alt: trimmed, reason: "just one word - use 2-5 descriptive keywords" });
|
|
181
183
|
}
|
|
182
184
|
}
|
|
185
|
+
// Every image had an intentionally-empty (decorative) alt - nothing to audit.
|
|
186
|
+
if (audited === 0) return null;
|
|
183
187
|
if (issues.length === 0) {
|
|
184
188
|
return {
|
|
185
189
|
label: "Image Alt Text",
|
|
186
|
-
value: `${
|
|
190
|
+
value: `${audited} alt text${audited === 1 ? "" : "s"} look well-formed`,
|
|
187
191
|
status: "good",
|
|
188
192
|
};
|
|
189
193
|
}
|
|
@@ -193,7 +197,7 @@ function imageAltTextAudit(altTexts: string[]): TechnicalAuditItem | null {
|
|
|
193
197
|
}).join("; ");
|
|
194
198
|
return {
|
|
195
199
|
label: "Image Alt Text",
|
|
196
|
-
value: `${issues.length} of ${
|
|
200
|
+
value: `${issues.length} of ${audited} alt text${audited === 1 ? "" : "s"} need attention`,
|
|
197
201
|
status: "warning",
|
|
198
202
|
recommendation: `${examples}. Alt text should be 2-5 descriptive keywords that describe the image, ideally including the primary keyword, and stay under 125 characters.`,
|
|
199
203
|
};
|
|
@@ -202,9 +206,17 @@ function imageAltTextAudit(altTexts: string[]): TechnicalAuditItem | null {
|
|
|
202
206
|
// Image title audit. Per the director, the title attribute (the tooltip shown on
|
|
203
207
|
// hover) sends an SEO signal, so each image should carry a short descriptive title.
|
|
204
208
|
// Flags images with no title, and titles that are a single bare word.
|
|
209
|
+
//
|
|
210
|
+
// MJH's image schemas (mainImage, figure) do not have a `title` field at all -
|
|
211
|
+
// only `alt`, `caption`, and `link`. When NONE of the document's images have a
|
|
212
|
+
// title, we treat that as "schema doesn't support titles" and skip the audit
|
|
213
|
+
// silently rather than flagging every image as missing a field the editor
|
|
214
|
+
// has no way to fill in. The director's intent (catch editors who set title
|
|
215
|
+
// on some images but not others) is preserved.
|
|
205
216
|
function imageTitleAudit(titles: string[], imageCount: number): TechnicalAuditItem | null {
|
|
206
217
|
if (imageCount <= 0) return null;
|
|
207
218
|
const withTitle = titles.length;
|
|
219
|
+
if (withTitle === 0) return null; // schema doesn't expose a title field - skip
|
|
208
220
|
const missing = imageCount - withTitle;
|
|
209
221
|
if (missing > 0) {
|
|
210
222
|
return {
|
|
@@ -234,7 +246,9 @@ function imageTitleAudit(titles: string[], imageCount: number): TechnicalAuditIt
|
|
|
234
246
|
// heading-level skips, and empty heading blocks.
|
|
235
247
|
function computeHeadingStructureAudits(headings: HeadingItem[], wordCount: number): TechnicalAuditItem[] {
|
|
236
248
|
const audits: TechnicalAuditItem[] = [];
|
|
237
|
-
|
|
249
|
+
// Count H2 AND H3 as section headings: an article sectioned only with H3s is
|
|
250
|
+
// still sectioned, so it shouldn't be told it has "no section headings".
|
|
251
|
+
const sectionCount = headings.filter((h) => h.level === 2 || h.level === 3).length;
|
|
238
252
|
|
|
239
253
|
// Heading-density check. Thresholds backed by SEO best-practice research:
|
|
240
254
|
// > 2,500 words really wants 1 H2 per ~400 words; 1,500+ usually needs 3+;
|
|
@@ -244,28 +258,28 @@ function computeHeadingStructureAudits(headings: HeadingItem[], wordCount: numbe
|
|
|
244
258
|
// softer density warnings, so a long article with no headings reports "error"
|
|
245
259
|
// (matching summary.ts) rather than falling into a lower-severity branch.
|
|
246
260
|
let densityFired = false;
|
|
247
|
-
if (wordCount >= 1000 &&
|
|
261
|
+
if (wordCount >= 1000 && sectionCount === 0) {
|
|
248
262
|
audits.push({
|
|
249
263
|
label: "Section Headings",
|
|
250
|
-
value: `No
|
|
264
|
+
value: `No section headings in a ${wordCount}-word article`,
|
|
251
265
|
status: "error",
|
|
252
|
-
recommendation: "Articles this long need section headings. Add 2-3 H2 headings to break the body into scannable sections.",
|
|
266
|
+
recommendation: "Articles this long need section headings. Add 2-3 H2 (or H3) headings to break the body into scannable sections.",
|
|
253
267
|
});
|
|
254
268
|
densityFired = true;
|
|
255
|
-
} else if (wordCount >= 2500 &&
|
|
269
|
+
} else if (wordCount >= 2500 && sectionCount < 5) {
|
|
256
270
|
audits.push({
|
|
257
271
|
label: "Section Headings",
|
|
258
|
-
value: `${
|
|
272
|
+
value: `${sectionCount} section heading${sectionCount === 1 ? "" : "s"} for a ${wordCount}-word article`,
|
|
259
273
|
status: "warning",
|
|
260
|
-
recommendation: "Long articles read best with 1
|
|
274
|
+
recommendation: "Long articles read best with 1 section heading per 300-400 words. Break the content into more named sections so readers and search engines can navigate it.",
|
|
261
275
|
});
|
|
262
276
|
densityFired = true;
|
|
263
|
-
} else if (wordCount >= 1500 &&
|
|
277
|
+
} else if (wordCount >= 1500 && sectionCount < 3) {
|
|
264
278
|
audits.push({
|
|
265
279
|
label: "Section Headings",
|
|
266
|
-
value: `${
|
|
280
|
+
value: `${sectionCount} section heading${sectionCount === 1 ? "" : "s"} for a ${wordCount}-word article`,
|
|
267
281
|
status: "warning",
|
|
268
|
-
recommendation: "Articles above 1,500 words usually need at least 3
|
|
282
|
+
recommendation: "Articles above 1,500 words usually need at least 3 named sections. Add section breaks so the outline is scannable.",
|
|
269
283
|
});
|
|
270
284
|
densityFired = true;
|
|
271
285
|
}
|
|
@@ -358,8 +372,9 @@ function LinkCheckCard({
|
|
|
358
372
|
const redirects = results.filter((r) => r.category === "redirect").length;
|
|
359
373
|
const broken = results.filter((r) => r.category === "broken").length;
|
|
360
374
|
const errored = results.filter((r) => r.category === "error").length;
|
|
375
|
+
const unverified = results.filter((r) => r.category === "unverified").length;
|
|
361
376
|
const issues = results.filter((r) => r.category !== "ok");
|
|
362
|
-
return { total, valid, redirects, broken, errored, issues };
|
|
377
|
+
return { total, valid, redirects, broken, errored, unverified, issues };
|
|
363
378
|
}, [results]);
|
|
364
379
|
|
|
365
380
|
return (
|
|
@@ -455,13 +470,33 @@ function LinkCheckCard({
|
|
|
455
470
|
|
|
456
471
|
{hasRun && !isLoading && !error && (
|
|
457
472
|
<>
|
|
458
|
-
{/*
|
|
459
|
-
<div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 6 }}>
|
|
473
|
+
{/* Summary tiles - drops to 5 columns when any links were blocked by anti-bot walls */}
|
|
474
|
+
<div style={{ display: "grid", gridTemplateColumns: counts.unverified > 0 ? "repeat(5, 1fr)" : "repeat(4, 1fr)", gap: 6 }}>
|
|
460
475
|
<StatTile label="Checked" value={counts.total} color="#475569" />
|
|
461
476
|
<StatTile label="Valid" value={counts.valid} color="#16a34a" />
|
|
462
477
|
<StatTile label="Redirects" value={counts.redirects} color="#8B7310" />
|
|
463
478
|
<StatTile label="Broken" value={counts.broken + counts.errored} color="#dc2626" />
|
|
479
|
+
{counts.unverified > 0 && (
|
|
480
|
+
<StatTile label="Blocked" value={counts.unverified} color="#b45309" />
|
|
481
|
+
)}
|
|
464
482
|
</div>
|
|
483
|
+
{counts.unverified > 0 && (
|
|
484
|
+
<div
|
|
485
|
+
style={{
|
|
486
|
+
marginTop: 8,
|
|
487
|
+
padding: "6px 10px",
|
|
488
|
+
background: "rgba(245,158,11,0.08)",
|
|
489
|
+
border: "1px solid rgba(245,158,11,0.25)",
|
|
490
|
+
borderRadius: 6,
|
|
491
|
+
fontSize: 10.5,
|
|
492
|
+
color: "#92400e",
|
|
493
|
+
lineHeight: 1.45,
|
|
494
|
+
}}
|
|
495
|
+
>
|
|
496
|
+
{counts.unverified} link{counts.unverified === 1 ? "" : "s"} were blocked from our auto-check (likely
|
|
497
|
+
anti-bot rules on the destination site). They may still work fine for human readers - click each to confirm.
|
|
498
|
+
</div>
|
|
499
|
+
)}
|
|
465
500
|
|
|
466
501
|
{/* Issues list */}
|
|
467
502
|
{counts.issues.length > 0 ? (
|
|
@@ -519,9 +554,14 @@ function LinkIssueRow({ result }: { result: LinkCheckResult }) {
|
|
|
519
554
|
ok: { bg: "rgba(22,163,74,0.06)", color: "#16a34a", label: "OK" },
|
|
520
555
|
redirect: { bg: "rgba(230,192,27,0.12)", color: "#8B7310", label: result.status > 0 ? String(result.status) : "REDIR" },
|
|
521
556
|
broken: { bg: "rgba(220,38,38,0.06)", color: "#dc2626", label: result.status > 0 ? String(result.status) : "404" },
|
|
557
|
+
// Amber for unverified - the link may work fine, our server just couldn't confirm.
|
|
558
|
+
unverified: { bg: "rgba(245,158,11,0.10)", color: "#b45309", label: result.status > 0 ? String(result.status) : "BLOCKED" },
|
|
522
559
|
error: { bg: "rgba(220,38,38,0.06)", color: "#dc2626", label: "ERR" },
|
|
523
560
|
} as const;
|
|
524
561
|
const c = map[result.category];
|
|
562
|
+
const tooltip = result.category === "unverified"
|
|
563
|
+
? `${result.url} (couldn't auto-check; likely anti-bot blocking - open manually to verify)`
|
|
564
|
+
: result.error ? `${result.url} (${result.error})` : result.url;
|
|
525
565
|
return (
|
|
526
566
|
<a
|
|
527
567
|
href={result.url}
|
|
@@ -563,7 +603,7 @@ function LinkIssueRow({ result }: { result: LinkCheckResult }) {
|
|
|
563
603
|
textOverflow: "ellipsis",
|
|
564
604
|
whiteSpace: "nowrap",
|
|
565
605
|
}}
|
|
566
|
-
title={
|
|
606
|
+
title={tooltip}
|
|
567
607
|
>
|
|
568
608
|
{result.url}
|
|
569
609
|
</span>
|
|
@@ -631,14 +671,12 @@ export function TechnicalTab({
|
|
|
631
671
|
: null;
|
|
632
672
|
|
|
633
673
|
// 450 is the body-text floor. 1,500+ is the competitive target for HCP clinical content.
|
|
634
|
-
|
|
674
|
+
// An empty body is not an error to "Fix" - the editor simply hasn't written yet
|
|
675
|
+
// (or the body hasn't loaded). Mirror summary.ts and show no card rather than a red
|
|
676
|
+
// alarm; the Word Count card appears once there's real text to measure.
|
|
677
|
+
const wordAudit: TechnicalAuditItem | null =
|
|
635
678
|
wordCount === 0
|
|
636
|
-
?
|
|
637
|
-
label: "Word Count",
|
|
638
|
-
value: "0 words",
|
|
639
|
-
status: "error",
|
|
640
|
-
recommendation: "Start writing. A link or image on its own doesn't count - the body needs real written substance.",
|
|
641
|
-
}
|
|
679
|
+
? null
|
|
642
680
|
: wordCount < 450
|
|
643
681
|
? {
|
|
644
682
|
label: "Word Count",
|
|
@@ -676,13 +714,15 @@ export function TechnicalTab({
|
|
|
676
714
|
|
|
677
715
|
return (
|
|
678
716
|
<div style={{ padding: 12, display: "flex", flexDirection: "column", gap: 10 }}>
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
717
|
+
{wordAudit && (
|
|
718
|
+
<AuditCard
|
|
719
|
+
anchorId="anchor-word-count"
|
|
720
|
+
label={wordAudit.label}
|
|
721
|
+
value={wordAudit.value}
|
|
722
|
+
status={wordAudit.status}
|
|
723
|
+
recommendation={wordAudit.recommendation}
|
|
724
|
+
/>
|
|
725
|
+
)}
|
|
686
726
|
|
|
687
727
|
{structureAudits.map((a, i) => (
|
|
688
728
|
<AuditCard
|