sanity-plugin-seo-copilot 0.2.14 → 0.2.16
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/README.md +63 -50
- package/dist/index.js +868 -797
- package/dist/index.mjs +791 -720
- package/package.json +9 -8
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/sanity.json +0 -3
- package/src/components/ChatPanel.tsx +0 -311
- package/src/components/ConfigContext.tsx +0 -22
- package/src/components/FeedbackButton.tsx +0 -218
- package/src/components/KeywordBadge.tsx +0 -50
- package/src/components/KeywordPanel.tsx +0 -1233
- package/src/components/OnboardingPopup.tsx +0 -108
- package/src/components/PlacementIndicators.tsx +0 -80
- package/src/components/ReportProblemButton.tsx +0 -212
- package/src/components/SEOCopilotPanel.tsx +0 -1287
- package/src/components/ScoreDonut.tsx +0 -158
- package/src/components/SeedKeywordInput.tsx +0 -128
- package/src/components/ShimmerLoader.tsx +0 -123
- package/src/components/TabBar.tsx +0 -373
- package/src/components/styles.ts +0 -158
- package/src/components/tabs/AEOTab.tsx +0 -585
- package/src/components/tabs/LinkingTab.tsx +0 -446
- package/src/components/tabs/MetaTab.tsx +0 -431
- package/src/components/tabs/SummaryTab.tsx +0 -405
- package/src/components/tabs/TechnicalTab.tsx +0 -933
- package/src/hooks/useDocumentContent.ts +0 -48
- package/src/hooks/useKeywordAnalysis.ts +0 -292
- package/src/hooks/useSEOChat.ts +0 -254
- package/src/index.ts +0 -16
- package/src/inspector.ts +0 -58
- package/src/lib/api.ts +0 -260
- package/src/lib/documentExtract.ts +0 -422
- package/src/lib/geoAnalysis.ts +0 -122
- package/src/lib/persistence.ts +0 -69
- package/src/lib/scoring.ts +0 -197
- package/src/lib/summary.ts +0 -645
- package/src/lib/types.ts +0 -212
- package/src/lib/utils.ts +0 -35
- package/v2-incompatible.js +0 -10
|
@@ -1,431 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
import type { DocumentFields, TechnicalAuditItem } from "../../lib/types";
|
|
3
|
-
import { containsKeywordTokens } from "../../lib/utils";
|
|
4
|
-
import { MJH_BLUE } from "../styles";
|
|
5
|
-
|
|
6
|
-
// Google's own page documenting E-E-A-T (Experience, Expertise, Authoritativeness,
|
|
7
|
-
// Trust). Linked from the Author Byline card so editors can read the source guidance.
|
|
8
|
-
const GOOGLE_EEAT_URL = "https://developers.google.com/search/docs/fundamentals/creating-helpful-content#eat";
|
|
9
|
-
|
|
10
|
-
// E-E-A-T audit items can carry an optional footer node (an external link, a notice).
|
|
11
|
-
type EEATItem = TechnicalAuditItem & { footer?: React.ReactNode };
|
|
12
|
-
|
|
13
|
-
// Small external-link pill, matching the LinkChip style used on the Linking tab.
|
|
14
|
-
// Opens in a new tab so the editor doesn't lose their place in the Studio.
|
|
15
|
-
function ExternalLinkChip({ href, label }: { href: string; label: string }) {
|
|
16
|
-
return (
|
|
17
|
-
<a
|
|
18
|
-
href={href}
|
|
19
|
-
target="_blank"
|
|
20
|
-
rel="noopener noreferrer"
|
|
21
|
-
style={{
|
|
22
|
-
display: "inline-flex",
|
|
23
|
-
alignItems: "center",
|
|
24
|
-
gap: 4,
|
|
25
|
-
marginTop: 8,
|
|
26
|
-
padding: "3px 9px",
|
|
27
|
-
borderRadius: 99,
|
|
28
|
-
fontSize: 10.5,
|
|
29
|
-
fontWeight: 700,
|
|
30
|
-
color: MJH_BLUE,
|
|
31
|
-
background: "rgba(255,255,255,0.7)",
|
|
32
|
-
border: `1px solid ${MJH_BLUE}33`,
|
|
33
|
-
textDecoration: "none",
|
|
34
|
-
lineHeight: 1.2,
|
|
35
|
-
}}
|
|
36
|
-
>
|
|
37
|
-
{label}
|
|
38
|
-
<svg width="9" height="9" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
|
39
|
-
<path d="M12.5 2a.75.75 0 000 1.5h2.44l-6.97 6.97a.75.75 0 101.06 1.06L16 4.56V7a.75.75 0 001.5 0V2.75A.75.75 0 0016.75 2H12.5z" />
|
|
40
|
-
<path d="M4.75 4.5A2.75 2.75 0 002 7.25v8A2.75 2.75 0 004.75 18h8A2.75 2.75 0 0015.5 15.25v-3a.75.75 0 00-1.5 0v3c0 .69-.56 1.25-1.25 1.25h-8c-.69 0-1.25-.56-1.25-1.25v-8c0-.69.56-1.25 1.25-1.25h3a.75.75 0 000-1.5h-3z" />
|
|
41
|
-
</svg>
|
|
42
|
-
</a>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// "Keep it fresh" notice, pinned to the top of the Meta tab: nudges editors to set the
|
|
47
|
-
// "Updated on" date in Sanity after a revision so the article resurfaces in Latest
|
|
48
|
-
// Updated Articles and ranks for freshness.
|
|
49
|
-
function FreshnessNotice() {
|
|
50
|
-
return (
|
|
51
|
-
<div
|
|
52
|
-
style={{
|
|
53
|
-
padding: "9px 12px",
|
|
54
|
-
background: "rgba(0,93,172,0.05)",
|
|
55
|
-
border: "1px solid rgba(0,93,172,0.15)",
|
|
56
|
-
borderLeft: `3px solid ${MJH_BLUE}`,
|
|
57
|
-
borderRadius: 8,
|
|
58
|
-
fontSize: 11,
|
|
59
|
-
color: "#1f2937",
|
|
60
|
-
lineHeight: 1.5,
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
<span style={{ fontWeight: 700, color: MJH_BLUE }}>Keep it fresh. </span>
|
|
64
|
-
Planning to update this article after it's published? Set the <strong>Updated on</strong> date in Sanity
|
|
65
|
-
(e.g. “Updated: February 19, 2026”). It surfaces the article in <strong>Latest Updated Articles</strong> and
|
|
66
|
-
increases its visibility in search engine results.
|
|
67
|
-
</div>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface MetaTabProps {
|
|
72
|
-
documentFields?: DocumentFields;
|
|
73
|
-
primaryKeyword?: string;
|
|
74
|
-
secondaryKeyword?: string;
|
|
75
|
-
isLoading?: boolean;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const cardStyle: React.CSSProperties = {
|
|
79
|
-
borderRadius: 14,
|
|
80
|
-
background: "rgba(255,255,255,0.55)",
|
|
81
|
-
backdropFilter: "blur(16px) saturate(170%)",
|
|
82
|
-
WebkitBackdropFilter: "blur(16px) saturate(170%)",
|
|
83
|
-
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)",
|
|
84
|
-
padding: "14px",
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
function StatusBadge({ status }: { status: TechnicalAuditItem["status"] }) {
|
|
88
|
-
const map = {
|
|
89
|
-
good: { bg: "rgba(22,163,74,0.12)", color: "#16a34a", label: "Good" },
|
|
90
|
-
warning: { bg: "rgba(230,192,27,0.18)", color: "#8B7310", label: "Review" },
|
|
91
|
-
error: { bg: "rgba(220,38,38,0.1)", color: "#dc2626", label: "Fix" },
|
|
92
|
-
} as const;
|
|
93
|
-
const c = map[status];
|
|
94
|
-
return (
|
|
95
|
-
<span
|
|
96
|
-
style={{
|
|
97
|
-
fontSize: 9,
|
|
98
|
-
fontWeight: 700,
|
|
99
|
-
textTransform: "uppercase",
|
|
100
|
-
letterSpacing: "0.05em",
|
|
101
|
-
padding: "2px 7px",
|
|
102
|
-
borderRadius: 99,
|
|
103
|
-
background: c.bg,
|
|
104
|
-
color: c.color,
|
|
105
|
-
flexShrink: 0,
|
|
106
|
-
}}
|
|
107
|
-
>
|
|
108
|
-
{c.label}
|
|
109
|
-
</span>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function AuditCard({ label, value, status, recommendation, anchorId, footer }: { label: string; value: string; status: TechnicalAuditItem["status"]; recommendation?: string; anchorId?: string; footer?: React.ReactNode }) {
|
|
114
|
-
return (
|
|
115
|
-
<div id={anchorId} style={cardStyle}>
|
|
116
|
-
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, marginBottom: 6 }}>
|
|
117
|
-
<span style={{ fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600 }}>
|
|
118
|
-
{label}
|
|
119
|
-
</span>
|
|
120
|
-
<StatusBadge status={status} />
|
|
121
|
-
</div>
|
|
122
|
-
<div
|
|
123
|
-
style={{
|
|
124
|
-
fontSize: 12,
|
|
125
|
-
color: status === "error" ? "#9ca3af" : "#374151",
|
|
126
|
-
lineHeight: 1.5,
|
|
127
|
-
fontStyle: status === "error" ? "italic" : "normal",
|
|
128
|
-
wordBreak: "break-word",
|
|
129
|
-
}}
|
|
130
|
-
>
|
|
131
|
-
{value}
|
|
132
|
-
</div>
|
|
133
|
-
{recommendation && (
|
|
134
|
-
<div
|
|
135
|
-
style={{
|
|
136
|
-
marginTop: 8,
|
|
137
|
-
padding: "6px 10px",
|
|
138
|
-
background: status === "error" ? "rgba(220,38,38,0.04)" : "rgba(230,192,27,0.06)",
|
|
139
|
-
borderLeft: `2px solid ${status === "error" ? "#dc2626" : "#E6C01B"}`,
|
|
140
|
-
borderRadius: 6,
|
|
141
|
-
fontSize: 11,
|
|
142
|
-
color: "#1f2937",
|
|
143
|
-
lineHeight: 1.5,
|
|
144
|
-
}}
|
|
145
|
-
>
|
|
146
|
-
{recommendation}
|
|
147
|
-
</div>
|
|
148
|
-
)}
|
|
149
|
-
{/* Optional extra content that lives INSIDE the card box (e.g. the 301
|
|
150
|
-
redirect caution under URL Slug) - no connector needed, it's the same box. */}
|
|
151
|
-
{footer}
|
|
152
|
-
</div>
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Builds the "primary X included, secondary Y not" clause shared across audits.
|
|
157
|
-
// Returns "" when there's nothing to flag (both present, or none set).
|
|
158
|
-
function keywordCoverageNote(haystack: string, primaryKeyword?: string, secondaryKeyword?: string): string {
|
|
159
|
-
const hasPrimary = primaryKeyword ? containsKeywordTokens(haystack, primaryKeyword) : true;
|
|
160
|
-
const hasSecondary = secondaryKeyword ? containsKeywordTokens(haystack, secondaryKeyword) : true;
|
|
161
|
-
if (primaryKeyword && !hasPrimary && secondaryKeyword && !hasSecondary) {
|
|
162
|
-
return `Neither your primary keyword "${primaryKeyword}" nor your secondary keyword "${secondaryKeyword}" appears here.`;
|
|
163
|
-
}
|
|
164
|
-
if (primaryKeyword && !hasPrimary) {
|
|
165
|
-
return `Your primary keyword "${primaryKeyword}" isn't included${secondaryKeyword ? ` (secondary keyword "${secondaryKeyword}" ${hasSecondary ? "is" : "isn't"}).` : "."}`;
|
|
166
|
-
}
|
|
167
|
-
if (secondaryKeyword && !hasSecondary) {
|
|
168
|
-
return `Your secondary keyword "${secondaryKeyword}" isn't included${primaryKeyword && hasPrimary ? ` (primary keyword "${primaryKeyword}" is present)` : ""}. Work it in if it reads naturally.`;
|
|
169
|
-
}
|
|
170
|
-
return "";
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function metaDescriptionAudit(meta?: string, primaryKeyword?: string, secondaryKeyword?: string): TechnicalAuditItem {
|
|
174
|
-
if (!meta) {
|
|
175
|
-
return {
|
|
176
|
-
label: "Meta Description",
|
|
177
|
-
value: "Missing",
|
|
178
|
-
status: "error",
|
|
179
|
-
recommendation: `Add a 120-160 character meta description that includes your primary keyword${secondaryKeyword ? " (and your secondary keyword if it fits)" : ""}.`,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
const len = meta.length;
|
|
183
|
-
const kwNote = keywordCoverageNote(meta, primaryKeyword, secondaryKeyword);
|
|
184
|
-
if (len < 120) {
|
|
185
|
-
return {
|
|
186
|
-
label: "Meta Description",
|
|
187
|
-
value: `${meta} (${len} chars)`,
|
|
188
|
-
status: "warning",
|
|
189
|
-
recommendation: `A little short - aim for 120-160 characters.${kwNote ? ` ${kwNote}` : ""}`,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
if (len > 160) {
|
|
193
|
-
return {
|
|
194
|
-
label: "Meta Description",
|
|
195
|
-
value: `${meta} (${len} chars)`,
|
|
196
|
-
status: "warning",
|
|
197
|
-
recommendation: `Over 160 characters - Google may shorten it in search, so trim it a little.${kwNote ? ` ${kwNote}` : ""}`,
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
if (kwNote) {
|
|
201
|
-
return {
|
|
202
|
-
label: "Meta Description",
|
|
203
|
-
value: `${meta} (${len} chars)`,
|
|
204
|
-
status: "warning",
|
|
205
|
-
recommendation: `Length is good. ${kwNote}`,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
return {
|
|
209
|
-
label: "Meta Description",
|
|
210
|
-
value: `${meta} (${len} chars)`,
|
|
211
|
-
status: "good",
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Returns the position (0-indexed char + 0-indexed word) of the first occurrence
|
|
216
|
-
// of any token in the primary keyword within the title. Returns null if missing.
|
|
217
|
-
function keywordPositionInTitle(title: string, primaryKeyword: string): { charIndex: number; wordIndex: number } | null {
|
|
218
|
-
const lowerTitle = title.toLowerCase();
|
|
219
|
-
const tokens = primaryKeyword.toLowerCase().split(/\s+/).filter((t) => t.length > 1);
|
|
220
|
-
if (tokens.length === 0) return null;
|
|
221
|
-
let firstHit = -1;
|
|
222
|
-
for (const t of tokens) {
|
|
223
|
-
const i = lowerTitle.indexOf(t);
|
|
224
|
-
if (i >= 0 && (firstHit === -1 || i < firstHit)) firstHit = i;
|
|
225
|
-
}
|
|
226
|
-
if (firstHit === -1) return null;
|
|
227
|
-
const wordsBefore = title.slice(0, firstHit).trim().split(/\s+/).filter(Boolean);
|
|
228
|
-
return { charIndex: firstHit, wordIndex: wordsBefore.length };
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Title audit per director guidance: editors can't easily change title length
|
|
232
|
-
// (Sanity uses the article title as the page title), so we don't warn about length.
|
|
233
|
-
// We DO check that the primary keyword sits early enough to survive Google's ~60-char
|
|
234
|
-
// truncation: research-validated thresholds are first 30 chars OR first 5 words.
|
|
235
|
-
function titleAudit(title?: string, primaryKeyword?: string): TechnicalAuditItem {
|
|
236
|
-
if (!title) {
|
|
237
|
-
return { label: "Title Tag", value: "Missing", status: "error", recommendation: "Add a title that leads with the primary keyword." };
|
|
238
|
-
}
|
|
239
|
-
const len = title.length;
|
|
240
|
-
if (primaryKeyword) {
|
|
241
|
-
const pos = keywordPositionInTitle(title, primaryKeyword);
|
|
242
|
-
if (!pos) {
|
|
243
|
-
return {
|
|
244
|
-
label: "Title Tag",
|
|
245
|
-
value: `${title} (${len} chars)`,
|
|
246
|
-
status: "warning",
|
|
247
|
-
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.`,
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
// Keyword is too far in: starts past char 30 AND past word 5.
|
|
251
|
-
// Either threshold alone is fine; both fail = warning.
|
|
252
|
-
if (pos.charIndex > 30 && pos.wordIndex > 5) {
|
|
253
|
-
return {
|
|
254
|
-
label: "Title Tag",
|
|
255
|
-
value: `${title} (${len} chars)`,
|
|
256
|
-
status: "warning",
|
|
257
|
-
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.`,
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return { label: "Title Tag", value: `${title} (${len} chars)`, status: "good" };
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function daysSince(iso?: string): number | null {
|
|
265
|
-
if (!iso) return null;
|
|
266
|
-
const t = new Date(iso).getTime();
|
|
267
|
-
if (isNaN(t)) return null;
|
|
268
|
-
return Math.floor((Date.now() - t) / 86400000);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function formatDateShort(iso?: string): string {
|
|
272
|
-
if (!iso) return "";
|
|
273
|
-
const d = new Date(iso);
|
|
274
|
-
// toLocaleDateString does NOT throw on a bad date - it returns "Invalid Date".
|
|
275
|
-
// Guard explicitly so we never render that (or a blank) inside a "Good" badge.
|
|
276
|
-
if (isNaN(d.getTime())) return "";
|
|
277
|
-
return d.toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" });
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
export function MetaTab({ documentFields, primaryKeyword, secondaryKeyword, isLoading }: MetaTabProps) {
|
|
281
|
-
const audits = useMemo<TechnicalAuditItem[]>(() => {
|
|
282
|
-
const list: TechnicalAuditItem[] = [];
|
|
283
|
-
list.push(titleAudit(documentFields?.title, primaryKeyword));
|
|
284
|
-
list.push(metaDescriptionAudit(documentFields?.metaDescription, primaryKeyword, secondaryKeyword));
|
|
285
|
-
// URL Slug audit moved to the Other Recs tab.
|
|
286
|
-
return list;
|
|
287
|
-
}, [documentFields, primaryKeyword, secondaryKeyword]);
|
|
288
|
-
|
|
289
|
-
// E-E-A-T audit - critical for healthcare YMYL-adjacent content per 2026 Google scrutiny
|
|
290
|
-
const eeatItems = useMemo<EEATItem[]>(() => {
|
|
291
|
-
const items: EEATItem[] = [];
|
|
292
|
-
const author = documentFields?.authorName;
|
|
293
|
-
const creds = documentFields?.authorCredentials;
|
|
294
|
-
const bio = documentFields?.authorBioUrl;
|
|
295
|
-
const authorIsRef = documentFields?.authorIsReference;
|
|
296
|
-
if (!author && authorIsRef) {
|
|
297
|
-
// The schema uses a reference field we can't resolve from the document pane.
|
|
298
|
-
// Don't flag as missing - just note we can't audit it here.
|
|
299
|
-
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." });
|
|
300
|
-
} else if (!author) {
|
|
301
|
-
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." });
|
|
302
|
-
} else if (!creds) {
|
|
303
|
-
items.push({ label: "Author Byline", value: author, status: "warning", recommendation: "Author shown but credentials (MD, PharmD, RN, etc.) aren't visible. Add credential suffixes." });
|
|
304
|
-
} else if (!bio) {
|
|
305
|
-
items.push({ label: "Author Byline", value: `${author}, ${creds}`, status: "warning", recommendation: "Add a link to the author's bio page so credentials are verifiable." });
|
|
306
|
-
} else {
|
|
307
|
-
items.push({ label: "Author Byline", value: `${author}, ${creds}`, status: "good" });
|
|
308
|
-
}
|
|
309
|
-
// Link the byline card to Google's own E-E-A-T guidance (opens in a new tab).
|
|
310
|
-
items[0].footer = <ExternalLinkChip href={GOOGLE_EEAT_URL} label="Google's E-E-A-T guidelines" />;
|
|
311
|
-
|
|
312
|
-
// Fact-checker - a second named reviewer is a strong E-E-A-T trust signal for YMYL
|
|
313
|
-
// healthcare content (MJH articles already show a "Fact checked by ..." line).
|
|
314
|
-
const factChecker = documentFields?.factCheckerName;
|
|
315
|
-
const factCheckerRef = documentFields?.factCheckerIsReference;
|
|
316
|
-
if (factChecker) {
|
|
317
|
-
items.push({ label: "Fact-Checker", value: factChecker, status: "good" });
|
|
318
|
-
} else if (factCheckerRef) {
|
|
319
|
-
items.push({ label: "Fact-Checker", value: "Set (reference)", status: "good", recommendation: "A fact-checker is linked as a reference. Open the linked person to confirm the name shows on the published page." });
|
|
320
|
-
} else {
|
|
321
|
-
items.push({ label: "Fact-Checker", value: "Not set", status: "warning", recommendation: "Add a second named person as a fact-checker, separate from the author. A visible \"Fact checked by\" line is a strong trust signal for healthcare content." });
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// Content Freshness - HOW RECENTLY the content was last touched. Recent = good, because
|
|
325
|
-
// fresh content gets cited/ranked more; old = should be refreshed. We show the single
|
|
326
|
-
// most-recent date and name it honestly ("Updated 3 days ago" vs "Published today") so it
|
|
327
|
-
// never mislabels a publish date as an "update" (that was the confusing "Last Updated:
|
|
328
|
-
// 0 days ago"). Publish Date itself is its own card at the top of the tab. Articles fall
|
|
329
|
-
// off AI Overview citations after ~14 days; 90+ days is effectively stale.
|
|
330
|
-
const dated: { verb: string; days: number }[] = [];
|
|
331
|
-
const addDate = (verb: string, days: number | null) => { if (days !== null) dated.push({ verb, days }); };
|
|
332
|
-
addDate("Updated", daysSince(documentFields?.updatedAt));
|
|
333
|
-
addDate("Reviewed", daysSince(documentFields?.lastReviewedAt));
|
|
334
|
-
addDate("Published", daysSince(documentFields?.publishedAt));
|
|
335
|
-
if (dated.length > 0) {
|
|
336
|
-
const freshest = dated.reduce((a, b) => (b.days < a.days ? b : a));
|
|
337
|
-
const days = freshest.days;
|
|
338
|
-
const ago = days <= 0 ? "today" : days === 1 ? "1 day ago" : `${days} days ago`;
|
|
339
|
-
const value = `${freshest.verb} ${ago}`;
|
|
340
|
-
if (days <= 14) {
|
|
341
|
-
items.push({ label: "Content Freshness", value, status: "good", recommendation: "Recent content gets cited and ranked more. Re-set the Updated-on date whenever you revise to keep it fresh." });
|
|
342
|
-
} else if (days <= 90) {
|
|
343
|
-
items.push({ label: "Content Freshness", value, status: "warning", recommendation: "Content older than two weeks gets cited less by AI search. If it's still accurate, refresh a stat and set the Updated-on date in Sanity." });
|
|
344
|
-
} else {
|
|
345
|
-
items.push({ label: "Content Freshness", value, status: "error", recommendation: "Over 90 days old. Review the facts, update what's stale, and set the Updated-on date in Sanity." });
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
return items;
|
|
350
|
-
}, [documentFields]);
|
|
351
|
-
|
|
352
|
-
// Publish Date - the leading "normal category" card, shown first (above Title Tag).
|
|
353
|
-
const publishDateItem = useMemo<TechnicalAuditItem>(() => {
|
|
354
|
-
const published = documentFields?.publishedAt;
|
|
355
|
-
const daysPub = daysSince(published);
|
|
356
|
-
if (!published) return { 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." };
|
|
357
|
-
if (daysPub === null) return { 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." };
|
|
358
|
-
return { label: "Publish Date", value: formatDateShort(published), status: "good" };
|
|
359
|
-
}, [documentFields]);
|
|
360
|
-
|
|
361
|
-
// Show a single loading placeholder while document fields are being read,
|
|
362
|
-
// so we don't flash "Missing" cards based on the previous doc / no doc.
|
|
363
|
-
const hasAnyField =
|
|
364
|
-
!!documentFields &&
|
|
365
|
-
(documentFields.title !== undefined ||
|
|
366
|
-
documentFields.metaDescription !== undefined ||
|
|
367
|
-
documentFields.slug !== undefined);
|
|
368
|
-
if (isLoading && !hasAnyField) {
|
|
369
|
-
return (
|
|
370
|
-
<div style={{ padding: 24, textAlign: "center" }}>
|
|
371
|
-
<div style={{ fontSize: 13, color: "#4b5563", fontWeight: 500 }}>Reading document fields...</div>
|
|
372
|
-
<div style={{ fontSize: 11, color: "#4b5563", marginTop: 4 }}>Audit will run once content loads</div>
|
|
373
|
-
</div>
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// Anchor IDs let the Summary tab deep-link straight to a specific audit card.
|
|
378
|
-
const auditAnchors = ["anchor-meta-title", "anchor-meta-description"];
|
|
379
|
-
|
|
380
|
-
return (
|
|
381
|
-
<div style={{ padding: 12, display: "flex", flexDirection: "column", gap: 10 }}>
|
|
382
|
-
{/* "Keep it fresh" notice pinned at the very top (moved here from the AEO tab). */}
|
|
383
|
-
<FreshnessNotice />
|
|
384
|
-
|
|
385
|
-
{/* Publish Date - the first normal-category card, above Title Tag. */}
|
|
386
|
-
<AuditCard
|
|
387
|
-
anchorId="anchor-publish-date"
|
|
388
|
-
label={publishDateItem.label}
|
|
389
|
-
value={publishDateItem.value}
|
|
390
|
-
status={publishDateItem.status}
|
|
391
|
-
recommendation={publishDateItem.recommendation}
|
|
392
|
-
/>
|
|
393
|
-
|
|
394
|
-
{audits.map((a, i) => (
|
|
395
|
-
<AuditCard
|
|
396
|
-
key={i}
|
|
397
|
-
anchorId={auditAnchors[i]}
|
|
398
|
-
label={a.label}
|
|
399
|
-
value={a.value}
|
|
400
|
-
status={a.status}
|
|
401
|
-
recommendation={a.recommendation}
|
|
402
|
-
/>
|
|
403
|
-
))}
|
|
404
|
-
|
|
405
|
-
{eeatItems.length > 0 && (
|
|
406
|
-
<>
|
|
407
|
-
<div style={{ display: "flex", alignItems: "center", gap: 8, margin: "6px 4px 0" }}>
|
|
408
|
-
<div style={{ height: 1, flex: 1, background: "rgba(0,0,0,0.06)" }} />
|
|
409
|
-
<span style={{ fontSize: 10, fontWeight: 700, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.08em" }}>
|
|
410
|
-
Author & Freshness
|
|
411
|
-
</span>
|
|
412
|
-
<div style={{ height: 1, flex: 1, background: "rgba(0,0,0,0.06)" }} />
|
|
413
|
-
</div>
|
|
414
|
-
<div style={{ fontSize: 10, color: "#4b5563", padding: "0 4px", marginTop: -4 }}>
|
|
415
|
-
Google looks for a named author with credentials and recent updates on healthcare content.
|
|
416
|
-
</div>
|
|
417
|
-
{eeatItems.map((item, i) => (
|
|
418
|
-
<AuditCard
|
|
419
|
-
key={`eeat-${i}`}
|
|
420
|
-
label={item.label}
|
|
421
|
-
value={item.value}
|
|
422
|
-
status={item.status}
|
|
423
|
-
recommendation={item.recommendation}
|
|
424
|
-
footer={item.footer}
|
|
425
|
-
/>
|
|
426
|
-
))}
|
|
427
|
-
</>
|
|
428
|
-
)}
|
|
429
|
-
</div>
|
|
430
|
-
);
|
|
431
|
-
}
|