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/dist/index.mjs
CHANGED
|
@@ -6,11 +6,14 @@ import { createElement } from "react";
|
|
|
6
6
|
|
|
7
7
|
// src/components/SEOCopilotPanel.tsx
|
|
8
8
|
import { useState as useState16, useRef as useRef10, useCallback as useCallback5, useEffect as useEffect10, useMemo as useMemo5, Suspense } from "react";
|
|
9
|
+
import { useWorkspace } from "sanity";
|
|
9
10
|
import { createPortal } from "react-dom";
|
|
10
11
|
|
|
11
12
|
// src/hooks/useDocumentContent.ts
|
|
12
13
|
import { useState, useEffect, useRef } from "react";
|
|
13
14
|
import { useDocumentPane } from "sanity/structure";
|
|
15
|
+
|
|
16
|
+
// src/lib/documentExtract.ts
|
|
14
17
|
function extractText(blocks) {
|
|
15
18
|
if (!blocks || !Array.isArray(blocks)) return "";
|
|
16
19
|
const parts = [];
|
|
@@ -72,6 +75,72 @@ function extractBodyLinks(blocks) {
|
|
|
72
75
|
}
|
|
73
76
|
return Array.from(urls);
|
|
74
77
|
}
|
|
78
|
+
function detectSlug(val) {
|
|
79
|
+
if (!val) return void 0;
|
|
80
|
+
const slugTypeFields = ["slug", "url", "urlSlug", "permalink", "pathname"];
|
|
81
|
+
for (const f of slugTypeFields) {
|
|
82
|
+
const obj = val[f];
|
|
83
|
+
if (obj && typeof obj === "object" && typeof obj.current === "string" && obj.current.trim()) {
|
|
84
|
+
return obj.current.trim();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const stringFields = ["urlSlug", "url", "URL", "path", "permalink", "pathname"];
|
|
88
|
+
const slugShape = /^[a-z0-9._~-]+(?:\/[a-z0-9._~-]+)*\/?$/i;
|
|
89
|
+
for (const f of stringFields) {
|
|
90
|
+
const v = val[f];
|
|
91
|
+
if (typeof v === "string") {
|
|
92
|
+
const trimmed = v.trim();
|
|
93
|
+
if (trimmed && !/^https?:\/\//i.test(trimmed) && slugShape.test(trimmed)) {
|
|
94
|
+
return trimmed;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return void 0;
|
|
99
|
+
}
|
|
100
|
+
function detectAuthor(val) {
|
|
101
|
+
if (!val) return { authorIsReference: false };
|
|
102
|
+
const candidateFields = [
|
|
103
|
+
"author",
|
|
104
|
+
"authors",
|
|
105
|
+
"byline",
|
|
106
|
+
"articleAuthor",
|
|
107
|
+
"primaryAuthor",
|
|
108
|
+
"writer",
|
|
109
|
+
"writers",
|
|
110
|
+
"contributor",
|
|
111
|
+
"contributors",
|
|
112
|
+
"authorMapping",
|
|
113
|
+
// MJH schema - array of author references
|
|
114
|
+
"Author",
|
|
115
|
+
"Authors"
|
|
116
|
+
// PascalCase variants
|
|
117
|
+
];
|
|
118
|
+
for (const f of candidateFields) {
|
|
119
|
+
const raw = val[f];
|
|
120
|
+
if (!raw) continue;
|
|
121
|
+
const first = Array.isArray(raw) ? raw[0] : raw;
|
|
122
|
+
if (!first) continue;
|
|
123
|
+
if (typeof first === "string") {
|
|
124
|
+
const trimmed = first.trim();
|
|
125
|
+
if (trimmed) return { authorName: trimmed, authorIsReference: false };
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (typeof first === "object" && first !== null) {
|
|
129
|
+
const o = first;
|
|
130
|
+
const name = o.name || o.fullName || o.displayName;
|
|
131
|
+
const creds = o.credentials || o.title || o.suffix;
|
|
132
|
+
const slug = o.slug?.current;
|
|
133
|
+
const bio = o.bioUrl || (slug ? `/author/${slug}` : void 0);
|
|
134
|
+
if (name) {
|
|
135
|
+
return { authorName: name, authorCredentials: creds, authorBioUrl: bio, authorIsReference: false };
|
|
136
|
+
}
|
|
137
|
+
if (typeof o._ref === "string" || o._type === "reference") {
|
|
138
|
+
return { authorIsReference: true };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return { authorIsReference: false };
|
|
143
|
+
}
|
|
75
144
|
function extractImageMeta(value) {
|
|
76
145
|
const names = [];
|
|
77
146
|
const titles = [];
|
|
@@ -88,8 +157,56 @@ function extractImageMeta(value) {
|
|
|
88
157
|
if (typeof img.title === "string" && img.title) titles.push(img.title);
|
|
89
158
|
else if (asset && typeof asset.title === "string" && asset.title) titles.push(asset.title);
|
|
90
159
|
}
|
|
160
|
+
const body = value.body;
|
|
161
|
+
if (Array.isArray(body)) {
|
|
162
|
+
for (const blk of body) {
|
|
163
|
+
if (!blk || typeof blk !== "object") continue;
|
|
164
|
+
const b = blk;
|
|
165
|
+
if (b._type !== "figure" && b._type !== "image") continue;
|
|
166
|
+
const asset = b.asset && typeof b.asset === "object" ? b.asset : void 0;
|
|
167
|
+
if (!asset && b._type !== "image") continue;
|
|
168
|
+
count++;
|
|
169
|
+
if (typeof b.alt === "string" && b.alt) names.push(b.alt);
|
|
170
|
+
if (asset && typeof asset.originalFilename === "string" && asset.originalFilename) names.push(asset.originalFilename);
|
|
171
|
+
if (typeof b.title === "string" && b.title) titles.push(b.title);
|
|
172
|
+
else if (asset && typeof asset.title === "string" && asset.title) titles.push(asset.title);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
91
175
|
return { names, titles, count };
|
|
92
176
|
}
|
|
177
|
+
function buildDocumentFields(value) {
|
|
178
|
+
const val = value;
|
|
179
|
+
const title = val?.title;
|
|
180
|
+
const body = val?.body;
|
|
181
|
+
const { authorName, authorCredentials, authorBioUrl, authorIsReference } = detectAuthor(val);
|
|
182
|
+
const imageMeta = val ? extractImageMeta(val) : { names: [], titles: [], count: 0 };
|
|
183
|
+
return {
|
|
184
|
+
title: title || void 0,
|
|
185
|
+
// MJH uses `summary`; standard Sanity SEO plugins use `metaDescription`
|
|
186
|
+
metaDescription: val?.metaDescription || val?.summary || val?.description || val?.seoDescription,
|
|
187
|
+
slug: detectSlug(val),
|
|
188
|
+
imageNames: imageMeta.names,
|
|
189
|
+
imageTitles: imageMeta.titles,
|
|
190
|
+
imageCount: imageMeta.count,
|
|
191
|
+
headings: extractHeadings(body),
|
|
192
|
+
headingsDetailed: extractHeadingsDetailed(body),
|
|
193
|
+
bodyLinks: extractBodyLinks(body),
|
|
194
|
+
contentCategory: val?.contentCategory || val?.category,
|
|
195
|
+
contentPlacement: Array.isArray(val?.contentPlacement) ? val.contentPlacement : void 0,
|
|
196
|
+
authorName,
|
|
197
|
+
authorCredentials,
|
|
198
|
+
authorBioUrl,
|
|
199
|
+
authorIsReference,
|
|
200
|
+
// `published` is MJH's date field; `publishedAt`/`publishDate` cover other schemas
|
|
201
|
+
publishedAt: val?.published || val?.publishedAt || val?.publishDate || val?._createdAt,
|
|
202
|
+
// `updatedOn` is MJH's "Updated On" field. `updatedAt` is the standard Sanity convention.
|
|
203
|
+
// `_updatedAt` is the Sanity-managed timestamp as a final fallback.
|
|
204
|
+
updatedAt: val?.updatedOn || val?.updatedAt || val?._updatedAt,
|
|
205
|
+
lastReviewedAt: val?.lastReviewedAt || val?.lastReviewed || val?.medicallyReviewedAt
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/hooks/useDocumentContent.ts
|
|
93
210
|
function useDocumentContent() {
|
|
94
211
|
const { value, ready } = useDocumentPane();
|
|
95
212
|
const documentId = value?._id || void 0;
|
|
@@ -109,43 +226,7 @@ function useDocumentContent() {
|
|
|
109
226
|
useEffect(() => {
|
|
110
227
|
const bodyText = extractText(body);
|
|
111
228
|
const fullText = [title, bodyText].filter(Boolean).join("\n\n");
|
|
112
|
-
const
|
|
113
|
-
let authorName;
|
|
114
|
-
let authorCredentials;
|
|
115
|
-
let authorBioUrl;
|
|
116
|
-
let authorIsReference = false;
|
|
117
|
-
const author = val?.author || Array.isArray(val?.authors) && val.authors[0] || val?.byline;
|
|
118
|
-
if (typeof author === "string") {
|
|
119
|
-
authorName = author;
|
|
120
|
-
} else if (author && typeof author === "object") {
|
|
121
|
-
authorName = author.name || author.fullName || author.displayName;
|
|
122
|
-
authorCredentials = author.credentials || author.title || author.suffix;
|
|
123
|
-
authorBioUrl = author.bioUrl || (author.slug?.current ? `/author/${author.slug.current}` : void 0);
|
|
124
|
-
if (!authorName && typeof author._ref === "string") {
|
|
125
|
-
authorIsReference = true;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const imageMeta = val ? extractImageMeta(val) : { names: [], titles: [], count: 0 };
|
|
129
|
-
const fields = {
|
|
130
|
-
title: title || void 0,
|
|
131
|
-
metaDescription: val?.metaDescription || val?.summary || val?.description || val?.seoDescription,
|
|
132
|
-
slug: val?.slug?.current || void 0,
|
|
133
|
-
imageNames: imageMeta.names,
|
|
134
|
-
imageTitles: imageMeta.titles,
|
|
135
|
-
imageCount: imageMeta.count,
|
|
136
|
-
headings: extractHeadings(body),
|
|
137
|
-
headingsDetailed: extractHeadingsDetailed(body),
|
|
138
|
-
bodyLinks: extractBodyLinks(body),
|
|
139
|
-
contentCategory: val?.contentCategory || val?.category,
|
|
140
|
-
contentPlacement: Array.isArray(val?.contentPlacement) ? val.contentPlacement : void 0,
|
|
141
|
-
authorName,
|
|
142
|
-
authorCredentials,
|
|
143
|
-
authorBioUrl,
|
|
144
|
-
authorIsReference,
|
|
145
|
-
publishedAt: val?.publishedAt || val?.publishDate || val?._createdAt,
|
|
146
|
-
updatedAt: val?.updatedAt || val?._updatedAt,
|
|
147
|
-
lastReviewedAt: val?.lastReviewedAt || val?.lastReviewed || val?.medicallyReviewedAt
|
|
148
|
-
};
|
|
229
|
+
const fields = buildDocumentFields(value);
|
|
149
230
|
setDocumentFields(fields);
|
|
150
231
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
151
232
|
timerRef.current = setTimeout(() => {
|
|
@@ -355,6 +436,7 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
|
|
|
355
436
|
cacheInitializedRef.current = true;
|
|
356
437
|
return;
|
|
357
438
|
}
|
|
439
|
+
docVersionRef.current += 1;
|
|
358
440
|
const fresh = loadCached();
|
|
359
441
|
cached.current = fresh;
|
|
360
442
|
setAnalysisRaw(fresh.analysis);
|
|
@@ -391,6 +473,7 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
|
|
|
391
473
|
}
|
|
392
474
|
}, [text, deepAnalysis, aeoTextSnapshot]);
|
|
393
475
|
const lastAnalysisRef = useRef2(null);
|
|
476
|
+
const docVersionRef = useRef2(0);
|
|
394
477
|
useEffect2(() => {
|
|
395
478
|
if ((!text || text.trim().length < 20) && (!effectiveSeeds || effectiveSeeds.length === 0)) {
|
|
396
479
|
setAnalysis(null);
|
|
@@ -430,6 +513,7 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
|
|
|
430
513
|
}, [text, apiUrl, publication, effectiveSeeds?.join(","), focusPrimary]);
|
|
431
514
|
const doVolumeLookup = useCallback((analysisResult, terms) => {
|
|
432
515
|
setIsVolumesLoading(true);
|
|
516
|
+
const myVersion = docVersionRef.current;
|
|
433
517
|
const lookupTerms = terms || (() => {
|
|
434
518
|
const candidateTerms = (analysisResult.primaryKeywordCandidates || []).map((c) => c.term);
|
|
435
519
|
return [
|
|
@@ -446,6 +530,7 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
|
|
|
446
530
|
return;
|
|
447
531
|
}
|
|
448
532
|
lookupKeywords(apiUrl, lookupTerms).then(({ results }) => {
|
|
533
|
+
if (docVersionRef.current !== myVersion) return;
|
|
449
534
|
results.forEach((r) => volumeMapRef.current.set(r.keyword.toLowerCase(), r));
|
|
450
535
|
const current = lastAnalysisRef.current || analysisResult;
|
|
451
536
|
const merged = mergeVolumes(current, volumeMapRef.current);
|
|
@@ -458,6 +543,7 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
|
|
|
458
543
|
}
|
|
459
544
|
setIsVolumesLoading(false);
|
|
460
545
|
}).catch(() => {
|
|
546
|
+
if (docVersionRef.current !== myVersion) return;
|
|
461
547
|
setIsVolumesLoading(false);
|
|
462
548
|
});
|
|
463
549
|
}, [apiUrl, cacheKey]);
|
|
@@ -472,10 +558,13 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
|
|
|
472
558
|
setError(null);
|
|
473
559
|
setAeoContentChanged(false);
|
|
474
560
|
setAeoTextSnapshot(text);
|
|
561
|
+
const myVersion = docVersionRef.current;
|
|
475
562
|
fetchAnalysis(apiUrl, text, "deep", publication, effectiveSeeds, documentFields, focusPrimary).then((result) => {
|
|
563
|
+
if (docVersionRef.current !== myVersion) return;
|
|
476
564
|
setDeepAnalysis(result);
|
|
477
565
|
setIsDeepLoading(false);
|
|
478
566
|
}).catch((err) => {
|
|
567
|
+
if (docVersionRef.current !== myVersion) return;
|
|
479
568
|
setError(err.message);
|
|
480
569
|
setIsDeepLoading(false);
|
|
481
570
|
});
|
|
@@ -580,6 +669,7 @@ function useSEOChat(apiUrl, documentText, publication, keywordPanelData, documen
|
|
|
580
669
|
}, [apiUrl, documentId, publication]);
|
|
581
670
|
const sendMessage = useCallback2(
|
|
582
671
|
async (text) => {
|
|
672
|
+
const myVersion = opVersionRef.current;
|
|
583
673
|
const userMessage = { role: "user", content: text };
|
|
584
674
|
const updatedMessages = [...messages, userMessage];
|
|
585
675
|
setMessages(updatedMessages);
|
|
@@ -599,10 +689,25 @@ function useSEOChat(apiUrl, documentText, publication, keywordPanelData, documen
|
|
|
599
689
|
const reader = stream.getReader();
|
|
600
690
|
const decoder = new TextDecoder();
|
|
601
691
|
let assistantContent = "";
|
|
692
|
+
if (opVersionRef.current !== myVersion) {
|
|
693
|
+
try {
|
|
694
|
+
await reader.cancel();
|
|
695
|
+
} catch {
|
|
696
|
+
}
|
|
697
|
+
setIsStreaming(false);
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
602
700
|
setMessages((prev) => [...prev, { role: "assistant", content: "" }]);
|
|
603
701
|
while (true) {
|
|
604
702
|
const { done, value } = await reader.read();
|
|
605
703
|
if (done) break;
|
|
704
|
+
if (opVersionRef.current !== myVersion) {
|
|
705
|
+
try {
|
|
706
|
+
await reader.cancel();
|
|
707
|
+
} catch {
|
|
708
|
+
}
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
606
711
|
const chunk = decoder.decode(value, { stream: true });
|
|
607
712
|
const lines = chunk.split("\n");
|
|
608
713
|
for (const line of lines) {
|
|
@@ -627,19 +732,25 @@ function useSEOChat(apiUrl, documentText, publication, keywordPanelData, documen
|
|
|
627
732
|
}
|
|
628
733
|
}
|
|
629
734
|
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
735
|
+
if (opVersionRef.current === myVersion) {
|
|
736
|
+
const finalMessages = [
|
|
737
|
+
...updatedMessages,
|
|
738
|
+
{ role: "assistant", content: assistantContent }
|
|
739
|
+
];
|
|
740
|
+
scheduleSave(finalMessages);
|
|
741
|
+
}
|
|
635
742
|
} catch (err) {
|
|
743
|
+
if (opVersionRef.current !== myVersion) {
|
|
744
|
+
setIsStreaming(false);
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
636
747
|
const errorMsg = err instanceof Error ? err.message : "Chat failed";
|
|
637
748
|
setMessages((prev) => [
|
|
638
749
|
...prev,
|
|
639
750
|
{ role: "assistant", content: `Error: ${errorMsg}` }
|
|
640
751
|
]);
|
|
641
752
|
}
|
|
642
|
-
setIsStreaming(false);
|
|
753
|
+
if (opVersionRef.current === myVersion) setIsStreaming(false);
|
|
643
754
|
},
|
|
644
755
|
[messages, apiUrl, documentText, publication, keywordPanelData, scheduleSave]
|
|
645
756
|
);
|
|
@@ -1497,12 +1608,9 @@ function PrimaryKeywordSelector({
|
|
|
1497
1608
|
fontWeight: isSelected ? 600 : 400,
|
|
1498
1609
|
color: isSelected ? "#166534" : "#374151"
|
|
1499
1610
|
}, children: candidate.term }),
|
|
1500
|
-
candidate.volume != null && /* @__PURE__ */
|
|
1501
|
-
abbrevVol(candidate.volume),
|
|
1502
|
-
"/mo"
|
|
1503
|
-
] }),
|
|
1611
|
+
candidate.volume != null && /* @__PURE__ */ jsx5("span", { style: { fontSize: 11, fontWeight: 600, color: "#1f2937" }, children: candidate.volume === 0 ? "N/A" : `${abbrevVol(candidate.volume)}/mo` }),
|
|
1504
1612
|
/* @__PURE__ */ jsxs4("span", { style: { fontSize: 10, color: "#1f2937" }, children: [
|
|
1505
|
-
Math.round(candidate.confidence * 100),
|
|
1613
|
+
Math.round((candidate.confidence ?? 0) * 100),
|
|
1506
1614
|
"% confidence"
|
|
1507
1615
|
] })
|
|
1508
1616
|
] }),
|
|
@@ -1919,10 +2027,7 @@ function SuggestedKeywordsCard({
|
|
|
1919
2027
|
} }),
|
|
1920
2028
|
/* @__PURE__ */ jsx5("span", { style: { fontSize: 12, fontWeight: kw.inContent ? 500 : 600, flexGrow: 1, color: "#1f2937" }, children: kw.term }),
|
|
1921
2029
|
enrichingTerms.has(kw.term) && /* @__PURE__ */ jsx5(LoadingBars, { size: "xs", color: "#6b7280" }),
|
|
1922
|
-
!enrichingTerms.has(kw.term) && kw.volume != null && /* @__PURE__ */
|
|
1923
|
-
abbrevVol(kw.volume),
|
|
1924
|
-
"/mo"
|
|
1925
|
-
] }),
|
|
2030
|
+
!enrichingTerms.has(kw.term) && kw.volume != null && /* @__PURE__ */ jsx5("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#1f2937", flexShrink: 0 }, title: "Monthly searches", children: kw.volume === 0 ? "N/A" : `${abbrevVol(kw.volume)}/mo` }),
|
|
1926
2031
|
kw.placement && /* @__PURE__ */ jsx5(PlacementIndicators, { placement: kw.placement }),
|
|
1927
2032
|
!kw.inContent && /* @__PURE__ */ jsx5(LightbulbButton, { onClick: () => fetchHelp(kw.term), isLoading: loadingTerm === kw.term })
|
|
1928
2033
|
] }),
|
|
@@ -2744,7 +2849,7 @@ var DEFAULT_GENERATE_ALL_MESSAGES = [
|
|
|
2744
2849
|
];
|
|
2745
2850
|
|
|
2746
2851
|
// src/lib/scoring.ts
|
|
2747
|
-
function calculateContentScoreDetailed(content, analysis) {
|
|
2852
|
+
function calculateContentScoreDetailed(content, analysis, documentFields) {
|
|
2748
2853
|
if (!content || !analysis) {
|
|
2749
2854
|
return { total: 0, components: [] };
|
|
2750
2855
|
}
|
|
@@ -2757,13 +2862,14 @@ function calculateContentScoreDetailed(content, analysis) {
|
|
|
2757
2862
|
const primaryRegex = new RegExp(escaped, "gi");
|
|
2758
2863
|
const primaryMatches = content.match(primaryRegex);
|
|
2759
2864
|
const primaryCount = primaryMatches?.length || 0;
|
|
2865
|
+
const primaryWordCount = Math.max(1, primaryTerm.split(/\s+/).filter(Boolean).length);
|
|
2760
2866
|
let pts = 0;
|
|
2761
2867
|
let detail;
|
|
2762
2868
|
if (primaryCount === 0) {
|
|
2763
2869
|
detail = `Primary keyword "${primaryTerm}" not found in content`;
|
|
2764
2870
|
} else {
|
|
2765
2871
|
pts += 12;
|
|
2766
|
-
const density = words > 0 ? primaryCount / words * 100 : 0;
|
|
2872
|
+
const density = words > 0 ? primaryCount * primaryWordCount / words * 100 : 0;
|
|
2767
2873
|
if (density >= 0.5 && density <= 2.5) {
|
|
2768
2874
|
pts += 13;
|
|
2769
2875
|
detail = `Primary keyword present, density ${density.toFixed(2)}% (ideal range)`;
|
|
@@ -2808,10 +2914,18 @@ function calculateContentScoreDetailed(content, analysis) {
|
|
|
2808
2914
|
wcDetail = `${words} words - start writing`;
|
|
2809
2915
|
}
|
|
2810
2916
|
components.push({ label: "Word count", points: wcPts, max: 15, detail: wcDetail });
|
|
2811
|
-
|
|
2812
|
-
|
|
2917
|
+
let hasH1orTitle;
|
|
2918
|
+
let hasSubheadings;
|
|
2919
|
+
if (documentFields) {
|
|
2920
|
+
hasH1orTitle = !!(documentFields.title && documentFields.title.trim());
|
|
2921
|
+
const det = documentFields.headingsDetailed;
|
|
2922
|
+
hasSubheadings = det ? det.some((h) => h.level >= 2 && h.level <= 4) : (documentFields.headings?.length || 0) > 0;
|
|
2923
|
+
} else {
|
|
2924
|
+
hasH1orTitle = /^#\s|<h1/im.test(content);
|
|
2925
|
+
hasSubheadings = /^##\s|^###\s|<h2|<h3/im.test(content);
|
|
2926
|
+
}
|
|
2813
2927
|
const structurePts = (hasH1orTitle ? 5 : 0) + (hasSubheadings ? 5 : 0);
|
|
2814
|
-
const structureDetail = !hasH1orTitle && !hasSubheadings ? "No
|
|
2928
|
+
const structureDetail = !hasH1orTitle && !hasSubheadings ? "No title or subheadings detected" : !hasSubheadings ? "Has a title but no H2/H3 subheadings - add section headings" : !hasH1orTitle ? "Has subheadings but no title" : "Title and subheadings present";
|
|
2815
2929
|
components.push({ label: "Heading structure", points: structurePts, max: 10, detail: structureDetail });
|
|
2816
2930
|
const missingCount = (analysis.missingKeywords || []).length;
|
|
2817
2931
|
let mPts = 0;
|
|
@@ -2829,13 +2943,17 @@ function calculateContentScoreDetailed(content, analysis) {
|
|
|
2829
2943
|
mDetail = `${missingCount} suggested keywords missing - significant gaps`;
|
|
2830
2944
|
}
|
|
2831
2945
|
components.push({ label: "Missing keyword gap", points: mPts, max: 15, detail: mDetail });
|
|
2946
|
+
let qCount;
|
|
2947
|
+
if (documentFields) {
|
|
2948
|
+
qCount = (documentFields.headings || []).filter((h) => h.trim().endsWith("?")).length;
|
|
2949
|
+
} else {
|
|
2950
|
+
const questionHeadings = content.match(/^#{1,6}\s+.*\?$/gm) || content.match(/<h[1-6][^>]*>.*\?<\/h[1-6]>/gi);
|
|
2951
|
+
qCount = questionHeadings?.length || 0;
|
|
2952
|
+
}
|
|
2832
2953
|
let aeoPts = 0;
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
if (qCount
|
|
2836
|
-
else if (qCount === 2) aeoPts += 4;
|
|
2837
|
-
else if (qCount === 1) aeoPts += 2;
|
|
2838
|
-
if (qCount > 0) aeoPts += 4;
|
|
2954
|
+
if (qCount >= 3) aeoPts = 10;
|
|
2955
|
+
else if (qCount === 2) aeoPts = 7;
|
|
2956
|
+
else if (qCount === 1) aeoPts = 4;
|
|
2839
2957
|
const aeoDetail = qCount === 0 ? "No question-style headings - AI answer engines favor them" : `${qCount} question heading${qCount === 1 ? "" : "s"}`;
|
|
2840
2958
|
components.push({ label: "AEO signals", points: aeoPts, max: 10, detail: aeoDetail });
|
|
2841
2959
|
const total = components.reduce((sum, c) => sum + c.points, 0);
|
|
@@ -2850,6 +2968,15 @@ function tokensContain(haystack, needle) {
|
|
|
2850
2968
|
const lower = haystack.toLowerCase();
|
|
2851
2969
|
return tokens.every((t) => lower.includes(t));
|
|
2852
2970
|
}
|
|
2971
|
+
function isShortFormContent(documentFields, title) {
|
|
2972
|
+
const shortFormCats = /* @__PURE__ */ new Set(["news", "brief", "preview", "recap", "update", "announcement", "roundup", "digest", "interview"]);
|
|
2973
|
+
const catTokens = (documentFields?.contentCategory || "").toLowerCase().split(/[^a-z]+/).filter(Boolean);
|
|
2974
|
+
if (catTokens.some((tok) => shortFormCats.has(tok))) return true;
|
|
2975
|
+
const t = (title || "").toLowerCase();
|
|
2976
|
+
if (/\b(preview|recap|roundup|digest)\b/.test(t)) return true;
|
|
2977
|
+
if (/:\s*\d+\s+(trials|things|takeaways|highlights|tips|questions|charts)/.test(t)) return true;
|
|
2978
|
+
return false;
|
|
2979
|
+
}
|
|
2853
2980
|
function buildSummaryItems(input) {
|
|
2854
2981
|
const items = [];
|
|
2855
2982
|
const { analysis, deepAnalysis, documentFields, linkingSuggestions, linkCheckResults, text } = input;
|
|
@@ -2991,20 +3118,20 @@ function buildSummaryItems(input) {
|
|
|
2991
3118
|
howToFix: "Add more body text. A link or image on its own doesn't count - the article needs real written substance.",
|
|
2992
3119
|
jumpTo: { tab: "technical", anchorId: "anchor-word-count" }
|
|
2993
3120
|
});
|
|
2994
|
-
} else if (wordCount2 < 1500) {
|
|
3121
|
+
} else if (wordCount2 < 1500 && !isShortFormContent(documentFields, title)) {
|
|
2995
3122
|
items.push({
|
|
2996
3123
|
id: "content-short-for-clinical",
|
|
2997
3124
|
category: "content",
|
|
2998
|
-
severity: "
|
|
3125
|
+
severity: "opportunity",
|
|
2999
3126
|
label: "Article could be longer",
|
|
3000
|
-
description: `${wordCount2} words. 1,500+
|
|
3001
|
-
howToFix: "
|
|
3127
|
+
description: `${wordCount2} words. For evergreen clinical topics 1,500+ tends to rank better - news, previews, and briefs are fine shorter.`,
|
|
3128
|
+
howToFix: "If this is an in-depth clinical piece, expand with citations, comparative data, or guideline references. For news or previews, this length is appropriate.",
|
|
3002
3129
|
jumpTo: { tab: "technical", anchorId: "anchor-word-count" }
|
|
3003
3130
|
});
|
|
3004
3131
|
}
|
|
3005
3132
|
const headings = documentFields?.headings || [];
|
|
3006
3133
|
const headingsDetailed = documentFields?.headingsDetailed;
|
|
3007
|
-
const h2Count = headingsDetailed ? headingsDetailed.filter((h) => h.level === 2).length : headings.length;
|
|
3134
|
+
const h2Count = headingsDetailed ? headingsDetailed.filter((h) => h.level === 2 || h.level === 3).length : headings.length;
|
|
3008
3135
|
if (headings.length === 0 && wordCount2 > 200 && wordCount2 < 1e3) {
|
|
3009
3136
|
items.push({
|
|
3010
3137
|
id: "headings-missing",
|
|
@@ -3169,9 +3296,21 @@ function buildSummaryItems(input) {
|
|
|
3169
3296
|
jumpTo: { tab: "keywords" }
|
|
3170
3297
|
});
|
|
3171
3298
|
}
|
|
3299
|
+
const primaryVolume = analysis?.primaryKeyword?.volume;
|
|
3300
|
+
if (deepAnalysis && (primaryVolume === 0 || primaryVolume === null)) {
|
|
3301
|
+
items.push({
|
|
3302
|
+
id: "keywords-primary-zero-volume",
|
|
3303
|
+
category: "keywords",
|
|
3304
|
+
severity: "warning",
|
|
3305
|
+
label: "Primary keyword has no search volume",
|
|
3306
|
+
description: `"${primaryKeyword}" shows no measurable monthly searches, so even ranking #1 brings little traffic.`,
|
|
3307
|
+
howToFix: "Pick a primary people actually search for - check your supporting keywords for higher-volume options, or set a new primary on the Keywords tab.",
|
|
3308
|
+
jumpTo: { tab: "keywords" }
|
|
3309
|
+
});
|
|
3310
|
+
}
|
|
3172
3311
|
}
|
|
3173
|
-
const
|
|
3174
|
-
if (deepAnalysis &&
|
|
3312
|
+
const actualQuestionHeadings = (documentFields?.headings || []).filter((h) => h.trim().endsWith("?"));
|
|
3313
|
+
if (deepAnalysis && actualQuestionHeadings.length === 0 && wordCount2 > 300) {
|
|
3175
3314
|
items.push({
|
|
3176
3315
|
id: "aeo-no-question-headings",
|
|
3177
3316
|
category: "aeo",
|
|
@@ -3219,6 +3358,18 @@ function buildSummaryItems(input) {
|
|
|
3219
3358
|
jumpTo: { tab: "technical", anchorId: "anchor-link-check" }
|
|
3220
3359
|
});
|
|
3221
3360
|
}
|
|
3361
|
+
const unverified = linkCheckResults.filter((r) => r.category === "unverified");
|
|
3362
|
+
if (unverified.length > 0) {
|
|
3363
|
+
items.push({
|
|
3364
|
+
id: "unverified-links",
|
|
3365
|
+
category: "technical",
|
|
3366
|
+
severity: "warning",
|
|
3367
|
+
label: `${unverified.length} link${unverified.length === 1 ? "" : "s"} couldn't be auto-verified`,
|
|
3368
|
+
description: `${unverified.length} link${unverified.length === 1 ? " was" : "s were"} blocked by an anti-bot wall (401/403/429) - the URLs may work fine for readers, our server just couldn't confirm.`,
|
|
3369
|
+
howToFix: "Open each one manually in a new tab to confirm it loads, then ignore the warning if it does.",
|
|
3370
|
+
jumpTo: { tab: "technical", anchorId: "anchor-link-check" }
|
|
3371
|
+
});
|
|
3372
|
+
}
|
|
3222
3373
|
}
|
|
3223
3374
|
if (deepAnalysis) {
|
|
3224
3375
|
const readability = deepAnalysis.readabilityNotes || [];
|
|
@@ -3455,8 +3606,8 @@ function SummaryTab({
|
|
|
3455
3606
|
}) {
|
|
3456
3607
|
const scoreDetail = useMemo(() => {
|
|
3457
3608
|
if (!analysis) return null;
|
|
3458
|
-
return calculateContentScoreDetailed(text, analysis);
|
|
3459
|
-
}, [text, analysis]);
|
|
3609
|
+
return calculateContentScoreDetailed(text, analysis, documentFields);
|
|
3610
|
+
}, [text, analysis, documentFields]);
|
|
3460
3611
|
const score = scoreDetail?.total ?? null;
|
|
3461
3612
|
const items = useMemo(
|
|
3462
3613
|
() => buildSummaryItems({
|
|
@@ -3571,9 +3722,12 @@ function wordCount(s) {
|
|
|
3571
3722
|
}
|
|
3572
3723
|
function analyzeHeadings(text, headings) {
|
|
3573
3724
|
if (!text || headings.length === 0) return [];
|
|
3725
|
+
const isQuestion = (h) => /\?\s*$/.test(h.trim());
|
|
3726
|
+
const questionHeadings = headings.filter(isQuestion);
|
|
3727
|
+
if (questionHeadings.length === 0) return [];
|
|
3574
3728
|
const headingSet = new Set(headings.map((h) => h.trim().toLowerCase()));
|
|
3575
3729
|
const lower = text.toLowerCase();
|
|
3576
|
-
return
|
|
3730
|
+
return questionHeadings.map((heading) => {
|
|
3577
3731
|
const needle = heading.trim().toLowerCase();
|
|
3578
3732
|
const idx = lower.indexOf(needle);
|
|
3579
3733
|
if (idx === -1) {
|
|
@@ -3605,7 +3759,7 @@ function analyzeFactDensity(text) {
|
|
|
3605
3759
|
const matches = text.match(new RegExp(FACT_PATTERN.source, "gi")) || [];
|
|
3606
3760
|
const factCount = matches.length;
|
|
3607
3761
|
const factsPer1000 = Math.round(factCount / total * 1e3);
|
|
3608
|
-
const sentences = text.split(/
|
|
3762
|
+
const sentences = text.split(/[.!?]+\s+/).filter((s) => s.trim().length > 0);
|
|
3609
3763
|
let drift = 0;
|
|
3610
3764
|
let runWords = 0;
|
|
3611
3765
|
let runHasFact = false;
|
|
@@ -3620,7 +3774,7 @@ function analyzeFactDensity(text) {
|
|
|
3620
3774
|
}
|
|
3621
3775
|
}
|
|
3622
3776
|
let status;
|
|
3623
|
-
if (factsPer1000 >= 8
|
|
3777
|
+
if (factsPer1000 >= 8) status = "strong";
|
|
3624
3778
|
else if (factsPer1000 >= 4) status = "moderate";
|
|
3625
3779
|
else status = "weak";
|
|
3626
3780
|
return { totalWords: total, factCount, factsPerThousandWords: factsPer1000, driftPassages: drift, status };
|
|
@@ -3709,9 +3863,11 @@ function CopyButton({ text }) {
|
|
|
3709
3863
|
function GEOCard({ geo, publication }) {
|
|
3710
3864
|
const [showDetails, setShowDetails] = usePersistentState("seo-copilot-ui-geo-details", false);
|
|
3711
3865
|
const fd = geo.factDensity;
|
|
3712
|
-
const
|
|
3713
|
-
const
|
|
3714
|
-
const
|
|
3866
|
+
const isShort = fd.totalWords > 0 && fd.totalWords < 600;
|
|
3867
|
+
const effectiveStatus = fd.status === "weak" && isShort ? "moderate" : fd.status;
|
|
3868
|
+
const fdColor = effectiveStatus === "strong" ? "#16a34a" : effectiveStatus === "moderate" ? "#8B7310" : "#dc2626";
|
|
3869
|
+
const fdLabel = fd.status === "strong" ? "Strong" : fd.status === "moderate" ? "Moderate" : isShort ? "Light (short-form)" : "Weak";
|
|
3870
|
+
const fdBg = effectiveStatus === "strong" ? "rgba(22,163,74,0.1)" : effectiveStatus === "moderate" ? "rgba(230,192,27,0.15)" : "rgba(220,38,38,0.08)";
|
|
3715
3871
|
const goodCount = geo.headingAudit.filter((h) => h.status === "good").length;
|
|
3716
3872
|
const totalHeadings = geo.headingAudit.length;
|
|
3717
3873
|
return /* @__PURE__ */ jsxs9("div", { style: cardStyle3, children: [
|
|
@@ -3769,7 +3925,7 @@ function GEOCard({ geo, publication }) {
|
|
|
3769
3925
|
fd.factsPerThousandWords,
|
|
3770
3926
|
" per 1,000 words).",
|
|
3771
3927
|
" ",
|
|
3772
|
-
fd.status === "strong" ? "AI engines prefer this density." : fd.status === "moderate" ? "Aim for 8+ per 1,000 words with named sources (NEJM, JAMA, FDA, trial numbers, p-values)." : "Vague claims get skipped. Add specific numbers, trial citations, or dates."
|
|
3928
|
+
fd.status === "strong" ? "AI engines prefer this density." : fd.status === "moderate" ? "Aim for 8+ per 1,000 words with named sources (NEJM, JAMA, FDA, trial numbers, p-values)." : isShort ? "Short-form content naturally has fewer stats - fine for news and previews. Add a citation or two where you can." : "Vague claims get skipped. Add specific numbers, trial citations, or dates."
|
|
3773
3929
|
] })
|
|
3774
3930
|
] })
|
|
3775
3931
|
]
|
|
@@ -4778,11 +4934,9 @@ function daysSince(iso) {
|
|
|
4778
4934
|
}
|
|
4779
4935
|
function formatDateShort(iso) {
|
|
4780
4936
|
if (!iso) return "";
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
return "";
|
|
4785
|
-
}
|
|
4937
|
+
const d = new Date(iso);
|
|
4938
|
+
if (isNaN(d.getTime())) return "";
|
|
4939
|
+
return d.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" });
|
|
4786
4940
|
}
|
|
4787
4941
|
function MetaTab({ documentFields, primaryKeyword, isLoading }) {
|
|
4788
4942
|
const audits = useMemo3(() => {
|
|
@@ -4801,7 +4955,7 @@ function MetaTab({ documentFields, primaryKeyword, isLoading }) {
|
|
|
4801
4955
|
if (!author && authorIsRef) {
|
|
4802
4956
|
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." });
|
|
4803
4957
|
} else if (!author) {
|
|
4804
|
-
items.push({ label: "Author Byline", value: "Missing", status: "
|
|
4958
|
+
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." });
|
|
4805
4959
|
} else if (!creds) {
|
|
4806
4960
|
items.push({ label: "Author Byline", value: author, status: "warning", recommendation: "Author shown but credentials (MD, PharmD, RN, etc.) aren't visible. Add credential suffixes." });
|
|
4807
4961
|
} else if (!bio) {
|
|
@@ -4818,6 +4972,8 @@ function MetaTab({ documentFields, primaryKeyword, isLoading }) {
|
|
|
4818
4972
|
const freshness = Math.min(...[daysUpd, daysRev, daysPub].filter((d) => d !== null));
|
|
4819
4973
|
if (!published) {
|
|
4820
4974
|
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." });
|
|
4975
|
+
} else if (daysPub === null) {
|
|
4976
|
+
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." });
|
|
4821
4977
|
} else {
|
|
4822
4978
|
items.push({ label: "Publish Date", value: formatDateShort(published), status: "good" });
|
|
4823
4979
|
}
|
|
@@ -5006,9 +5162,11 @@ function imageFilenameAudit(filenames) {
|
|
|
5006
5162
|
function imageAltTextAudit(altTexts) {
|
|
5007
5163
|
if (altTexts.length === 0) return null;
|
|
5008
5164
|
const issues = [];
|
|
5165
|
+
let audited = 0;
|
|
5009
5166
|
for (const alt of altTexts) {
|
|
5010
5167
|
const trimmed = alt.trim();
|
|
5011
5168
|
if (!trimmed) continue;
|
|
5169
|
+
audited++;
|
|
5012
5170
|
const len = trimmed.length;
|
|
5013
5171
|
const wc = trimmed.split(/\s+/).filter(Boolean).length;
|
|
5014
5172
|
if (len > 125) {
|
|
@@ -5017,10 +5175,11 @@ function imageAltTextAudit(altTexts) {
|
|
|
5017
5175
|
issues.push({ alt: trimmed, reason: "just one word - use 2-5 descriptive keywords" });
|
|
5018
5176
|
}
|
|
5019
5177
|
}
|
|
5178
|
+
if (audited === 0) return null;
|
|
5020
5179
|
if (issues.length === 0) {
|
|
5021
5180
|
return {
|
|
5022
5181
|
label: "Image Alt Text",
|
|
5023
|
-
value: `${
|
|
5182
|
+
value: `${audited} alt text${audited === 1 ? "" : "s"} look well-formed`,
|
|
5024
5183
|
status: "good"
|
|
5025
5184
|
};
|
|
5026
5185
|
}
|
|
@@ -5030,7 +5189,7 @@ function imageAltTextAudit(altTexts) {
|
|
|
5030
5189
|
}).join("; ");
|
|
5031
5190
|
return {
|
|
5032
5191
|
label: "Image Alt Text",
|
|
5033
|
-
value: `${issues.length} of ${
|
|
5192
|
+
value: `${issues.length} of ${audited} alt text${audited === 1 ? "" : "s"} need attention`,
|
|
5034
5193
|
status: "warning",
|
|
5035
5194
|
recommendation: `${examples}. Alt text should be 2-5 descriptive keywords that describe the image, ideally including the primary keyword, and stay under 125 characters.`
|
|
5036
5195
|
};
|
|
@@ -5038,6 +5197,7 @@ function imageAltTextAudit(altTexts) {
|
|
|
5038
5197
|
function imageTitleAudit(titles, imageCount) {
|
|
5039
5198
|
if (imageCount <= 0) return null;
|
|
5040
5199
|
const withTitle = titles.length;
|
|
5200
|
+
if (withTitle === 0) return null;
|
|
5041
5201
|
const missing = imageCount - withTitle;
|
|
5042
5202
|
if (missing > 0) {
|
|
5043
5203
|
return {
|
|
@@ -5064,30 +5224,30 @@ function imageTitleAudit(titles, imageCount) {
|
|
|
5064
5224
|
}
|
|
5065
5225
|
function computeHeadingStructureAudits(headings, wordCount2) {
|
|
5066
5226
|
const audits = [];
|
|
5067
|
-
const
|
|
5227
|
+
const sectionCount = headings.filter((h) => h.level === 2 || h.level === 3).length;
|
|
5068
5228
|
let densityFired = false;
|
|
5069
|
-
if (wordCount2 >= 1e3 &&
|
|
5229
|
+
if (wordCount2 >= 1e3 && sectionCount === 0) {
|
|
5070
5230
|
audits.push({
|
|
5071
5231
|
label: "Section Headings",
|
|
5072
|
-
value: `No
|
|
5232
|
+
value: `No section headings in a ${wordCount2}-word article`,
|
|
5073
5233
|
status: "error",
|
|
5074
|
-
recommendation: "Articles this long need section headings. Add 2-3 H2 headings to break the body into scannable sections."
|
|
5234
|
+
recommendation: "Articles this long need section headings. Add 2-3 H2 (or H3) headings to break the body into scannable sections."
|
|
5075
5235
|
});
|
|
5076
5236
|
densityFired = true;
|
|
5077
|
-
} else if (wordCount2 >= 2500 &&
|
|
5237
|
+
} else if (wordCount2 >= 2500 && sectionCount < 5) {
|
|
5078
5238
|
audits.push({
|
|
5079
5239
|
label: "Section Headings",
|
|
5080
|
-
value: `${
|
|
5240
|
+
value: `${sectionCount} section heading${sectionCount === 1 ? "" : "s"} for a ${wordCount2}-word article`,
|
|
5081
5241
|
status: "warning",
|
|
5082
|
-
recommendation: "Long articles read best with 1
|
|
5242
|
+
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."
|
|
5083
5243
|
});
|
|
5084
5244
|
densityFired = true;
|
|
5085
|
-
} else if (wordCount2 >= 1500 &&
|
|
5245
|
+
} else if (wordCount2 >= 1500 && sectionCount < 3) {
|
|
5086
5246
|
audits.push({
|
|
5087
5247
|
label: "Section Headings",
|
|
5088
|
-
value: `${
|
|
5248
|
+
value: `${sectionCount} section heading${sectionCount === 1 ? "" : "s"} for a ${wordCount2}-word article`,
|
|
5089
5249
|
status: "warning",
|
|
5090
|
-
recommendation: "Articles above 1,500 words usually need at least 3
|
|
5250
|
+
recommendation: "Articles above 1,500 words usually need at least 3 named sections. Add section breaks so the outline is scannable."
|
|
5091
5251
|
});
|
|
5092
5252
|
densityFired = true;
|
|
5093
5253
|
}
|
|
@@ -5160,8 +5320,9 @@ function LinkCheckCard({
|
|
|
5160
5320
|
const redirects = results.filter((r) => r.category === "redirect").length;
|
|
5161
5321
|
const broken = results.filter((r) => r.category === "broken").length;
|
|
5162
5322
|
const errored = results.filter((r) => r.category === "error").length;
|
|
5323
|
+
const unverified = results.filter((r) => r.category === "unverified").length;
|
|
5163
5324
|
const issues = results.filter((r) => r.category !== "ok");
|
|
5164
|
-
return { total, valid, redirects, broken, errored, issues };
|
|
5325
|
+
return { total, valid, redirects, broken, errored, unverified, issues };
|
|
5165
5326
|
}, [results]);
|
|
5166
5327
|
return /* @__PURE__ */ jsxs13("div", { id: "anchor-link-check", style: cardStyle6, children: [
|
|
5167
5328
|
/* @__PURE__ */ jsxs13("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, marginBottom: 6 }, children: [
|
|
@@ -5257,12 +5418,34 @@ function LinkCheckCard({
|
|
|
5257
5418
|
}
|
|
5258
5419
|
),
|
|
5259
5420
|
hasRun && !isLoading && !error && /* @__PURE__ */ jsxs13(Fragment7, { children: [
|
|
5260
|
-
/* @__PURE__ */ jsxs13("div", { style: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 6 }, children: [
|
|
5421
|
+
/* @__PURE__ */ jsxs13("div", { style: { display: "grid", gridTemplateColumns: counts.unverified > 0 ? "repeat(5, 1fr)" : "repeat(4, 1fr)", gap: 6 }, children: [
|
|
5261
5422
|
/* @__PURE__ */ jsx14(StatTile, { label: "Checked", value: counts.total, color: "#475569" }),
|
|
5262
5423
|
/* @__PURE__ */ jsx14(StatTile, { label: "Valid", value: counts.valid, color: "#16a34a" }),
|
|
5263
5424
|
/* @__PURE__ */ jsx14(StatTile, { label: "Redirects", value: counts.redirects, color: "#8B7310" }),
|
|
5264
|
-
/* @__PURE__ */ jsx14(StatTile, { label: "Broken", value: counts.broken + counts.errored, color: "#dc2626" })
|
|
5425
|
+
/* @__PURE__ */ jsx14(StatTile, { label: "Broken", value: counts.broken + counts.errored, color: "#dc2626" }),
|
|
5426
|
+
counts.unverified > 0 && /* @__PURE__ */ jsx14(StatTile, { label: "Blocked", value: counts.unverified, color: "#b45309" })
|
|
5265
5427
|
] }),
|
|
5428
|
+
counts.unverified > 0 && /* @__PURE__ */ jsxs13(
|
|
5429
|
+
"div",
|
|
5430
|
+
{
|
|
5431
|
+
style: {
|
|
5432
|
+
marginTop: 8,
|
|
5433
|
+
padding: "6px 10px",
|
|
5434
|
+
background: "rgba(245,158,11,0.08)",
|
|
5435
|
+
border: "1px solid rgba(245,158,11,0.25)",
|
|
5436
|
+
borderRadius: 6,
|
|
5437
|
+
fontSize: 10.5,
|
|
5438
|
+
color: "#92400e",
|
|
5439
|
+
lineHeight: 1.45
|
|
5440
|
+
},
|
|
5441
|
+
children: [
|
|
5442
|
+
counts.unverified,
|
|
5443
|
+
" link",
|
|
5444
|
+
counts.unverified === 1 ? "" : "s",
|
|
5445
|
+
" were blocked from our auto-check (likely anti-bot rules on the destination site). They may still work fine for human readers - click each to confirm."
|
|
5446
|
+
]
|
|
5447
|
+
}
|
|
5448
|
+
),
|
|
5266
5449
|
counts.issues.length > 0 ? /* @__PURE__ */ jsxs13("div", { style: { marginTop: 12, display: "flex", flexDirection: "column", gap: 6 }, children: [
|
|
5267
5450
|
/* @__PURE__ */ jsxs13("div", { style: { fontSize: 10, fontWeight: 700, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.06em" }, children: [
|
|
5268
5451
|
counts.issues.length,
|
|
@@ -5321,9 +5504,12 @@ function LinkIssueRow({ result }) {
|
|
|
5321
5504
|
ok: { bg: "rgba(22,163,74,0.06)", color: "#16a34a", label: "OK" },
|
|
5322
5505
|
redirect: { bg: "rgba(230,192,27,0.12)", color: "#8B7310", label: result.status > 0 ? String(result.status) : "REDIR" },
|
|
5323
5506
|
broken: { bg: "rgba(220,38,38,0.06)", color: "#dc2626", label: result.status > 0 ? String(result.status) : "404" },
|
|
5507
|
+
// Amber for unverified - the link may work fine, our server just couldn't confirm.
|
|
5508
|
+
unverified: { bg: "rgba(245,158,11,0.10)", color: "#b45309", label: result.status > 0 ? String(result.status) : "BLOCKED" },
|
|
5324
5509
|
error: { bg: "rgba(220,38,38,0.06)", color: "#dc2626", label: "ERR" }
|
|
5325
5510
|
};
|
|
5326
5511
|
const c = map[result.category];
|
|
5512
|
+
const tooltip = result.category === "unverified" ? `${result.url} (couldn't auto-check; likely anti-bot blocking - open manually to verify)` : result.error ? `${result.url} (${result.error})` : result.url;
|
|
5327
5513
|
return /* @__PURE__ */ jsxs13(
|
|
5328
5514
|
"a",
|
|
5329
5515
|
{
|
|
@@ -5370,7 +5556,7 @@ function LinkIssueRow({ result }) {
|
|
|
5370
5556
|
textOverflow: "ellipsis",
|
|
5371
5557
|
whiteSpace: "nowrap"
|
|
5372
5558
|
},
|
|
5373
|
-
title:
|
|
5559
|
+
title: tooltip,
|
|
5374
5560
|
children: result.url
|
|
5375
5561
|
}
|
|
5376
5562
|
)
|
|
@@ -5422,12 +5608,7 @@ function TechnicalTab({
|
|
|
5422
5608
|
status: "warning",
|
|
5423
5609
|
recommendation: "Add at least one hero image with descriptive alt text. Articles with images perform better on both reader engagement and search."
|
|
5424
5610
|
} : null;
|
|
5425
|
-
const wordAudit = wordCount2 === 0 ? {
|
|
5426
|
-
label: "Word Count",
|
|
5427
|
-
value: "0 words",
|
|
5428
|
-
status: "error",
|
|
5429
|
-
recommendation: "Start writing. A link or image on its own doesn't count - the body needs real written substance."
|
|
5430
|
-
} : wordCount2 < 450 ? {
|
|
5611
|
+
const wordAudit = wordCount2 === 0 ? null : wordCount2 < 450 ? {
|
|
5431
5612
|
label: "Word Count",
|
|
5432
5613
|
value: `${wordCount2} words`,
|
|
5433
5614
|
status: "error",
|
|
@@ -5447,7 +5628,7 @@ function TechnicalTab({
|
|
|
5447
5628
|
] });
|
|
5448
5629
|
}
|
|
5449
5630
|
return /* @__PURE__ */ jsxs13("div", { style: { padding: 12, display: "flex", flexDirection: "column", gap: 10 }, children: [
|
|
5450
|
-
/* @__PURE__ */ jsx14(
|
|
5631
|
+
wordAudit && /* @__PURE__ */ jsx14(
|
|
5451
5632
|
AuditCard2,
|
|
5452
5633
|
{
|
|
5453
5634
|
anchorId: "anchor-word-count",
|
|
@@ -6050,6 +6231,8 @@ function SEOCopilotInner({ config, onClose }) {
|
|
|
6050
6231
|
const resizeStart = useRef10(null);
|
|
6051
6232
|
const { text, isLoading: docLoading, documentFields, documentId } = useDocumentContent();
|
|
6052
6233
|
const { apiUrl } = useConfig();
|
|
6234
|
+
const workspace = useWorkspace();
|
|
6235
|
+
const effectivePublication = config.publication || workspace?.dataset;
|
|
6053
6236
|
const seedCacheKey = documentId ? `seo-copilot-cache-${documentId}` : "seo-copilot-cache-v2";
|
|
6054
6237
|
const loadSeedsFromCache = useCallback5(() => {
|
|
6055
6238
|
try {
|
|
@@ -6084,7 +6267,7 @@ function SEOCopilotInner({ config, onClose }) {
|
|
|
6084
6267
|
const [activeTab, setActiveTab] = useState16("keywords");
|
|
6085
6268
|
const [chatOpen, setChatOpen] = usePersistentState("seo-copilot-ui-chat-open-v35", false);
|
|
6086
6269
|
const [splitPercent, setSplitPercent] = usePersistentState("seo-copilot-ui-split", 70);
|
|
6087
|
-
const keywordAnalysisState = useKeywordAnalysis(text, apiUrl,
|
|
6270
|
+
const keywordAnalysisState = useKeywordAnalysis(text, apiUrl, effectivePublication, seedKeywords, documentFields, selectedPrimary, documentId);
|
|
6088
6271
|
const effectivePrimary = selectedPrimary || keywordAnalysisState.analysis?.primaryKeyword?.term || "";
|
|
6089
6272
|
const keywordPanelData = useMemo5(() => {
|
|
6090
6273
|
const analysis = keywordAnalysisState.analysis;
|
|
@@ -6101,7 +6284,7 @@ function SEOCopilotInner({ config, onClose }) {
|
|
|
6101
6284
|
} : void 0
|
|
6102
6285
|
};
|
|
6103
6286
|
}, [keywordAnalysisState.analysis, keywordAnalysisState.deepAnalysis]);
|
|
6104
|
-
const chatHookState = useSEOChat(apiUrl, text,
|
|
6287
|
+
const chatHookState = useSEOChat(apiUrl, text, effectivePublication, keywordPanelData, documentId);
|
|
6105
6288
|
const contentSuggestionsKey = documentId ? `seo-copilot-content-suggestions-${documentId}` : "seo-copilot-content-suggestions-default";
|
|
6106
6289
|
const [contentSuggestions, setContentSuggestions] = usePersistentState(contentSuggestionsKey, null);
|
|
6107
6290
|
const [isCSLoading, setIsCSLoading] = useState16(false);
|
|
@@ -6122,7 +6305,7 @@ function SEOCopilotInner({ config, onClose }) {
|
|
|
6122
6305
|
setIsCSLoading(true);
|
|
6123
6306
|
setCsError(null);
|
|
6124
6307
|
try {
|
|
6125
|
-
const data = await fetchContentSuggestions(apiUrl, text, effectivePrimary,
|
|
6308
|
+
const data = await fetchContentSuggestions(apiUrl, text, effectivePrimary, effectivePublication);
|
|
6126
6309
|
if (aeoOpVersionRef.current !== myVersion) return;
|
|
6127
6310
|
if (data.keyTakeaways.length === 0 && data.infographicOpportunities.length === 0 && data.bulletListItems.length === 0) {
|
|
6128
6311
|
setCsError("No suggestions returned. Try again with more content.");
|
|
@@ -6135,7 +6318,7 @@ function SEOCopilotInner({ config, onClose }) {
|
|
|
6135
6318
|
}
|
|
6136
6319
|
if (aeoOpVersionRef.current !== myVersion) return;
|
|
6137
6320
|
setIsCSLoading(false);
|
|
6138
|
-
}, [apiUrl, text, effectivePrimary,
|
|
6321
|
+
}, [apiUrl, text, effectivePrimary, effectivePublication]);
|
|
6139
6322
|
const linkingKey = documentId ? `seo-copilot-linking-${documentId}` : "seo-copilot-linking-default";
|
|
6140
6323
|
const [linkingSuggestions, setLinkingSuggestions] = usePersistentState(linkingKey, []);
|
|
6141
6324
|
const [isLinkingLoading, setIsLinkingLoading] = useState16(false);
|
|
@@ -6170,7 +6353,7 @@ function SEOCopilotInner({ config, onClose }) {
|
|
|
6170
6353
|
effectivePrimary,
|
|
6171
6354
|
supportingKeywordsForLinking,
|
|
6172
6355
|
documentId,
|
|
6173
|
-
|
|
6356
|
+
effectivePublication
|
|
6174
6357
|
);
|
|
6175
6358
|
if (linkingVersionRef.current !== myVersion) return;
|
|
6176
6359
|
setLinkingSuggestions(suggestions);
|
|
@@ -6181,7 +6364,7 @@ function SEOCopilotInner({ config, onClose }) {
|
|
|
6181
6364
|
}
|
|
6182
6365
|
if (linkingVersionRef.current !== myVersion) return;
|
|
6183
6366
|
setIsLinkingLoading(false);
|
|
6184
|
-
}, [apiUrl, text, effectivePrimary, supportingKeywordsForLinking, documentId,
|
|
6367
|
+
}, [apiUrl, text, effectivePrimary, supportingKeywordsForLinking, documentId, effectivePublication]);
|
|
6185
6368
|
const isLinkingStale = useMemo5(() => {
|
|
6186
6369
|
if (!linkingFetchedText || linkingSuggestions.length === 0) return false;
|
|
6187
6370
|
if (Math.abs(text.length - linkingFetchedText.length) > 150) return true;
|
|
@@ -6295,7 +6478,7 @@ function SEOCopilotInner({ config, onClose }) {
|
|
|
6295
6478
|
const panelContent = /* @__PURE__ */ jsx15(
|
|
6296
6479
|
PanelContent,
|
|
6297
6480
|
{
|
|
6298
|
-
initialPublication:
|
|
6481
|
+
initialPublication: effectivePublication,
|
|
6299
6482
|
isFloating,
|
|
6300
6483
|
isFullscreen,
|
|
6301
6484
|
onToggleFloat: () => {
|