sanity-plugin-seo-copilot 0.2.12 → 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 +1506 -1086
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1474 -1054
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/KeywordPanel.tsx +190 -176
- package/src/components/ReportProblemButton.tsx +212 -0
- package/src/components/SEOCopilotPanel.tsx +37 -9
- package/src/components/styles.ts +7 -0
- package/src/components/tabs/AEOTab.tsx +5 -1
- 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/hooks/useKeywordAnalysis.ts +8 -7
- package/src/lib/api.ts +21 -52
- package/src/lib/documentExtract.ts +168 -14
- package/src/lib/scoring.ts +4 -4
- package/src/lib/summary.ts +23 -14
- package/src/lib/types.ts +12 -0
|
@@ -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) => {
|
|
@@ -522,7 +530,6 @@ function PanelContent({
|
|
|
522
530
|
text={text}
|
|
523
531
|
deepAnalysis={keywordAnalysisState.deepAnalysis}
|
|
524
532
|
isDeepLoading={keywordAnalysisState.isDeepLoading}
|
|
525
|
-
primaryKeyword={effectivePrimary}
|
|
526
533
|
publication={publication}
|
|
527
534
|
runDeepAnalysis={keywordAnalysisState.runDeepAnalysis}
|
|
528
535
|
aeoContentChanged={keywordAnalysisState.aeoContentChanged}
|
|
@@ -754,7 +761,7 @@ function SEOCopilotInner({ config, onClose }: { config: SEOCopilotConfig; onClos
|
|
|
754
761
|
const [chatOpen, setChatOpen] = usePersistentState<boolean>("seo-copilot-ui-chat-open-v35", false);
|
|
755
762
|
const [splitPercent, setSplitPercent] = usePersistentState<number>("seo-copilot-ui-split", 70);
|
|
756
763
|
|
|
757
|
-
const keywordAnalysisState = useKeywordAnalysis(text, apiUrl, effectivePublication, seedKeywords, documentFields, selectedPrimary, documentId);
|
|
764
|
+
const keywordAnalysisState = useKeywordAnalysis(text, apiUrl, effectivePublication, seedKeywords, documentFields, selectedPrimary, documentId, selectedSecondary);
|
|
758
765
|
|
|
759
766
|
// Effective primary (matches PanelContent's resolution)
|
|
760
767
|
const effectivePrimary = selectedPrimary || keywordAnalysisState.analysis?.primaryKeyword?.term || "";
|
|
@@ -986,6 +993,33 @@ function SEOCopilotInner({ config, onClose }: { config: SEOCopilotConfig; onClos
|
|
|
986
993
|
};
|
|
987
994
|
}, []);
|
|
988
995
|
|
|
996
|
+
// Re-run the WHOLE copilot (deep analysis + content suggestions + linking + link check),
|
|
997
|
+
// the same set the Summary tab's "Generate everything" button fires.
|
|
998
|
+
const runAllAnalyses = () => {
|
|
999
|
+
keywordAnalysisState.runDeepAnalysis();
|
|
1000
|
+
if (text && text.trim().length >= 100) loadContentSuggestions();
|
|
1001
|
+
if (text && text.trim().length >= 50 && effectivePrimary) refreshLinkingSuggestions();
|
|
1002
|
+
if ((documentFields?.bodyLinks || []).length > 0) runLinkCheck();
|
|
1003
|
+
};
|
|
1004
|
+
const runAllRef = useRef(runAllAnalyses);
|
|
1005
|
+
runAllRef.current = runAllAnalyses;
|
|
1006
|
+
|
|
1007
|
+
// Choosing or changing the secondary keyword on the CURRENT document re-runs everything so
|
|
1008
|
+
// every tab re-optimizes toward both keywords. Skip document switches and the first mount
|
|
1009
|
+
// (those are not user picks, just cache loads).
|
|
1010
|
+
const secAutoRunRef = useRef<{ doc?: string; sec: string; init: boolean }>({ doc: documentId, sec: selectedSecondary, init: true });
|
|
1011
|
+
useEffect(() => {
|
|
1012
|
+
const prev = secAutoRunRef.current;
|
|
1013
|
+
const docChanged = prev.doc !== documentId;
|
|
1014
|
+
const secChanged = prev.sec !== selectedSecondary;
|
|
1015
|
+
secAutoRunRef.current = { doc: documentId, sec: selectedSecondary, init: false };
|
|
1016
|
+
if (prev.init || docChanged || !secChanged) return;
|
|
1017
|
+
// Debounce so clicking THROUGH several secondary options only fires one full run-all.
|
|
1018
|
+
const t = setTimeout(() => runAllRef.current(), 1500);
|
|
1019
|
+
return () => clearTimeout(t);
|
|
1020
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1021
|
+
}, [selectedSecondary, documentId]);
|
|
1022
|
+
|
|
989
1023
|
const handleDragStart = useCallback(
|
|
990
1024
|
(e: React.MouseEvent) => {
|
|
991
1025
|
dragOffset.current = {
|
|
@@ -1127,13 +1161,7 @@ function SEOCopilotInner({ config, onClose }: { config: SEOCopilotConfig; onClos
|
|
|
1127
1161
|
isCSLoading ||
|
|
1128
1162
|
isLinkingLoading ||
|
|
1129
1163
|
isLinkCheckLoading,
|
|
1130
|
-
onGenerateAll:
|
|
1131
|
-
keywordAnalysisState.runDeepAnalysis();
|
|
1132
|
-
if (text && text.trim().length >= 100) loadContentSuggestions();
|
|
1133
|
-
if (text && text.trim().length >= 50 && effectivePrimary) refreshLinkingSuggestions();
|
|
1134
|
-
// Also run the broken-link check so Summary picks up any 404s.
|
|
1135
|
-
if ((documentFields?.bodyLinks || []).length > 0) runLinkCheck();
|
|
1136
|
-
},
|
|
1164
|
+
onGenerateAll: runAllAnalyses,
|
|
1137
1165
|
onItemClick: (item) => {
|
|
1138
1166
|
setActiveTab(item.jumpTo.tab);
|
|
1139
1167
|
const id = item.jumpTo.anchorId;
|
package/src/components/styles.ts
CHANGED
|
@@ -38,6 +38,13 @@ export const INJECTED_CSS = `
|
|
|
38
38
|
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
39
39
|
to { opacity: 0; transform: translateY(-6px) scale(0.97); }
|
|
40
40
|
}
|
|
41
|
+
@keyframes seo-copilot-sec-float {
|
|
42
|
+
0%, 100% { transform: translateY(0); }
|
|
43
|
+
50% { transform: translateY(-1.5px); }
|
|
44
|
+
}
|
|
45
|
+
@media (prefers-reduced-motion: reduce) {
|
|
46
|
+
.seo-copilot-sec-circle { animation: none !important; }
|
|
47
|
+
}
|
|
41
48
|
.prose-chat { font-size: 12.5px; line-height: 1.65; color: #475569; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }
|
|
42
49
|
.prose-chat h1 { font-size: 14px; font-weight: 700; color: #1e293b; margin: 10px 0 5px 0; line-height: 1.35; }
|
|
43
50
|
.prose-chat h2, .prose-chat h3 { font-size: 13px; font-weight: 700; color: #1e293b; margin: 10px 0 5px 0; line-height: 1.35; }
|
|
@@ -12,7 +12,6 @@ interface AEOTabProps {
|
|
|
12
12
|
text: string;
|
|
13
13
|
deepAnalysis: DeepAnalysis | null;
|
|
14
14
|
isDeepLoading: boolean;
|
|
15
|
-
primaryKeyword: string;
|
|
16
15
|
publication?: string;
|
|
17
16
|
runDeepAnalysis: () => void;
|
|
18
17
|
aeoContentChanged: boolean;
|
|
@@ -310,10 +309,15 @@ export function AEOTab({
|
|
|
310
309
|
{/* The AI-generated disclaimer lives in the panel-level notice now, above
|
|
311
310
|
the tab bar - so every tab shows it once, not per-tab. */}
|
|
312
311
|
|
|
312
|
+
{/* The "Keep it fresh" / Updated-on notice now lives at the top of the Meta tab. */}
|
|
313
|
+
|
|
313
314
|
{/* Content changed banner */}
|
|
314
315
|
{aeoContentChanged && (
|
|
315
316
|
<div
|
|
316
317
|
onClick={runDeepAnalysis}
|
|
318
|
+
role="button"
|
|
319
|
+
tabIndex={0}
|
|
320
|
+
onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); runDeepAnalysis(); } }}
|
|
317
321
|
style={{
|
|
318
322
|
padding: "8px 12px",
|
|
319
323
|
background: "#fffbeb",
|
|
@@ -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
|
</>
|