sanity-plugin-seo-copilot 0.2.13 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,72 @@
1
1
  import { useMemo } from "react";
2
2
  import type { DocumentFields, TechnicalAuditItem } from "../../lib/types";
3
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&apos;s published? Set the <strong>Updated on</strong> date in Sanity
65
+ (e.g. &ldquo;Updated: February 19, 2026&rdquo;). It surfaces the article in <strong>Latest Updated Articles</strong> and
66
+ increases its visibility in search engine results.
67
+ </div>
68
+ );
69
+ }
4
70
 
5
71
  interface MetaTabProps {
6
72
  documentFields?: DocumentFields;
@@ -221,8 +287,8 @@ export function MetaTab({ documentFields, primaryKeyword, secondaryKeyword, isLo
221
287
  }, [documentFields, primaryKeyword, secondaryKeyword]);
222
288
 
223
289
  // E-E-A-T audit - critical for healthcare YMYL-adjacent content per 2026 Google scrutiny
224
- const eeatItems = useMemo(() => {
225
- const items: TechnicalAuditItem[] = [];
290
+ const eeatItems = useMemo<EEATItem[]>(() => {
291
+ const items: EEATItem[] = [];
226
292
  const author = documentFields?.authorName;
227
293
  const creds = documentFields?.authorCredentials;
228
294
  const bio = documentFields?.authorBioUrl;
@@ -240,39 +306,58 @@ export function MetaTab({ documentFields, primaryKeyword, secondaryKeyword, isLo
240
306
  } else {
241
307
  items.push({ label: "Author Byline", value: `${author}, ${creds}`, status: "good" });
242
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" />;
243
311
 
244
- const published = documentFields?.publishedAt;
245
- const updated = documentFields?.updatedAt;
246
- const reviewed = documentFields?.lastReviewedAt;
247
- const daysPub = daysSince(published);
248
- const daysUpd = daysSince(updated);
249
- const daysRev = daysSince(reviewed);
250
- const freshness = Math.min(...[daysUpd, daysRev, daysPub].filter((d): d is number => d !== null));
251
-
252
- if (!published) {
253
- 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." });
254
- } else if (daysPub === null) {
255
- // A date is set but couldn't be parsed - don't show a blank/garbage value in a green "Good" badge.
256
- 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." });
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." });
257
320
  } else {
258
- items.push({ label: "Publish Date", value: formatDateShort(published), status: "good" });
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." });
259
322
  }
260
323
 
261
- // Freshness signal - articles fall off AI Overview citations after about 14 days
262
- // without updates; 90+ days is effectively stale.
263
- if (Number.isFinite(freshness)) {
264
- if (freshness <= 14) {
265
- items.push({ label: "Last Updated", value: `${freshness} day${freshness === 1 ? "" : "s"} ago`, status: "good" });
266
- } else if (freshness <= 90) {
267
- 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." });
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." });
268
344
  } else {
269
- 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." });
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." });
270
346
  }
271
347
  }
272
348
 
273
349
  return items;
274
350
  }, [documentFields]);
275
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
+
276
361
  // Show a single loading placeholder while document fields are being read,
277
362
  // so we don't flash "Missing" cards based on the previous doc / no doc.
278
363
  const hasAnyField =
@@ -294,6 +379,18 @@ export function MetaTab({ documentFields, primaryKeyword, secondaryKeyword, isLo
294
379
 
295
380
  return (
296
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
+
297
394
  {audits.map((a, i) => (
298
395
  <AuditCard
299
396
  key={i}
@@ -324,6 +421,7 @@ export function MetaTab({ documentFields, primaryKeyword, secondaryKeyword, isLo
324
421
  value={item.value}
325
422
  status={item.status}
326
423
  recommendation={item.recommendation}
424
+ footer={item.footer}
327
425
  />
328
426
  ))}
329
427
  </>
@@ -60,13 +60,23 @@ function scoreColors(score: number): { bg: string; text: string; label: string }
60
60
  return { bg: "rgba(220,38,38,0.08)", text: "#dc2626", label: "Needs work" };
61
61
  }
62
62
 
63
- // The score card. The breakdown is ALWAYS visible - the score is just a roll-up
64
- // of the six visible components below it. No hidden state, no "click to see why".
63
+ // Qualitative tier for a single score component. We deliberately show a word + color,
64
+ // not "points / max" - the underlying numbers are coarse heuristics, and a precise-looking
65
+ // "17 / 25" implies an accuracy the rubric doesn't actually have.
66
+ function componentTier(pct: number): { label: string; color: string; bar: string } {
67
+ if (pct >= 75) return { label: "Strong", color: "#16a34a", bar: "#16a34a" };
68
+ if (pct >= 40) return { label: "OK", color: "#8B7310", bar: "#E6C01B" };
69
+ return { label: "Low", color: "#dc2626", bar: "#dc2626" };
70
+ }
71
+
72
+ // The score card. The breakdown is ALWAYS visible - the overall tier is just a roll-up
73
+ // of the components below it. No raw numbers: each row reads as a colored "vibe" (Strong /
74
+ // OK / Low) so editors focus on what's weak, not on chasing an arbitrary point total.
65
75
  function ScoreBadge({ score, breakdown }: { score: number; breakdown: ContentScore["components"] }) {
66
76
  const c = scoreColors(score);
67
77
  return (
68
78
  <div style={cardStyle}>
69
- {/* Top row: number + label */}
79
+ {/* Top row: qualitative tier + label (no number) */}
70
80
  <div style={{ display: "flex", alignItems: "center", gap: 14 }}>
71
81
  <div
72
82
  style={{
@@ -75,42 +85,38 @@ function ScoreBadge({ score, breakdown }: { score: number; breakdown: ContentSco
75
85
  borderRadius: "50%",
76
86
  background: c.bg,
77
87
  display: "flex",
78
- flexDirection: "column",
79
88
  alignItems: "center",
80
89
  justifyContent: "center",
81
90
  flexShrink: 0,
82
- lineHeight: 1,
83
91
  }}
84
92
  >
85
- <span style={{ fontSize: 20, fontWeight: 700, color: c.text }}>{score}</span>
86
- <span style={{ fontSize: 8, fontWeight: 700, color: c.text, opacity: 0.7, letterSpacing: "0.06em", marginTop: 2 }}>
87
- / 100
88
- </span>
93
+ {/* Solid status disc - a color cue, not a number */}
94
+ <div style={{ width: 22, height: 22, borderRadius: "50%", background: c.text, opacity: 0.9 }} />
89
95
  </div>
90
96
  <div style={{ flex: 1, minWidth: 0 }}>
91
97
  <div style={{ fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600, marginBottom: 2 }}>
92
98
  Content Score
93
99
  </div>
94
- <div style={{ fontSize: 14, fontWeight: 700, color: c.text }}>{c.label}</div>
100
+ <div style={{ fontSize: 16, fontWeight: 700, color: c.text }}>{c.label}</div>
95
101
  </div>
96
102
  </div>
97
103
 
98
- {/* Always-visible breakdown - each row shows what's driving the score */}
104
+ {/* Always-visible breakdown - each row shows what's driving the score, as a vibe */}
99
105
  {breakdown.length > 0 && (
100
106
  <div style={{ marginTop: 12, display: "flex", flexDirection: "column", gap: 8 }}>
101
107
  {breakdown.map((comp, i) => {
102
108
  const pct = comp.max > 0 ? (comp.points / comp.max) * 100 : 0;
103
- const barColor = pct >= 75 ? "#16a34a" : pct >= 40 ? "#E6C01B" : "#dc2626";
109
+ const tier = componentTier(pct);
104
110
  return (
105
111
  <div key={i}>
106
112
  <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", marginBottom: 3 }}>
107
113
  <span style={{ fontSize: 11, fontWeight: 600, color: "#1f2937" }}>{comp.label}</span>
108
- <span style={{ fontSize: 11, color: "#4b5563", fontVariantNumeric: "tabular-nums" }}>
109
- {comp.points} / {comp.max}
114
+ <span style={{ fontSize: 9.5, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.04em", color: tier.color }}>
115
+ {tier.label}
110
116
  </span>
111
117
  </div>
112
118
  <div style={{ height: 4, background: "#f1f5f9", borderRadius: 99, overflow: "hidden", marginBottom: 4 }}>
113
- <div style={{ width: `${pct}%`, height: "100%", background: barColor, transition: "width 200ms" }} />
119
+ <div style={{ width: `${pct}%`, height: "100%", background: tier.bar, transition: "width 200ms" }} />
114
120
  </div>
115
121
  <div style={{ fontSize: 10.5, color: "#4b5563", lineHeight: 1.4 }}>{comp.detail}</div>
116
122
  </div>