sanity-plugin-seo-copilot 0.2.14 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +63 -50
  2. package/dist/index.js +868 -797
  3. package/dist/index.mjs +791 -720
  4. package/package.json +9 -8
  5. package/dist/index.js.map +0 -1
  6. package/dist/index.mjs.map +0 -1
  7. package/sanity.json +0 -3
  8. package/src/components/ChatPanel.tsx +0 -311
  9. package/src/components/ConfigContext.tsx +0 -22
  10. package/src/components/FeedbackButton.tsx +0 -218
  11. package/src/components/KeywordBadge.tsx +0 -50
  12. package/src/components/KeywordPanel.tsx +0 -1233
  13. package/src/components/OnboardingPopup.tsx +0 -108
  14. package/src/components/PlacementIndicators.tsx +0 -80
  15. package/src/components/ReportProblemButton.tsx +0 -212
  16. package/src/components/SEOCopilotPanel.tsx +0 -1287
  17. package/src/components/ScoreDonut.tsx +0 -158
  18. package/src/components/SeedKeywordInput.tsx +0 -128
  19. package/src/components/ShimmerLoader.tsx +0 -123
  20. package/src/components/TabBar.tsx +0 -373
  21. package/src/components/styles.ts +0 -158
  22. package/src/components/tabs/AEOTab.tsx +0 -585
  23. package/src/components/tabs/LinkingTab.tsx +0 -446
  24. package/src/components/tabs/MetaTab.tsx +0 -431
  25. package/src/components/tabs/SummaryTab.tsx +0 -405
  26. package/src/components/tabs/TechnicalTab.tsx +0 -933
  27. package/src/hooks/useDocumentContent.ts +0 -48
  28. package/src/hooks/useKeywordAnalysis.ts +0 -292
  29. package/src/hooks/useSEOChat.ts +0 -254
  30. package/src/index.ts +0 -16
  31. package/src/inspector.ts +0 -58
  32. package/src/lib/api.ts +0 -260
  33. package/src/lib/documentExtract.ts +0 -422
  34. package/src/lib/geoAnalysis.ts +0 -122
  35. package/src/lib/persistence.ts +0 -69
  36. package/src/lib/scoring.ts +0 -197
  37. package/src/lib/summary.ts +0 -645
  38. package/src/lib/types.ts +0 -212
  39. package/src/lib/utils.ts +0 -35
  40. package/v2-incompatible.js +0 -10
@@ -1,158 +0,0 @@
1
- // Hand-rolled SVG donut showing how topic / freshness / section-fit each contributed
2
- // to a Linking suggestion's composite score. Inline-styled - works inside Sanity Studio sandbox.
3
- // Hover the donut for the raw sub-scores (the surest way to read tiny segments).
4
-
5
- import { useState } from "react";
6
- import { MJH_BLUE, MJH_GOLD } from "./styles";
7
-
8
- interface ScoreDonutProps {
9
- size?: number;
10
- strokeWidth?: number;
11
- topic: number;
12
- freshness: number;
13
- sectionFit: number;
14
- /** Pre-computed composite (0-100). If omitted, computed from defaults 60/25/15. */
15
- composite?: number;
16
- }
17
-
18
- const W = { topic: 0.6, freshness: 0.25, sectionFit: 0.15 } as const;
19
- // Colorblind-safe trio: blue + gold + purple. Green was dropped - blue+green fails
20
- // for deuteranopia (~5% of men). Purple is distinct from both blue and gold under
21
- // every common colorblindness simulation.
22
- const COLORS = { topic: MJH_BLUE, freshness: MJH_GOLD, sectionFit: "#9B59B6" };
23
- const TRACK = "#eef2f7";
24
-
25
- export function ScoreDonut({
26
- size = 64,
27
- strokeWidth = 9,
28
- topic,
29
- freshness,
30
- sectionFit,
31
- composite,
32
- }: ScoreDonutProps) {
33
- const [hovered, setHovered] = useState(false);
34
- const radius = (size - strokeWidth) / 2;
35
- const circumference = 2 * Math.PI * radius;
36
-
37
- // Weighted contributions (points the segment actually contributed to composite).
38
- const cTopic = topic * W.topic;
39
- const cFresh = freshness * W.freshness;
40
- const cSection = sectionFit * W.sectionFit;
41
- const compositeValue = composite != null ? composite : Math.round(cTopic + cFresh + cSection);
42
-
43
- // Each segment renders as a fraction of the full ring (weighted maxes sum to 100,
44
- // so a perfect 100 fills the donut).
45
- const seg = (contribution: number) => (contribution / 100) * circumference;
46
- // A small transparent gap between segments so adjacent colors don't bleed together.
47
- const GAP = Math.min(2.5, circumference * 0.02);
48
- const drawn = (fullLen: number) => (fullLen > 0 ? Math.max(0.75, fullLen - GAP) : 0);
49
-
50
- const topicLen = seg(cTopic);
51
- const freshLen = seg(cFresh);
52
- const sectionLen = seg(cSection);
53
-
54
- const Slice = ({ color, fullLen, offset }: { color: string; fullLen: number; offset: number }) => (
55
- <circle
56
- cx={size / 2}
57
- cy={size / 2}
58
- r={radius}
59
- fill="none"
60
- stroke={color}
61
- strokeWidth={strokeWidth}
62
- strokeLinecap="butt"
63
- strokeDasharray={`${drawn(fullLen)} ${circumference}`}
64
- strokeDashoffset={-offset}
65
- />
66
- );
67
-
68
- return (
69
- <div
70
- style={{ position: "relative", width: size, height: size, flexShrink: 0 }}
71
- onMouseEnter={() => setHovered(true)}
72
- onMouseLeave={() => setHovered(false)}
73
- >
74
- <svg width={size} height={size} viewBox={`0 0 ${size} ${size}`} style={{ transform: "rotate(-90deg)" }}>
75
- <circle cx={size / 2} cy={size / 2} r={radius} fill="none" stroke={TRACK} strokeWidth={strokeWidth} />
76
- <Slice color={COLORS.topic} fullLen={topicLen} offset={0} />
77
- <Slice color={COLORS.freshness} fullLen={freshLen} offset={topicLen} />
78
- <Slice color={COLORS.sectionFit} fullLen={sectionLen} offset={topicLen + freshLen} />
79
- </svg>
80
- <div
81
- style={{
82
- position: "absolute",
83
- inset: 0,
84
- display: "flex",
85
- flexDirection: "column",
86
- alignItems: "center",
87
- justifyContent: "center",
88
- fontVariantNumeric: "tabular-nums",
89
- lineHeight: 1,
90
- }}
91
- >
92
- <span style={{ fontSize: Math.max(11, size / 5.5), fontWeight: 700, color: "#1f2937" }}>
93
- {compositeValue}%
94
- </span>
95
- <span style={{ fontSize: Math.max(7, size / 11), fontWeight: 700, color: "#4b5563", letterSpacing: "0.05em", marginTop: 1 }}>
96
- MATCH
97
- </span>
98
- </div>
99
-
100
- {hovered && (
101
- <div
102
- role="tooltip"
103
- style={{
104
- position: "absolute",
105
- left: "50%",
106
- top: -6,
107
- transform: "translate(-50%, -100%)",
108
- background: "#1f2937",
109
- color: "#ffffff",
110
- borderRadius: 8,
111
- padding: "7px 9px",
112
- fontSize: 10.5,
113
- lineHeight: 1.5,
114
- whiteSpace: "nowrap",
115
- boxShadow: "0 4px 14px rgba(0,0,0,0.25)",
116
- zIndex: 20,
117
- pointerEvents: "none",
118
- }}
119
- >
120
- <SubScoreRow color={COLORS.topic} label="Topic" value={topic} />
121
- <SubScoreRow color={COLORS.freshness} label="Freshness" value={freshness} />
122
- <SubScoreRow color={COLORS.sectionFit} label="Section fit" value={sectionFit} />
123
- </div>
124
- )}
125
- </div>
126
- );
127
- }
128
-
129
- function SubScoreRow({ color, label, value }: { color: string; label: string; value: number }) {
130
- return (
131
- <div style={{ display: "flex", alignItems: "center", gap: 6 }}>
132
- <span style={{ width: 7, height: 7, borderRadius: "50%", background: color, display: "inline-block", flexShrink: 0 }} />
133
- <span style={{ flex: 1 }}>{label}</span>
134
- <span style={{ fontWeight: 700, fontVariantNumeric: "tabular-nums" }}>{Math.round(value)}/100</span>
135
- </div>
136
- );
137
- }
138
-
139
- export function ScoreDonutLegend() {
140
- // The percentages here are the WEIGHTS each signal contributes to the composite,
141
- // not the article's score on that signal. Phrased so editors don't misread it.
142
- return (
143
- <div style={{ display: "flex", gap: 10, fontSize: 9, color: "rgba(0,0,0,0.55)", alignItems: "center", flexWrap: "wrap" }}>
144
- <LegendDot color={COLORS.topic} label="Topic match (60% of score)" />
145
- <LegendDot color={COLORS.freshness} label="Freshness (25%)" />
146
- <LegendDot color={COLORS.sectionFit} label="Section fit (15%)" />
147
- </div>
148
- );
149
- }
150
-
151
- function LegendDot({ color, label }: { color: string; label: string }) {
152
- return (
153
- <span style={{ display: "inline-flex", alignItems: "center", gap: 4 }}>
154
- <span style={{ width: 7, height: 7, borderRadius: "50%", background: color, display: "inline-block" }} />
155
- {label}
156
- </span>
157
- );
158
- }
@@ -1,128 +0,0 @@
1
- import { useState, useRef } from "react";
2
- import { MJH_GOLD } from "./styles";
3
-
4
- interface SeedKeywordInputProps {
5
- seeds: string[];
6
- onSeedsChange: (seeds: string[]) => void;
7
- }
8
-
9
- function parseSeedInput(input: string): string[] {
10
- return input
11
- .split(/[,\n]+/)
12
- .map((s) => s.trim())
13
- .filter((s) => s.length > 0);
14
- }
15
-
16
- export function SeedKeywordInput({ seeds, onSeedsChange }: SeedKeywordInputProps) {
17
- const [inputValue, setInputValue] = useState("");
18
- const inputRef = useRef<HTMLTextAreaElement>(null);
19
-
20
- const handleAdd = () => {
21
- const parsed = parseSeedInput(inputValue);
22
- if (parsed.length > 0) {
23
- const combined = [...new Set([...seeds, ...parsed])];
24
- onSeedsChange(combined);
25
- setInputValue("");
26
- }
27
- };
28
-
29
- const handleRemove = (term: string) => {
30
- onSeedsChange(seeds.filter((s) => s !== term));
31
- };
32
-
33
- const handleKeyDown = (e: React.KeyboardEvent) => {
34
- if (e.key === "Enter" && !e.shiftKey) {
35
- e.preventDefault();
36
- handleAdd();
37
- }
38
- };
39
-
40
- return (
41
- <div style={{
42
- borderRadius: 14,
43
- background: "rgba(255,255,255,0.55)",
44
- backdropFilter: "blur(16px) saturate(170%)",
45
- WebkitBackdropFilter: "blur(16px) saturate(170%)",
46
- boxShadow: "inset 0 0 0 1px rgba(255,255,255,0.85), inset 1.5px 2px 1px -1px rgba(255,255,255,1), inset -2px -3px 2px -1px rgba(255,255,255,0.6), 0 2px 6px rgba(0,0,0,0.07), 0 10px 26px rgba(0,0,0,0.08)",
47
- padding: "12px 14px",
48
- }}>
49
- <span style={{ fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600 }}>
50
- Desired Keywords
51
- </span>
52
-
53
- {/* Seed tags */}
54
- {seeds.length > 0 && (
55
- <div style={{ display: "flex", flexWrap: "wrap", gap: 5, marginTop: 8 }}>
56
- {seeds.map((seed) => (
57
- <span key={seed} style={{
58
- display: "inline-flex",
59
- alignItems: "center",
60
- gap: 5,
61
- padding: "3px 10px",
62
- borderRadius: 99,
63
- fontSize: 11.5,
64
- fontWeight: 500,
65
- background: `rgba(230,192,27,0.12)`,
66
- color: "#92810F",
67
- transition: "all 150ms",
68
- }}>
69
- {seed}
70
- <button
71
- onClick={() => handleRemove(seed)}
72
- aria-label={`Remove ${seed}`}
73
- style={{ background: "none", border: "none", cursor: "pointer", padding: 0, fontSize: 14, color: "#8B7310", lineHeight: 1 }}
74
- >
75
- ×
76
- </button>
77
- </span>
78
- ))}
79
- </div>
80
- )}
81
-
82
- {/* Input area - always visible */}
83
- <div style={{ marginTop: 8 }}>
84
- <textarea
85
- ref={inputRef}
86
- value={inputValue}
87
- onChange={(e) => setInputValue(e.target.value)}
88
- onKeyDown={handleKeyDown}
89
- placeholder="Enter 2-3 word phrases for best results"
90
- rows={2}
91
- style={{
92
- width: "100%",
93
- padding: "8px 10px",
94
- fontSize: 12.5,
95
- borderRadius: 10,
96
- border: "1px solid #e2e8f0",
97
- background: "#fafbfc",
98
- resize: "vertical",
99
- outline: "none",
100
- fontFamily: "inherit",
101
- boxSizing: "border-box",
102
- }}
103
- />
104
- <button
105
- onClick={handleAdd}
106
- disabled={!inputValue.trim()}
107
- style={{
108
- marginTop: 4,
109
- padding: "4px 12px",
110
- fontSize: 11,
111
- fontWeight: 600,
112
- borderRadius: 6,
113
- border: "none",
114
- background: inputValue.trim() ? MJH_GOLD : "#e5e7eb",
115
- color: inputValue.trim() ? "#ffffff" : "#9ca3af",
116
- cursor: inputValue.trim() ? "pointer" : "not-allowed",
117
- transition: "all 150ms",
118
- }}
119
- >
120
- Add
121
- </button>
122
- <div style={{ marginTop: 4, fontSize: 10, color: "#4b5563" }}>
123
- Two- and three-word phrases give sharper results than single words.
124
- </div>
125
- </div>
126
- </div>
127
- );
128
- }
@@ -1,123 +0,0 @@
1
- // ShimmerLoader - pulsating MJH-bar loader + rotating shimmer text.
2
- // The three bars echo the MJH logo (shifting heights) and animate via the
3
- // bar-shift keyframes injected globally by SEOCopilotPanel's INJECTED_CSS.
4
- // The text uses a scoped shimmer keyframe injected once on first mount.
5
-
6
- import { useEffect, useState } from "react";
7
- import { MJH_GOLD } from "./styles";
8
-
9
- let keyframesInjected = false;
10
-
11
- const KEYFRAMES = `
12
- @keyframes seo-copilot-text-shimmer {
13
- 0% { background-position: -100% center; }
14
- 100% { background-position: 100% center; }
15
- }
16
- `;
17
-
18
- interface LoaderBarsProps {
19
- color?: string;
20
- }
21
-
22
- // Three gold bars that shift height - the MJH "pulsating bars" loader.
23
- function LoaderBars({ color = MJH_GOLD }: LoaderBarsProps) {
24
- return (
25
- <div
26
- role="status"
27
- aria-label="Loading"
28
- style={{ display: "inline-flex", alignItems: "flex-end", gap: 2, height: 14, flexShrink: 0 }}
29
- >
30
- {[1, 2, 3].map((i) => (
31
- <div
32
- key={i}
33
- style={{
34
- width: 6,
35
- height: 8,
36
- borderRadius: 2,
37
- background: color,
38
- animation: `bar-shift-${i} 1.4s ease-in-out infinite`,
39
- }}
40
- />
41
- ))}
42
- </div>
43
- );
44
- }
45
-
46
- interface ShimmerLoaderProps {
47
- messages: string[];
48
- intervalMs?: number;
49
- textSize?: number;
50
- iconColor?: string;
51
- }
52
-
53
- export function ShimmerLoader({
54
- messages,
55
- intervalMs = 1500,
56
- textSize = 14,
57
- iconColor = MJH_GOLD,
58
- }: ShimmerLoaderProps) {
59
- const [idx, setIdx] = useState(0);
60
-
61
- useEffect(() => {
62
- if (typeof window !== "undefined" && !keyframesInjected) {
63
- keyframesInjected = true;
64
- const style = document.createElement("style");
65
- style.dataset.seoCopilotKeyframes = "1";
66
- style.innerHTML = KEYFRAMES;
67
- document.head.appendChild(style);
68
- // Intentionally NOT removed on unmount. The ~100-byte keyframe block is global
69
- // and harmless to leave in <head>. Removing it when the first loader unmounts
70
- // would yank the animation out from under any OTHER ShimmerLoader still mounted,
71
- // so we inject once per session and keep the flag latched true.
72
- }
73
- }, []);
74
-
75
- useEffect(() => {
76
- if (messages.length <= 1) return;
77
- const id = setInterval(() => {
78
- setIdx((i) => (i + 1) % messages.length);
79
- }, intervalMs);
80
- return () => clearInterval(id);
81
- }, [messages.length, intervalMs]);
82
-
83
- const text = messages[idx] || messages[0] || "";
84
-
85
- return (
86
- <div
87
- style={{
88
- display: "inline-flex",
89
- alignItems: "center",
90
- gap: 8,
91
- fontSize: textSize,
92
- fontWeight: 500,
93
- letterSpacing: "0.01em",
94
- }}
95
- >
96
- <LoaderBars color={iconColor} />
97
- <span
98
- style={{
99
- backgroundImage:
100
- "linear-gradient(90deg, rgb(113 113 122) 0%, rgb(113 113 122) 40%, rgb(24 24 27) 50%, rgb(113 113 122) 60%, rgb(113 113 122) 100%)",
101
- backgroundSize: "200% auto",
102
- backgroundClip: "text",
103
- WebkitBackgroundClip: "text",
104
- color: "transparent",
105
- animation: "seo-copilot-text-shimmer 2s ease-in-out infinite",
106
- }}
107
- >
108
- {text}
109
- </span>
110
- </div>
111
- );
112
- }
113
-
114
- export const DEFAULT_GENERATE_ALL_MESSAGES = [
115
- "Processing",
116
- "Gathering keyword data",
117
- "Running deep analysis",
118
- "Scanning for AEO opportunities",
119
- "Finding internal links",
120
- "Auditing meta and structure",
121
- "Cross-checking score components",
122
- "Compiling summary",
123
- ];