sanity-plugin-seo-copilot 0.2.13 → 0.2.14
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 +1253 -865
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1226 -838
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/ReportProblemButton.tsx +212 -0
- package/src/components/SEOCopilotPanel.tsx +8 -0
- package/src/components/tabs/AEOTab.tsx +2 -0
- package/src/components/tabs/LinkingTab.tsx +39 -13
- package/src/components/tabs/MetaTab.tsx +122 -24
- package/src/components/tabs/SummaryTab.tsx +21 -15
- package/src/components/tabs/TechnicalTab.tsx +276 -269
- package/src/lib/api.ts +18 -2
- package/src/lib/documentExtract.ts +168 -14
- package/src/lib/scoring.ts +4 -4
- package/src/lib/summary.ts +22 -13
- package/src/lib/types.ts +12 -0
package/package.json
CHANGED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { useState, useRef, useEffect } from "react";
|
|
2
|
+
import { useCurrentUser } from "sanity";
|
|
3
|
+
import { useConfig } from "./ConfigContext";
|
|
4
|
+
import { submitFeedback } from "../lib/api";
|
|
5
|
+
import { MJH_BLUE } from "./styles";
|
|
6
|
+
|
|
7
|
+
interface ReportProblemButtonProps {
|
|
8
|
+
activeTab?: string;
|
|
9
|
+
publication?: string;
|
|
10
|
+
documentId?: string;
|
|
11
|
+
documentType?: string;
|
|
12
|
+
primaryKeyword?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Header "Report a problem" affordance. Opens a small message box AND captures
|
|
16
|
+
// structured context (which surface + tab was open, the doc + publication + keyword,
|
|
17
|
+
// the URL, the user agent) so we can debug widespread-adoption issues - not just read
|
|
18
|
+
// the written note. Posts to the shared /feedback endpoint as suggestion_type
|
|
19
|
+
// "bug_report". Never throws into the UI; failures are swallowed.
|
|
20
|
+
export function ReportProblemButton({ activeTab, publication, documentId, documentType, primaryKeyword }: ReportProblemButtonProps) {
|
|
21
|
+
const { apiUrl } = useConfig();
|
|
22
|
+
const sanityUser = useCurrentUser();
|
|
23
|
+
const [open, setOpen] = useState(false);
|
|
24
|
+
const [text, setText] = useState("");
|
|
25
|
+
const [submitting, setSubmitting] = useState(false);
|
|
26
|
+
const [submitted, setSubmitted] = useState(false);
|
|
27
|
+
const [failed, setFailed] = useState(false);
|
|
28
|
+
const popRef = useRef<HTMLDivElement>(null);
|
|
29
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
30
|
+
const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
31
|
+
const mounted = useRef(true);
|
|
32
|
+
|
|
33
|
+
useEffect(() => () => { mounted.current = false; if (closeTimer.current) clearTimeout(closeTimer.current); }, []);
|
|
34
|
+
|
|
35
|
+
// Close on outside click.
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!open) return;
|
|
38
|
+
const handler = (e: MouseEvent) => {
|
|
39
|
+
if (popRef.current && !popRef.current.contains(e.target as Node)) setOpen(false);
|
|
40
|
+
};
|
|
41
|
+
document.addEventListener("mousedown", handler);
|
|
42
|
+
return () => document.removeEventListener("mousedown", handler);
|
|
43
|
+
}, [open]);
|
|
44
|
+
|
|
45
|
+
// Focus the textarea when the dialog opens.
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (open) setTimeout(() => textareaRef.current?.focus(), 50);
|
|
48
|
+
}, [open]);
|
|
49
|
+
|
|
50
|
+
const handleSubmit = async () => {
|
|
51
|
+
const trimmed = text.trim();
|
|
52
|
+
if (!trimmed || submitting) return;
|
|
53
|
+
setFailed(false);
|
|
54
|
+
setSubmitting(true);
|
|
55
|
+
try {
|
|
56
|
+
await submitFeedback(apiUrl, {
|
|
57
|
+
suggestion_type: "bug_report",
|
|
58
|
+
suggestion_text: trimmed.slice(0, 10000),
|
|
59
|
+
vote: "down",
|
|
60
|
+
document_id: documentId,
|
|
61
|
+
publication,
|
|
62
|
+
user_id: sanityUser?.id,
|
|
63
|
+
context: {
|
|
64
|
+
surface: "sanity-plugin",
|
|
65
|
+
activeTab,
|
|
66
|
+
primaryKeyword: primaryKeyword || undefined,
|
|
67
|
+
documentType,
|
|
68
|
+
url: typeof window !== "undefined" && /^https?:\/\//i.test(window.location.href) ? window.location.href.slice(0, 500) : undefined,
|
|
69
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent.slice(0, 500) : undefined,
|
|
70
|
+
timestamp: new Date().toISOString(),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
} catch (e) {
|
|
74
|
+
// Show a real error + keep the box open so the report isn't silently lost. Log it too.
|
|
75
|
+
console.error("[SEO Copilot] failed to send problem report:", e);
|
|
76
|
+
if (mounted.current) { setSubmitting(false); setFailed(true); }
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (!mounted.current) return;
|
|
80
|
+
setSubmitting(false);
|
|
81
|
+
setSubmitted(true);
|
|
82
|
+
closeTimer.current = setTimeout(() => {
|
|
83
|
+
if (!mounted.current) return;
|
|
84
|
+
setOpen(false);
|
|
85
|
+
setSubmitted(false);
|
|
86
|
+
setText("");
|
|
87
|
+
}, 1500);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div style={{ position: "relative", display: "flex" }}>
|
|
92
|
+
<button
|
|
93
|
+
type="button"
|
|
94
|
+
onClick={(e) => { e.stopPropagation(); if (closeTimer.current) { clearTimeout(closeTimer.current); closeTimer.current = null; } setOpen((o) => !o); }}
|
|
95
|
+
onMouseDown={(e) => e.stopPropagation()}
|
|
96
|
+
aria-label="Report a problem"
|
|
97
|
+
title="Report a problem"
|
|
98
|
+
style={{
|
|
99
|
+
display: "inline-flex",
|
|
100
|
+
alignItems: "center",
|
|
101
|
+
gap: 4,
|
|
102
|
+
padding: "3px 8px",
|
|
103
|
+
borderRadius: 99,
|
|
104
|
+
border: `1px solid ${open ? MJH_BLUE : "#d1d5db"}`,
|
|
105
|
+
background: open ? "rgba(0,93,172,0.08)" : "rgba(255,255,255,0.6)",
|
|
106
|
+
cursor: "pointer",
|
|
107
|
+
fontSize: 10,
|
|
108
|
+
fontWeight: 600,
|
|
109
|
+
color: open ? MJH_BLUE : "#6b7280",
|
|
110
|
+
whiteSpace: "nowrap",
|
|
111
|
+
transition: "all 150ms",
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
<svg width="11" height="11" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
|
115
|
+
<path d="M3 2.75a.75.75 0 00-1.5 0v14.5a.75.75 0 001.5 0v-4.392l1.657-.348a6.449 6.449 0 014.271.572 7.948 7.948 0 005.965.524l2.078-.64A.75.75 0 0017.5 12.25v-8.5a.75.75 0 00-.904-.734l-1.74.348a7.948 7.948 0 01-5.965-.524 6.449 6.449 0 00-4.271-.572L3 2.842V2.75z" />
|
|
116
|
+
</svg>
|
|
117
|
+
Report a problem
|
|
118
|
+
</button>
|
|
119
|
+
|
|
120
|
+
{open && (
|
|
121
|
+
<div
|
|
122
|
+
ref={popRef}
|
|
123
|
+
onMouseDown={(e) => e.stopPropagation()}
|
|
124
|
+
style={{
|
|
125
|
+
position: "absolute",
|
|
126
|
+
top: "100%",
|
|
127
|
+
right: 0,
|
|
128
|
+
marginTop: 6,
|
|
129
|
+
width: 260,
|
|
130
|
+
padding: 12,
|
|
131
|
+
borderRadius: 10,
|
|
132
|
+
background: "#ffffff",
|
|
133
|
+
boxShadow: "0 6px 22px rgba(0,0,0,0.16), 0 1px 4px rgba(0,0,0,0.1)",
|
|
134
|
+
border: "1px solid #e5e7eb",
|
|
135
|
+
zIndex: 100,
|
|
136
|
+
}}
|
|
137
|
+
>
|
|
138
|
+
{submitted ? (
|
|
139
|
+
<div style={{ fontSize: 12, color: "#16a34a", textAlign: "center", padding: "6px 0", fontWeight: 600 }}>
|
|
140
|
+
Thanks - we got it.
|
|
141
|
+
</div>
|
|
142
|
+
) : (
|
|
143
|
+
<>
|
|
144
|
+
<div style={{ fontSize: 12, fontWeight: 700, color: "#1f2937", marginBottom: 3 }}>
|
|
145
|
+
Report a problem
|
|
146
|
+
</div>
|
|
147
|
+
<div style={{ fontSize: 10.5, color: "#6b7280", marginBottom: 8, lineHeight: 1.45 }}>
|
|
148
|
+
Beta - tell us what went wrong. We also note which tab you're on to help us track it down.
|
|
149
|
+
</div>
|
|
150
|
+
{failed && (
|
|
151
|
+
<div style={{ fontSize: 10.5, color: "#dc2626", marginBottom: 8, lineHeight: 1.45, fontWeight: 600 }}>
|
|
152
|
+
Couldn't send - please try again.
|
|
153
|
+
</div>
|
|
154
|
+
)}
|
|
155
|
+
<textarea
|
|
156
|
+
ref={textareaRef}
|
|
157
|
+
value={text}
|
|
158
|
+
onChange={(e) => setText(e.target.value)}
|
|
159
|
+
onKeyDown={(e) => {
|
|
160
|
+
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) { e.preventDefault(); handleSubmit(); }
|
|
161
|
+
}}
|
|
162
|
+
placeholder="What happened? The more detail, the better."
|
|
163
|
+
rows={4}
|
|
164
|
+
maxLength={4000}
|
|
165
|
+
style={{
|
|
166
|
+
width: "100%",
|
|
167
|
+
padding: "6px 8px",
|
|
168
|
+
fontSize: 11,
|
|
169
|
+
borderRadius: 6,
|
|
170
|
+
border: "1px solid #e5e7eb",
|
|
171
|
+
outline: "none",
|
|
172
|
+
fontFamily: "inherit",
|
|
173
|
+
resize: "vertical",
|
|
174
|
+
boxSizing: "border-box",
|
|
175
|
+
lineHeight: 1.5,
|
|
176
|
+
}}
|
|
177
|
+
/>
|
|
178
|
+
<div style={{ display: "flex", justifyContent: "flex-end", marginTop: 8, gap: 6 }}>
|
|
179
|
+
<button
|
|
180
|
+
type="button"
|
|
181
|
+
onClick={() => { setOpen(false); setText(""); }}
|
|
182
|
+
style={{
|
|
183
|
+
padding: "4px 10px", fontSize: 10.5, borderRadius: 5,
|
|
184
|
+
border: "1px solid #e5e7eb", background: "#ffffff", color: "#4b5563",
|
|
185
|
+
cursor: "pointer",
|
|
186
|
+
}}
|
|
187
|
+
>
|
|
188
|
+
Cancel
|
|
189
|
+
</button>
|
|
190
|
+
<button
|
|
191
|
+
type="button"
|
|
192
|
+
onClick={handleSubmit}
|
|
193
|
+
disabled={!text.trim() || submitting}
|
|
194
|
+
style={{
|
|
195
|
+
padding: "4px 12px", fontSize: 10.5, borderRadius: 5,
|
|
196
|
+
border: "none",
|
|
197
|
+
background: !text.trim() || submitting ? "#cbd5e1" : MJH_BLUE,
|
|
198
|
+
color: "#ffffff",
|
|
199
|
+
cursor: !text.trim() || submitting ? "default" : "pointer",
|
|
200
|
+
fontWeight: 700,
|
|
201
|
+
}}
|
|
202
|
+
>
|
|
203
|
+
{submitting ? "Sending..." : "Send"}
|
|
204
|
+
</button>
|
|
205
|
+
</div>
|
|
206
|
+
</>
|
|
207
|
+
)}
|
|
208
|
+
</div>
|
|
209
|
+
)}
|
|
210
|
+
</div>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
@@ -9,6 +9,7 @@ import { KeywordPanel } from "./KeywordPanel";
|
|
|
9
9
|
import { ChatPanel } from "./ChatPanel";
|
|
10
10
|
import { TabBar } from "./TabBar";
|
|
11
11
|
import { OnboardingInfoButton, OnboardingCard } from "./OnboardingPopup";
|
|
12
|
+
import { ReportProblemButton } from "./ReportProblemButton";
|
|
12
13
|
import { SummaryTab } from "./tabs/SummaryTab";
|
|
13
14
|
import { AEOTab } from "./tabs/AEOTab";
|
|
14
15
|
import { LinkingTab } from "./tabs/LinkingTab";
|
|
@@ -304,6 +305,13 @@ function PanelContent({
|
|
|
304
305
|
</div>
|
|
305
306
|
<div style={{ display: "flex", alignItems: "center", gap: isFloating ? 4 : 6 }}>
|
|
306
307
|
<OnboardingInfoButton onClick={openPopupPersistent} />
|
|
308
|
+
<ReportProblemButton
|
|
309
|
+
activeTab={activeTab}
|
|
310
|
+
publication={publication}
|
|
311
|
+
documentId={documentId}
|
|
312
|
+
documentType={documentType}
|
|
313
|
+
primaryKeyword={effectivePrimary}
|
|
314
|
+
/>
|
|
307
315
|
{isFloating && onToggleFullscreen && (
|
|
308
316
|
<button
|
|
309
317
|
onClick={(e) => {
|
|
@@ -309,6 +309,8 @@ export function AEOTab({
|
|
|
309
309
|
{/* The AI-generated disclaimer lives in the panel-level notice now, above
|
|
310
310
|
the tab bar - so every tab shows it once, not per-tab. */}
|
|
311
311
|
|
|
312
|
+
{/* The "Keep it fresh" / Updated-on notice now lives at the top of the Meta tab. */}
|
|
313
|
+
|
|
312
314
|
{/* Content changed banner */}
|
|
313
315
|
{aeoContentChanged && (
|
|
314
316
|
<div
|
|
@@ -77,6 +77,32 @@ function LinkChip({ href, label, color }: { href: string; label: string; color:
|
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
// At-a-glance status of whether this suggestion is a real, clickable link. Green when
|
|
81
|
+
// we have a live reader URL the editor can actually link to; muted when there's no live
|
|
82
|
+
// URL (the article can still be referenced inside Sanity, but it isn't directly clickable).
|
|
83
|
+
function ClickableBadge({ clickable }: { clickable: boolean }) {
|
|
84
|
+
return (
|
|
85
|
+
<span
|
|
86
|
+
style={{
|
|
87
|
+
fontSize: 9,
|
|
88
|
+
fontWeight: 700,
|
|
89
|
+
textTransform: "uppercase",
|
|
90
|
+
letterSpacing: "0.04em",
|
|
91
|
+
padding: "2px 7px",
|
|
92
|
+
borderRadius: 99,
|
|
93
|
+
display: "inline-flex",
|
|
94
|
+
alignItems: "center",
|
|
95
|
+
gap: 4,
|
|
96
|
+
background: clickable ? "rgba(22,163,74,0.12)" : "rgba(0,0,0,0.05)",
|
|
97
|
+
color: clickable ? "#16a34a" : "#9ca3af",
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
<span style={{ width: 5, height: 5, borderRadius: "50%", background: "currentColor" }} />
|
|
101
|
+
{clickable ? "Clickable link" : "No live link"}
|
|
102
|
+
</span>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
80
106
|
const cardStyle: React.CSSProperties = {
|
|
81
107
|
borderRadius: 14,
|
|
82
108
|
background: "rgba(255,255,255,0.55)",
|
|
@@ -327,7 +353,10 @@ export function LinkingTab({
|
|
|
327
353
|
|
|
328
354
|
{suggestions.length > 0 && (
|
|
329
355
|
<div style={{ display: "flex", flexDirection: "column", gap: 10 }}>
|
|
330
|
-
{suggestions.map((s) =>
|
|
356
|
+
{suggestions.map((s) => {
|
|
357
|
+
const liveUrl = buildLiveUrl(publication, s.slug);
|
|
358
|
+
const sanityUrl = buildSanityUrl(sanityBaseUrl, s._id); // omit type - resolves by ID, suggested doc type differs from current
|
|
359
|
+
return (
|
|
331
360
|
<div
|
|
332
361
|
key={s._id}
|
|
333
362
|
style={{
|
|
@@ -353,6 +382,7 @@ export function LinkingTab({
|
|
|
353
382
|
{s.publishedAt && (
|
|
354
383
|
<span style={{ fontSize: 10, color: "#4b5563" }}>{formatDate(s.publishedAt)}</span>
|
|
355
384
|
)}
|
|
385
|
+
<ClickableBadge clickable={!!liveUrl} />
|
|
356
386
|
</div>
|
|
357
387
|
<div style={{ fontSize: 12, fontWeight: 700, color: "#1f2937", lineHeight: 1.4, marginBottom: 2 }}>
|
|
358
388
|
{s.title}
|
|
@@ -360,17 +390,12 @@ export function LinkingTab({
|
|
|
360
390
|
<div style={{ fontSize: 10, color: "#4b5563", fontFamily: "ui-monospace, SFMono-Regular, monospace", marginBottom: 6 }}>
|
|
361
391
|
/{s.slug}
|
|
362
392
|
</div>
|
|
363
|
-
{(
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
{sanityUrl && <LinkChip href={sanityUrl} label="Inside Sanity" color={MJH_BLUE} />}
|
|
370
|
-
{liveUrl && <LinkChip href={liveUrl} label="Live site" color="#4b5563" />}
|
|
371
|
-
</div>
|
|
372
|
-
);
|
|
373
|
-
})()}
|
|
393
|
+
{(liveUrl || sanityUrl) && (
|
|
394
|
+
<div style={{ display: "flex", flexWrap: "wrap", gap: 6, marginBottom: 6 }}>
|
|
395
|
+
{sanityUrl && <LinkChip href={sanityUrl} label="Inside Sanity" color={MJH_BLUE} />}
|
|
396
|
+
{liveUrl && <LinkChip href={liveUrl} label="Live site" color="#4b5563" />}
|
|
397
|
+
</div>
|
|
398
|
+
)}
|
|
374
399
|
{s.relevanceReason && (
|
|
375
400
|
<div style={{ fontSize: 11, color: "#1f2937", marginBottom: 6, lineHeight: 1.45 }}>
|
|
376
401
|
<span style={{ fontWeight: 700, color: "#4b5563" }}>Why it fits:</span>{" "}
|
|
@@ -411,7 +436,8 @@ export function LinkingTab({
|
|
|
411
436
|
/>
|
|
412
437
|
</div>
|
|
413
438
|
</div>
|
|
414
|
-
|
|
439
|
+
);
|
|
440
|
+
})}
|
|
415
441
|
</div>
|
|
416
442
|
)}
|
|
417
443
|
</div>
|
|
@@ -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'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
|
+
}
|
|
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:
|
|
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
|
-
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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: "
|
|
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
|
|
262
|
-
//
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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: "
|
|
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
|
-
//
|
|
64
|
-
//
|
|
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:
|
|
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
|
-
|
|
86
|
-
<
|
|
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:
|
|
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
|
|
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:
|
|
109
|
-
{
|
|
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:
|
|
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>
|