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.
- package/dist/index.js +1283 -883
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1254 -854
- package/dist/index.mjs.map +1 -1
- package/package.json +64 -61
- package/src/components/KeywordPanel.tsx +4 -3
- 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/index.ts +18 -16
- package/src/lib/api.ts +30 -12
- package/src/lib/apiKey.ts +30 -0
- 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
|
@@ -1,61 +1,64 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "sanity-plugin-seo-copilot",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "AI-powered SEO writing assistant for Sanity Studio",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"sanity",
|
|
7
|
-
"sanity-plugin",
|
|
8
|
-
"seo",
|
|
9
|
-
"copilot"
|
|
10
|
-
],
|
|
11
|
-
"license": "UNLICENSED",
|
|
12
|
-
"author": "MJH Life Sciences",
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"source": "./src/index.ts",
|
|
16
|
-
"import": "./dist/index.mjs",
|
|
17
|
-
"require": "./dist/index.js",
|
|
18
|
-
"default": "./dist/index.js"
|
|
19
|
-
},
|
|
20
|
-
"./package.json": "./package.json"
|
|
21
|
-
},
|
|
22
|
-
"main": "./dist/index.js",
|
|
23
|
-
"module": "./dist/index.mjs",
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
25
|
-
"files": [
|
|
26
|
-
"dist",
|
|
27
|
-
"sanity.json",
|
|
28
|
-
"src",
|
|
29
|
-
"v2-incompatible.js"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"react": "^19.
|
|
45
|
-
"react-dom": "^19.2.
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"sanity": "^3.0.0
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
}
|
|
61
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "sanity-plugin-seo-copilot",
|
|
3
|
+
"version": "0.2.15",
|
|
4
|
+
"description": "AI-powered SEO writing assistant for Sanity Studio",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sanity",
|
|
7
|
+
"sanity-plugin",
|
|
8
|
+
"seo",
|
|
9
|
+
"copilot"
|
|
10
|
+
],
|
|
11
|
+
"license": "UNLICENSED",
|
|
12
|
+
"author": "MJH Life Sciences",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"source": "./src/index.ts",
|
|
16
|
+
"import": "./dist/index.mjs",
|
|
17
|
+
"require": "./dist/index.js",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"module": "./dist/index.mjs",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"sanity.json",
|
|
28
|
+
"src",
|
|
29
|
+
"v2-incompatible.js",
|
|
30
|
+
"!src/**/*.test.ts"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsup",
|
|
34
|
+
"prepublishOnly": "npm run build",
|
|
35
|
+
"test": "vitest run"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"react-markdown": "^10.1.0",
|
|
39
|
+
"remark-gfm": "^4.0.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@sanity/icons": "^3.7.4",
|
|
43
|
+
"@sanity/ui": "^3.1.13",
|
|
44
|
+
"@types/react": "^19.0.0",
|
|
45
|
+
"@types/react-dom": "^19.2.3",
|
|
46
|
+
"react": "^19.2.4",
|
|
47
|
+
"react-dom": "^19.2.4",
|
|
48
|
+
"sanity": "^5.13.0",
|
|
49
|
+
"styled-components": "^6.3.11",
|
|
50
|
+
"tsup": "^8.0.0",
|
|
51
|
+
"typescript": "^5.9.3",
|
|
52
|
+
"vitest": "^4.1.11"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@sanity/icons": "^3.0.0",
|
|
56
|
+
"@sanity/ui": "^2.0.0 || ^3.0.0",
|
|
57
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
58
|
+
"sanity": "^3.0.0 || ^5.0.0",
|
|
59
|
+
"styled-components": "^6.0.0"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=18"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -7,6 +7,7 @@ import { LoadingBars } from "./SEOCopilotPanel";
|
|
|
7
7
|
import { MJH_GOLD, MJH_BLUE } from "./styles";
|
|
8
8
|
import { usePersistentState, loadLocal } from "../lib/persistence";
|
|
9
9
|
import type { PrimaryKeywordCandidate, DocumentFields } from "../lib/types";
|
|
10
|
+
import { jsonHeaders } from "../lib/apiKey";
|
|
10
11
|
|
|
11
12
|
function loadLocalArray<T>(key: string): T[] {
|
|
12
13
|
return loadLocal<T[]>(key, []);
|
|
@@ -538,7 +539,7 @@ function SuggestedKeywordsCard({
|
|
|
538
539
|
: undefined;
|
|
539
540
|
const res = await fetch(`${apiUrl}/api/seo-copilot/keyword-help`, {
|
|
540
541
|
method: "POST",
|
|
541
|
-
headers:
|
|
542
|
+
headers: jsonHeaders(),
|
|
542
543
|
// Clip to 5,000 chars: the backend only reads the first 4,000 anyway, so sending
|
|
543
544
|
// the full article needlessly bloats the request on long pieces.
|
|
544
545
|
body: JSON.stringify({ keyword: term, content: text.slice(0, 5000), publication, previousSuggestions }),
|
|
@@ -574,7 +575,7 @@ function SuggestedKeywordsCard({
|
|
|
574
575
|
try {
|
|
575
576
|
const res = await fetch(`${apiUrl}/api/seo-copilot/keywords`, {
|
|
576
577
|
method: "POST",
|
|
577
|
-
headers:
|
|
578
|
+
headers: jsonHeaders(),
|
|
578
579
|
body: JSON.stringify({ keywords: [trimmed] }),
|
|
579
580
|
});
|
|
580
581
|
if (res.ok) {
|
|
@@ -670,7 +671,7 @@ function SuggestedKeywordsCard({
|
|
|
670
671
|
const existingTerms = allKeywords.map((kw) => kw.term);
|
|
671
672
|
const res = await fetch(`${apiUrl}/api/seo-copilot/more-keywords`, {
|
|
672
673
|
method: "POST",
|
|
673
|
-
headers:
|
|
674
|
+
headers: jsonHeaders(),
|
|
674
675
|
body: JSON.stringify({ content: text, existingKeywords: existingTerms, publication }),
|
|
675
676
|
});
|
|
676
677
|
if (res.ok) {
|
|
@@ -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>
|