sanity-plugin-seo-copilot 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4729 -895
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4722 -888
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/ChatPanel.tsx +87 -69
- package/src/components/FeedbackButton.tsx +2 -2
- package/src/components/KeywordBadge.tsx +50 -50
- package/src/components/KeywordPanel.tsx +97 -226
- package/src/components/PlacementIndicators.tsx +80 -76
- package/src/components/SEOCopilotPanel.tsx +712 -165
- package/src/components/ScoreDonut.tsx +158 -0
- package/src/components/SeedKeywordInput.tsx +128 -125
- package/src/components/ShimmerLoader.tsx +119 -0
- package/src/components/TabBar.tsx +370 -0
- package/src/components/styles.ts +66 -0
- package/src/components/tabs/AEOTab.tsx +573 -0
- package/src/components/tabs/LinkingTab.tsx +343 -0
- package/src/components/tabs/MetaTab.tsx +417 -0
- package/src/components/tabs/SummaryTab.tsx +384 -0
- package/src/components/tabs/TechnicalTab.tsx +776 -0
- package/src/hooks/useDocumentContent.ts +216 -99
- package/src/hooks/useKeywordAnalysis.ts +28 -8
- package/src/hooks/useSEOChat.ts +38 -11
- package/src/lib/api.ts +109 -13
- package/src/lib/geoAnalysis.ts +109 -0
- package/src/lib/persistence.ts +69 -0
- package/src/lib/scoring.ts +147 -0
- package/src/lib/summary.ts +504 -0
- package/src/lib/types.ts +197 -108
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { useMemo, useState } from "react";
|
|
2
|
+
import type { DocumentFields, TechnicalAuditItem } from "../../lib/types";
|
|
3
|
+
|
|
4
|
+
interface MetaTabProps {
|
|
5
|
+
documentFields?: DocumentFields;
|
|
6
|
+
primaryKeyword?: string;
|
|
7
|
+
isLoading?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Token-based keyword match so "selinexor in myelofibrosis" still counts as containing
|
|
11
|
+
// the primary keyword "selinexor myelofibrosis" (word order / connecting words don't matter).
|
|
12
|
+
function containsKeywordTokens(haystack: string, needle?: string): boolean {
|
|
13
|
+
if (!needle) return true;
|
|
14
|
+
const tokens = needle.toLowerCase().split(/\s+/).filter((t) => t.length > 1);
|
|
15
|
+
if (tokens.length === 0) return true;
|
|
16
|
+
const lower = haystack.toLowerCase();
|
|
17
|
+
return tokens.every((t) => lower.includes(t));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const cardStyle: React.CSSProperties = {
|
|
21
|
+
borderRadius: 14,
|
|
22
|
+
background: "rgba(255,255,255,0.55)",
|
|
23
|
+
backdropFilter: "blur(16px) saturate(170%)",
|
|
24
|
+
WebkitBackdropFilter: "blur(16px) saturate(170%)",
|
|
25
|
+
boxShadow: "inset 0 0 0 1px rgba(255,255,255,0.85), inset 1.5px 2px 1px -1px rgba(255,255,255,1), inset -2px -3px 2px -1px rgba(255,255,255,0.6), 0 2px 6px rgba(0,0,0,0.07), 0 10px 26px rgba(0,0,0,0.08)",
|
|
26
|
+
padding: "14px",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function StatusBadge({ status }: { status: TechnicalAuditItem["status"] }) {
|
|
30
|
+
const map = {
|
|
31
|
+
good: { bg: "rgba(22,163,74,0.12)", color: "#16a34a", label: "Good" },
|
|
32
|
+
warning: { bg: "rgba(230,192,27,0.18)", color: "#8B7310", label: "Review" },
|
|
33
|
+
error: { bg: "rgba(220,38,38,0.1)", color: "#dc2626", label: "Fix" },
|
|
34
|
+
} as const;
|
|
35
|
+
const c = map[status];
|
|
36
|
+
return (
|
|
37
|
+
<span
|
|
38
|
+
style={{
|
|
39
|
+
fontSize: 9,
|
|
40
|
+
fontWeight: 700,
|
|
41
|
+
textTransform: "uppercase",
|
|
42
|
+
letterSpacing: "0.05em",
|
|
43
|
+
padding: "2px 7px",
|
|
44
|
+
borderRadius: 99,
|
|
45
|
+
background: c.bg,
|
|
46
|
+
color: c.color,
|
|
47
|
+
flexShrink: 0,
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
{c.label}
|
|
51
|
+
</span>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function AuditCard({ label, value, status, recommendation, anchorId, footer }: { label: string; value: string; status: TechnicalAuditItem["status"]; recommendation?: string; anchorId?: string; footer?: React.ReactNode }) {
|
|
56
|
+
return (
|
|
57
|
+
<div id={anchorId} style={cardStyle}>
|
|
58
|
+
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, marginBottom: 6 }}>
|
|
59
|
+
<span style={{ fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600 }}>
|
|
60
|
+
{label}
|
|
61
|
+
</span>
|
|
62
|
+
<StatusBadge status={status} />
|
|
63
|
+
</div>
|
|
64
|
+
<div
|
|
65
|
+
style={{
|
|
66
|
+
fontSize: 12,
|
|
67
|
+
color: status === "error" ? "#9ca3af" : "#374151",
|
|
68
|
+
lineHeight: 1.5,
|
|
69
|
+
fontStyle: status === "error" ? "italic" : "normal",
|
|
70
|
+
wordBreak: "break-word",
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
{value}
|
|
74
|
+
</div>
|
|
75
|
+
{recommendation && (
|
|
76
|
+
<div
|
|
77
|
+
style={{
|
|
78
|
+
marginTop: 8,
|
|
79
|
+
padding: "6px 10px",
|
|
80
|
+
background: status === "error" ? "rgba(220,38,38,0.04)" : "rgba(230,192,27,0.06)",
|
|
81
|
+
borderLeft: `2px solid ${status === "error" ? "#dc2626" : "#E6C01B"}`,
|
|
82
|
+
borderRadius: 6,
|
|
83
|
+
fontSize: 11,
|
|
84
|
+
color: "#1f2937",
|
|
85
|
+
lineHeight: 1.5,
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
{recommendation}
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
{/* Optional extra content that lives INSIDE the card box (e.g. the 301
|
|
92
|
+
redirect caution under URL Slug) - no connector needed, it's the same box. */}
|
|
93
|
+
{footer}
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function metaDescriptionAudit(meta?: string, primaryKeyword?: string): TechnicalAuditItem {
|
|
99
|
+
if (!meta) {
|
|
100
|
+
return {
|
|
101
|
+
label: "Meta Description",
|
|
102
|
+
value: "Missing",
|
|
103
|
+
status: "error",
|
|
104
|
+
recommendation: "Add a 120-160 character meta description that includes your primary keyword.",
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const len = meta.length;
|
|
108
|
+
const lacksKeyword = primaryKeyword && !containsKeywordTokens(meta, primaryKeyword);
|
|
109
|
+
if (len < 120) {
|
|
110
|
+
return {
|
|
111
|
+
label: "Meta Description",
|
|
112
|
+
value: `${meta} (${len} chars)`,
|
|
113
|
+
status: "warning",
|
|
114
|
+
recommendation: `Too short - aim for 120-160 characters.${lacksKeyword ? ` Also missing primary keyword "${primaryKeyword}".` : ""}`,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (len > 160) {
|
|
118
|
+
return {
|
|
119
|
+
label: "Meta Description",
|
|
120
|
+
value: `${meta} (${len} chars)`,
|
|
121
|
+
status: "warning",
|
|
122
|
+
recommendation: `Too long - Google may truncate beyond 160 characters.${lacksKeyword ? ` Also missing primary keyword "${primaryKeyword}".` : ""}`,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (lacksKeyword) {
|
|
126
|
+
return {
|
|
127
|
+
label: "Meta Description",
|
|
128
|
+
value: `${meta} (${len} chars)`,
|
|
129
|
+
status: "warning",
|
|
130
|
+
recommendation: `Length is good but primary keyword "${primaryKeyword}" is not included.`,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
label: "Meta Description",
|
|
135
|
+
value: `${meta} (${len} chars)`,
|
|
136
|
+
status: "good",
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Returns the position (0-indexed char + 0-indexed word) of the first occurrence
|
|
141
|
+
// of any token in the primary keyword within the title. Returns null if missing.
|
|
142
|
+
function keywordPositionInTitle(title: string, primaryKeyword: string): { charIndex: number; wordIndex: number } | null {
|
|
143
|
+
const lowerTitle = title.toLowerCase();
|
|
144
|
+
const tokens = primaryKeyword.toLowerCase().split(/\s+/).filter((t) => t.length > 1);
|
|
145
|
+
if (tokens.length === 0) return null;
|
|
146
|
+
let firstHit = -1;
|
|
147
|
+
for (const t of tokens) {
|
|
148
|
+
const i = lowerTitle.indexOf(t);
|
|
149
|
+
if (i >= 0 && (firstHit === -1 || i < firstHit)) firstHit = i;
|
|
150
|
+
}
|
|
151
|
+
if (firstHit === -1) return null;
|
|
152
|
+
const wordsBefore = title.slice(0, firstHit).trim().split(/\s+/).filter(Boolean);
|
|
153
|
+
return { charIndex: firstHit, wordIndex: wordsBefore.length };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Title audit per director guidance: editors can't easily change title length
|
|
157
|
+
// (Sanity uses the article title as the page title), so we don't warn about length.
|
|
158
|
+
// We DO check that the primary keyword sits early enough to survive Google's ~60-char
|
|
159
|
+
// truncation: research-validated thresholds are first 30 chars OR first 5 words.
|
|
160
|
+
function titleAudit(title?: string, primaryKeyword?: string): TechnicalAuditItem {
|
|
161
|
+
if (!title) {
|
|
162
|
+
return { label: "Title Tag", value: "Missing", status: "error", recommendation: "Add a title that leads with the primary keyword." };
|
|
163
|
+
}
|
|
164
|
+
const len = title.length;
|
|
165
|
+
if (primaryKeyword) {
|
|
166
|
+
const pos = keywordPositionInTitle(title, primaryKeyword);
|
|
167
|
+
if (!pos) {
|
|
168
|
+
return {
|
|
169
|
+
label: "Title Tag",
|
|
170
|
+
value: `${title} (${len} chars)`,
|
|
171
|
+
status: "warning",
|
|
172
|
+
recommendation: `Primary keyword "${primaryKeyword}" isn't in the title. Reorder or rephrase the title so it leads with the keyword - Google shows roughly the first 60 characters in search.`,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
// Keyword is too far in: starts past char 30 AND past word 5.
|
|
176
|
+
// Either threshold alone is fine; both fail = warning.
|
|
177
|
+
if (pos.charIndex > 30 && pos.wordIndex > 5) {
|
|
178
|
+
return {
|
|
179
|
+
label: "Title Tag",
|
|
180
|
+
value: `${title} (${len} chars)`,
|
|
181
|
+
status: "warning",
|
|
182
|
+
recommendation: `Primary keyword "${primaryKeyword}" starts at character ${pos.charIndex + 1}. Move it toward the front so it stays visible if Google truncates the title at ~60 characters.`,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return { label: "Title Tag", value: `${title} (${len} chars)`, status: "good" };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function urlAudit(slug?: string, primaryKeyword?: string): TechnicalAuditItem {
|
|
190
|
+
if (!slug) {
|
|
191
|
+
return { label: "URL Slug", value: "Missing", status: "error", recommendation: "Add a clean, hyphenated URL slug containing the primary keyword. Aim for 3-5 words." };
|
|
192
|
+
}
|
|
193
|
+
const issues: string[] = [];
|
|
194
|
+
if (slug.length > 60) issues.push("longer than 60 characters - aim for 3-5 words");
|
|
195
|
+
if (/[A-Z]/.test(slug)) issues.push("contains uppercase letters");
|
|
196
|
+
if (/_/.test(slug)) issues.push("uses underscores instead of hyphens");
|
|
197
|
+
if (/[^a-zA-Z0-9-/]/.test(slug.replace(/^\//, ""))) issues.push("contains special characters");
|
|
198
|
+
if (primaryKeyword && !containsKeywordTokens(slug.replace(/-/g, " "), primaryKeyword)) {
|
|
199
|
+
issues.push(`missing primary keyword "${primaryKeyword}"`);
|
|
200
|
+
}
|
|
201
|
+
if (issues.length === 0) {
|
|
202
|
+
return { label: "URL Slug", value: `/${slug}`, status: "good" };
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
label: "URL Slug",
|
|
206
|
+
value: `/${slug}`,
|
|
207
|
+
status: "warning",
|
|
208
|
+
recommendation: `Issues: ${issues.join(", ")}.`,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Caution block that lives INSIDE the URL Slug card (same box - no connector). A
|
|
213
|
+
// slug change on an indexed page without a 301 redirect silently drops search
|
|
214
|
+
// rankings to zero and breaks every external link to the old URL - but it's a
|
|
215
|
+
// warning (avoidable), not an error, so it's styled amber. It echoes the card's
|
|
216
|
+
// own recommendation-block pattern (amber left rail + tint) with a divider above
|
|
217
|
+
// it, so it reads as a distinct caution that's clearly part of the slug card. The
|
|
218
|
+
// headline is always visible; the "why / how" detail tucks behind Learn more.
|
|
219
|
+
function SlugRedirectNotice() {
|
|
220
|
+
const [expanded, setExpanded] = useState(false);
|
|
221
|
+
return (
|
|
222
|
+
<div
|
|
223
|
+
style={{
|
|
224
|
+
marginTop: 10,
|
|
225
|
+
paddingTop: 10,
|
|
226
|
+
borderTop: "1px solid rgba(0,0,0,0.07)",
|
|
227
|
+
}}
|
|
228
|
+
>
|
|
229
|
+
<div
|
|
230
|
+
style={{
|
|
231
|
+
padding: "8px 10px",
|
|
232
|
+
background: "rgba(245,158,11,0.08)",
|
|
233
|
+
borderLeft: "2px solid #f59e0b",
|
|
234
|
+
borderRadius: 6,
|
|
235
|
+
}}
|
|
236
|
+
>
|
|
237
|
+
<div style={{ display: "flex", alignItems: "center", gap: 6, marginBottom: 4 }}>
|
|
238
|
+
<svg width="12" height="12" viewBox="0 0 20 20" fill="#f59e0b" aria-hidden="true">
|
|
239
|
+
<path fillRule="evenodd" d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z" clipRule="evenodd" />
|
|
240
|
+
</svg>
|
|
241
|
+
<span style={{ fontSize: 10.5, fontWeight: 700, color: "#b45309", textTransform: "uppercase", letterSpacing: "0.06em" }}>
|
|
242
|
+
Changing a URL?
|
|
243
|
+
</span>
|
|
244
|
+
</div>
|
|
245
|
+
<div style={{ fontSize: 11, color: "#1f2937", lineHeight: 1.55 }}>
|
|
246
|
+
If the page has been published and indexed, you MUST add a 301 redirect from the old slug to the new one before changing it. For a brand-new page that's never been published, no redirect needed.
|
|
247
|
+
</div>
|
|
248
|
+
<button
|
|
249
|
+
onClick={() => setExpanded((v) => !v)}
|
|
250
|
+
style={{
|
|
251
|
+
display: "flex",
|
|
252
|
+
alignItems: "center",
|
|
253
|
+
gap: 3,
|
|
254
|
+
marginTop: 6,
|
|
255
|
+
padding: 0,
|
|
256
|
+
background: "none",
|
|
257
|
+
border: "none",
|
|
258
|
+
cursor: "pointer",
|
|
259
|
+
fontSize: 10.5,
|
|
260
|
+
fontWeight: 700,
|
|
261
|
+
color: "#b45309",
|
|
262
|
+
fontFamily: "inherit",
|
|
263
|
+
}}
|
|
264
|
+
>
|
|
265
|
+
{expanded ? "Show less" : "Learn more"}
|
|
266
|
+
<svg width="10" height="10" viewBox="0 0 20 20" fill="currentColor" style={{ transform: expanded ? "rotate(180deg)" : "none", transition: "transform 150ms" }}>
|
|
267
|
+
<path fillRule="evenodd" d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z" clipRule="evenodd" />
|
|
268
|
+
</svg>
|
|
269
|
+
</button>
|
|
270
|
+
{expanded && (
|
|
271
|
+
<ul style={{ margin: "6px 0 0", paddingLeft: 16, fontSize: 11, color: "#1f2937", lineHeight: 1.55 }}>
|
|
272
|
+
<li>Without the 301, the page loses every search ranking and every external link to it breaks.</li>
|
|
273
|
+
<li>A 301 preserves the rankings and link equity built up on the old URL.</li>
|
|
274
|
+
<li>Set this up using vanity redirects in Sanity.</li>
|
|
275
|
+
</ul>
|
|
276
|
+
)}
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function daysSince(iso?: string): number | null {
|
|
283
|
+
if (!iso) return null;
|
|
284
|
+
const t = new Date(iso).getTime();
|
|
285
|
+
if (isNaN(t)) return null;
|
|
286
|
+
return Math.floor((Date.now() - t) / 86400000);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function formatDateShort(iso?: string): string {
|
|
290
|
+
if (!iso) return "";
|
|
291
|
+
try {
|
|
292
|
+
return new Date(iso).toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" });
|
|
293
|
+
} catch {
|
|
294
|
+
return "";
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export function MetaTab({ documentFields, primaryKeyword, isLoading }: MetaTabProps) {
|
|
299
|
+
const audits = useMemo<TechnicalAuditItem[]>(() => {
|
|
300
|
+
const list: TechnicalAuditItem[] = [];
|
|
301
|
+
list.push(titleAudit(documentFields?.title, primaryKeyword));
|
|
302
|
+
list.push(metaDescriptionAudit(documentFields?.metaDescription, primaryKeyword));
|
|
303
|
+
list.push(urlAudit(documentFields?.slug, primaryKeyword));
|
|
304
|
+
return list;
|
|
305
|
+
}, [documentFields, primaryKeyword]);
|
|
306
|
+
|
|
307
|
+
// E-E-A-T audit - critical for healthcare YMYL-adjacent content per 2026 Google scrutiny
|
|
308
|
+
const eeatItems = useMemo(() => {
|
|
309
|
+
const items: TechnicalAuditItem[] = [];
|
|
310
|
+
const author = documentFields?.authorName;
|
|
311
|
+
const creds = documentFields?.authorCredentials;
|
|
312
|
+
const bio = documentFields?.authorBioUrl;
|
|
313
|
+
const authorIsRef = documentFields?.authorIsReference;
|
|
314
|
+
if (!author && authorIsRef) {
|
|
315
|
+
// The schema uses a reference field we can't resolve from the document pane.
|
|
316
|
+
// Don't flag as missing - just note we can't audit it here.
|
|
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
|
+
} else if (!author) {
|
|
319
|
+
items.push({ label: "Author Byline", value: "Missing", status: "error", recommendation: "Add a named author. Healthcare content needs visible authorship for Google to consider it trustworthy." });
|
|
320
|
+
} else if (!creds) {
|
|
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
|
+
} else if (!bio) {
|
|
323
|
+
items.push({ label: "Author Byline", value: `${author}, ${creds}`, status: "warning", recommendation: "Add a link to the author's bio page so credentials are verifiable." });
|
|
324
|
+
} else {
|
|
325
|
+
items.push({ label: "Author Byline", value: `${author}, ${creds}`, status: "good" });
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const published = documentFields?.publishedAt;
|
|
329
|
+
const updated = documentFields?.updatedAt;
|
|
330
|
+
const reviewed = documentFields?.lastReviewedAt;
|
|
331
|
+
const daysPub = daysSince(published);
|
|
332
|
+
const daysUpd = daysSince(updated);
|
|
333
|
+
const daysRev = daysSince(reviewed);
|
|
334
|
+
const freshness = Math.min(...[daysUpd, daysRev, daysPub].filter((d): d is number => d !== null));
|
|
335
|
+
|
|
336
|
+
if (!published) {
|
|
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 {
|
|
339
|
+
items.push({ label: "Publish Date", value: formatDateShort(published), status: "good" });
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Freshness signal - articles fall off AI Overview citations after about 14 days
|
|
343
|
+
// without updates; 90+ days is effectively stale.
|
|
344
|
+
if (Number.isFinite(freshness)) {
|
|
345
|
+
if (freshness <= 14) {
|
|
346
|
+
items.push({ label: "Last Updated", value: `${freshness} day${freshness === 1 ? "" : "s"} ago`, status: "good" });
|
|
347
|
+
} else if (freshness <= 90) {
|
|
348
|
+
items.push({ label: "Last Updated", value: `${freshness} days ago`, status: "warning", recommendation: "Articles older than two weeks get cited less by AI search. If the content is still accurate, refresh stats or add a last-reviewed date." });
|
|
349
|
+
} else {
|
|
350
|
+
items.push({ label: "Last Updated", value: `${freshness} days ago`, status: "error", recommendation: "Older than 90 days. Review the facts, update what's stale, and timestamp the refresh." });
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return items;
|
|
355
|
+
}, [documentFields]);
|
|
356
|
+
|
|
357
|
+
// Show a single loading placeholder while document fields are being read,
|
|
358
|
+
// so we don't flash "Missing" cards based on the previous doc / no doc.
|
|
359
|
+
const hasAnyField =
|
|
360
|
+
!!documentFields &&
|
|
361
|
+
(documentFields.title !== undefined ||
|
|
362
|
+
documentFields.metaDescription !== undefined ||
|
|
363
|
+
documentFields.slug !== undefined);
|
|
364
|
+
if (isLoading && !hasAnyField) {
|
|
365
|
+
return (
|
|
366
|
+
<div style={{ padding: 24, textAlign: "center" }}>
|
|
367
|
+
<div style={{ fontSize: 13, color: "#4b5563", fontWeight: 500 }}>Reading document fields...</div>
|
|
368
|
+
<div style={{ fontSize: 11, color: "#4b5563", marginTop: 4 }}>Audit will run once content loads</div>
|
|
369
|
+
</div>
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// Anchor IDs let the Summary tab deep-link straight to a specific audit card.
|
|
374
|
+
const auditAnchors = ["anchor-meta-title", "anchor-meta-description", "anchor-url-slug"];
|
|
375
|
+
|
|
376
|
+
return (
|
|
377
|
+
<div style={{ padding: 12, display: "flex", flexDirection: "column", gap: 10 }}>
|
|
378
|
+
{audits.map((a, i) => (
|
|
379
|
+
<AuditCard
|
|
380
|
+
key={i}
|
|
381
|
+
anchorId={auditAnchors[i]}
|
|
382
|
+
label={a.label}
|
|
383
|
+
value={a.value}
|
|
384
|
+
status={a.status}
|
|
385
|
+
recommendation={a.recommendation}
|
|
386
|
+
// 301-redirect caution lives INSIDE the URL Slug card (same box, no
|
|
387
|
+
// connector). Always present so editors see the rule before changing a URL.
|
|
388
|
+
footer={a.label === "URL Slug" ? <SlugRedirectNotice /> : undefined}
|
|
389
|
+
/>
|
|
390
|
+
))}
|
|
391
|
+
|
|
392
|
+
{eeatItems.length > 0 && (
|
|
393
|
+
<>
|
|
394
|
+
<div style={{ display: "flex", alignItems: "center", gap: 8, margin: "6px 4px 0" }}>
|
|
395
|
+
<div style={{ height: 1, flex: 1, background: "rgba(0,0,0,0.06)" }} />
|
|
396
|
+
<span style={{ fontSize: 10, fontWeight: 700, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.08em" }}>
|
|
397
|
+
Author & Freshness
|
|
398
|
+
</span>
|
|
399
|
+
<div style={{ height: 1, flex: 1, background: "rgba(0,0,0,0.06)" }} />
|
|
400
|
+
</div>
|
|
401
|
+
<div style={{ fontSize: 10, color: "#4b5563", padding: "0 4px", marginTop: -4 }}>
|
|
402
|
+
Google looks for a named author with credentials and recent updates on healthcare content.
|
|
403
|
+
</div>
|
|
404
|
+
{eeatItems.map((item, i) => (
|
|
405
|
+
<AuditCard
|
|
406
|
+
key={`eeat-${i}`}
|
|
407
|
+
label={item.label}
|
|
408
|
+
value={item.value}
|
|
409
|
+
status={item.status}
|
|
410
|
+
recommendation={item.recommendation}
|
|
411
|
+
/>
|
|
412
|
+
))}
|
|
413
|
+
</>
|
|
414
|
+
)}
|
|
415
|
+
</div>
|
|
416
|
+
);
|
|
417
|
+
}
|