sanity-plugin-seo-copilot 0.1.2 → 0.2.0
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 +4729 -895
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4722 -888
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/ChatPanel.tsx +87 -69
- package/src/components/FeedbackButton.tsx +2 -2
- package/src/components/KeywordBadge.tsx +50 -50
- package/src/components/KeywordPanel.tsx +97 -226
- package/src/components/PlacementIndicators.tsx +80 -76
- package/src/components/SEOCopilotPanel.tsx +712 -165
- package/src/components/ScoreDonut.tsx +158 -0
- package/src/components/SeedKeywordInput.tsx +128 -125
- package/src/components/ShimmerLoader.tsx +119 -0
- package/src/components/TabBar.tsx +370 -0
- package/src/components/styles.ts +66 -0
- package/src/components/tabs/AEOTab.tsx +573 -0
- package/src/components/tabs/LinkingTab.tsx +343 -0
- package/src/components/tabs/MetaTab.tsx +417 -0
- package/src/components/tabs/SummaryTab.tsx +384 -0
- package/src/components/tabs/TechnicalTab.tsx +776 -0
- package/src/hooks/useDocumentContent.ts +216 -99
- package/src/hooks/useKeywordAnalysis.ts +28 -8
- package/src/hooks/useSEOChat.ts +38 -11
- package/src/lib/api.ts +109 -13
- package/src/lib/geoAnalysis.ts +109 -0
- package/src/lib/persistence.ts +69 -0
- package/src/lib/scoring.ts +147 -0
- package/src/lib/summary.ts +504 -0
- package/src/lib/types.ts +197 -108
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { useState, useEffect,
|
|
2
|
-
import { useKeywordAnalysis } from "../hooks/useKeywordAnalysis";
|
|
1
|
+
import { useState, useEffect, useRef, useCallback } from "react";
|
|
3
2
|
import { useConfig } from "./ConfigContext";
|
|
4
|
-
import { KeywordBadge } from "./KeywordBadge";
|
|
5
3
|
import { PlacementIndicators } from "./PlacementIndicators";
|
|
6
4
|
import { SeedKeywordInput } from "./SeedKeywordInput";
|
|
7
5
|
import { FeedbackButton } from "./FeedbackButton";
|
|
8
6
|
import { LoadingBars } from "./SEOCopilotPanel";
|
|
9
|
-
import { MJH_GOLD,
|
|
10
|
-
import
|
|
7
|
+
import { MJH_GOLD, MJH_BLUE } from "./styles";
|
|
8
|
+
import { usePersistentState, loadLocal } from "../lib/persistence";
|
|
9
|
+
import type { PrimaryKeywordCandidate, DocumentFields } from "../lib/types";
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
function loadLocalArray<T>(key: string): T[] {
|
|
12
|
+
return loadLocal<T[]>(key, []);
|
|
13
|
+
}
|
|
13
14
|
|
|
14
15
|
interface KeywordPanelProps {
|
|
15
16
|
text: string;
|
|
@@ -18,10 +19,13 @@ interface KeywordPanelProps {
|
|
|
18
19
|
onSeedsChange?: (seeds: string[]) => void;
|
|
19
20
|
onSelectPrimary?: (term: string) => void;
|
|
20
21
|
documentFields?: DocumentFields;
|
|
21
|
-
//
|
|
22
|
-
|
|
22
|
+
// Used as key for SuggestedKeywordsCard to remount on doc change (resets manualKeywords/extraKeywords/helpData)
|
|
23
|
+
documentId?: string;
|
|
24
|
+
// Required: keyword analysis state lifted to parent (SEOCopilotInner) to avoid duplicate API calls
|
|
25
|
+
externalAnalysis: {
|
|
23
26
|
analysis: import("../lib/types").SEOAnalysis | null;
|
|
24
27
|
isLoading: boolean;
|
|
28
|
+
isVolumesLoading: boolean;
|
|
25
29
|
error: string | null;
|
|
26
30
|
deepAnalysis: import("../lib/types").DeepAnalysis | null;
|
|
27
31
|
isDeepLoading: boolean;
|
|
@@ -43,7 +47,7 @@ function SectionHeader({ label, iconColor, actionButton }: { label: string; icon
|
|
|
43
47
|
return (
|
|
44
48
|
<div style={{ display: "flex", alignItems: "center", gap: 7, marginBottom: 10 }}>
|
|
45
49
|
<div style={{ width: 7, height: 7, borderRadius: "50%", background: iconColor, flexShrink: 0 }} />
|
|
46
|
-
<span style={{ fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#
|
|
50
|
+
<span style={{ fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600, flex: 1 }}>
|
|
47
51
|
{label}
|
|
48
52
|
</span>
|
|
49
53
|
{actionButton}
|
|
@@ -53,8 +57,10 @@ function SectionHeader({ label, iconColor, actionButton }: { label: string; icon
|
|
|
53
57
|
|
|
54
58
|
const cardStyle = {
|
|
55
59
|
borderRadius: 14,
|
|
56
|
-
background: "
|
|
57
|
-
|
|
60
|
+
background: "rgba(255,255,255,0.55)",
|
|
61
|
+
backdropFilter: "blur(16px) saturate(170%)",
|
|
62
|
+
WebkitBackdropFilter: "blur(16px) saturate(170%)",
|
|
63
|
+
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)",
|
|
58
64
|
padding: "14px",
|
|
59
65
|
};
|
|
60
66
|
|
|
@@ -62,7 +68,7 @@ function BulletItem({ text }: { text: string }) {
|
|
|
62
68
|
return (
|
|
63
69
|
<div style={{ display: "flex", gap: 8, alignItems: "flex-start", padding: "2px 0" }}>
|
|
64
70
|
<div style={{ width: 6, height: 6, borderRadius: "50%", marginTop: 6, background: MJH_GOLD, flexShrink: 0 }} />
|
|
65
|
-
<span style={{ fontSize: 12, color: "#
|
|
71
|
+
<span style={{ fontSize: 12, color: "#1f2937", lineHeight: 1.6 }}>{text}</span>
|
|
66
72
|
</div>
|
|
67
73
|
);
|
|
68
74
|
}
|
|
@@ -132,19 +138,22 @@ function LightbulbButton({ onClick, isLoading }: { onClick: () => void; isLoadin
|
|
|
132
138
|
style={{
|
|
133
139
|
position: "relative",
|
|
134
140
|
cursor: isLoading ? "wait" : "pointer",
|
|
135
|
-
fontSize: 14,
|
|
136
141
|
lineHeight: 1,
|
|
137
142
|
opacity: isLoading ? 0.5 : 1,
|
|
138
143
|
flexShrink: 0,
|
|
139
144
|
display: "inline-flex",
|
|
140
145
|
alignItems: "center",
|
|
146
|
+
color: hovered ? MJH_GOLD : "#9ca3af",
|
|
147
|
+
transition: "color 150ms",
|
|
141
148
|
}}
|
|
142
|
-
title="
|
|
149
|
+
title="Show how to use this keyword"
|
|
143
150
|
>
|
|
144
151
|
{isLoading ? (
|
|
145
152
|
<LoadingBars size="xs" color={MJH_GOLD} />
|
|
146
153
|
) : (
|
|
147
|
-
"
|
|
154
|
+
<svg width="13" height="13" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
|
155
|
+
<path fillRule="evenodd" d="M10 1a6 6 0 00-3.815 10.631C7.001 12.097 7.5 12.93 7.5 13.875V15a2.5 2.5 0 002.5 2.5h0a2.5 2.5 0 002.5-2.5v-1.125c0-.945.498-1.778 1.315-2.244A6 6 0 0010 1zM8.025 13H9.5v-2.077a.75.75 0 011.5 0V13h1.475A4.5 4.5 0 0011.5 9.86V5.75a.75.75 0 00-1.5 0v4.11a4.5 4.5 0 00-1.975 3.14z" clipRule="evenodd" />
|
|
156
|
+
</svg>
|
|
148
157
|
)}
|
|
149
158
|
{hovered && !isLoading && (
|
|
150
159
|
<span style={{
|
|
@@ -162,7 +171,7 @@ function LightbulbButton({ onClick, isLoading }: { onClick: () => void; isLoadin
|
|
|
162
171
|
pointerEvents: "none",
|
|
163
172
|
zIndex: 10,
|
|
164
173
|
}}>
|
|
165
|
-
|
|
174
|
+
Suggest a fix
|
|
166
175
|
</span>
|
|
167
176
|
)}
|
|
168
177
|
</span>
|
|
@@ -202,14 +211,14 @@ function KeywordHelpDisplay({ suggestions, onRegenerate, isRegenerating, term, p
|
|
|
202
211
|
<div style={{ flex: 1 }}>
|
|
203
212
|
{s.type === "change" ? (
|
|
204
213
|
<>
|
|
205
|
-
<div style={{ color: "#
|
|
214
|
+
<div style={{ color: "#4b5563", fontWeight: 600, fontSize: 10, textTransform: "uppercase", marginBottom: 2 }}>Change</div>
|
|
206
215
|
<div style={{ color: "#991b1b", textDecoration: "line-through", marginBottom: 2 }}>{s.original}</div>
|
|
207
216
|
<div style={{ color: "#166534" }}><HighlightKeyword text={s.revised || ""} keyword={term} /></div>
|
|
208
217
|
</>
|
|
209
218
|
) : (
|
|
210
219
|
<>
|
|
211
|
-
<div style={{ color: "#
|
|
212
|
-
<div style={{ color: "#
|
|
220
|
+
<div style={{ color: "#4b5563", fontWeight: 600, fontSize: 10, textTransform: "uppercase", marginBottom: 2 }}>Add{s.where ? ` - ${s.where}` : ""}</div>
|
|
221
|
+
<div style={{ color: "#1f2937" }}><HighlightKeyword text={s.sentence || ""} keyword={term} /></div>
|
|
213
222
|
</>
|
|
214
223
|
)}
|
|
215
224
|
</div>
|
|
@@ -392,9 +401,9 @@ function PrimaryKeywordSelector({
|
|
|
392
401
|
{candidate.term}
|
|
393
402
|
</span>
|
|
394
403
|
{candidate.volume != null && (
|
|
395
|
-
<span style={{ fontSize: 11, color: "#
|
|
404
|
+
<span style={{ fontSize: 11, fontWeight: 600, color: "#1f2937" }}>{abbrevVol(candidate.volume)}/mo</span>
|
|
396
405
|
)}
|
|
397
|
-
<span style={{ fontSize: 10, color: "#
|
|
406
|
+
<span style={{ fontSize: 10, color: "#1f2937" }}>
|
|
398
407
|
{Math.round(candidate.confidence * 100)}% confidence
|
|
399
408
|
</span>
|
|
400
409
|
</div>
|
|
@@ -442,6 +451,7 @@ function SuggestedKeywordsCard({
|
|
|
442
451
|
documentFields,
|
|
443
452
|
refreshVolumes,
|
|
444
453
|
isVolumesLoading,
|
|
454
|
+
documentId,
|
|
445
455
|
}: {
|
|
446
456
|
keywords: SuggestedKeyword[];
|
|
447
457
|
text: string;
|
|
@@ -450,19 +460,50 @@ function SuggestedKeywordsCard({
|
|
|
450
460
|
documentFields?: DocumentFields;
|
|
451
461
|
refreshVolumes?: () => void;
|
|
452
462
|
isVolumesLoading?: boolean;
|
|
463
|
+
documentId?: string;
|
|
453
464
|
}) {
|
|
454
|
-
|
|
465
|
+
// Per-doc persistence: manual keywords, generated "more" keywords, and cached
|
|
466
|
+
// AI keyword help survive dock/undock and full page reload.
|
|
467
|
+
const docScope = documentId || "default";
|
|
468
|
+
const [helpData, setHelpData] = usePersistentState<Record<string, KeywordHelpSuggestion[]>>(
|
|
469
|
+
`seo-copilot-help-data-${docScope}`,
|
|
470
|
+
{}
|
|
471
|
+
);
|
|
455
472
|
const [loadingTerm, setLoadingTerm] = useState<string | null>(null);
|
|
456
473
|
const [regeneratingTerm, setRegeneratingTerm] = useState<string | null>(null);
|
|
457
474
|
const [manualInputOpen, setManualInputOpen] = useState(false);
|
|
458
475
|
const [manualInputValue, setManualInputValue] = useState("");
|
|
459
|
-
const [manualKeywords, setManualKeywords] =
|
|
460
|
-
|
|
461
|
-
|
|
476
|
+
const [manualKeywords, setManualKeywords] = usePersistentState<string[]>(
|
|
477
|
+
`seo-copilot-manual-keywords-${docScope}`,
|
|
478
|
+
[]
|
|
479
|
+
);
|
|
480
|
+
const [expanded, setExpanded] = usePersistentState<boolean>("seo-copilot-ui-keywords-expanded", false);
|
|
481
|
+
const [extraKeywords, setExtraKeywords] = usePersistentState<SuggestedKeyword[]>(
|
|
482
|
+
`seo-copilot-extra-keywords-${docScope}`,
|
|
483
|
+
[]
|
|
484
|
+
);
|
|
462
485
|
const [isGeneratingMore, setIsGeneratingMore] = useState(false);
|
|
463
|
-
const [sortAsc, setSortAsc] =
|
|
464
|
-
|
|
486
|
+
const [sortAsc, setSortAsc] = usePersistentState<boolean>("seo-copilot-ui-keywords-sort-asc", false);
|
|
487
|
+
// Active filters - persist as array since JSON.stringify can't round-trip a Set.
|
|
488
|
+
const filtersKey = `seo-copilot-ui-keywords-filters-${docScope}`;
|
|
489
|
+
const [activeFilters, setActiveFiltersRaw] = useState<Set<PlacementKey>>(
|
|
490
|
+
() => new Set(loadLocalArray<PlacementKey>(filtersKey))
|
|
491
|
+
);
|
|
465
492
|
const [showFilterDropdown, setShowFilterDropdown] = useState(false);
|
|
493
|
+
const setActiveFilters = useCallback(
|
|
494
|
+
(updater: Set<PlacementKey> | ((prev: Set<PlacementKey>) => Set<PlacementKey>)) => {
|
|
495
|
+
setActiveFiltersRaw((prev) => {
|
|
496
|
+
const next = typeof updater === "function" ? updater(prev) : updater;
|
|
497
|
+
try {
|
|
498
|
+
localStorage.setItem(filtersKey, JSON.stringify(Array.from(next)));
|
|
499
|
+
} catch {
|
|
500
|
+
/* silent */
|
|
501
|
+
}
|
|
502
|
+
return next;
|
|
503
|
+
});
|
|
504
|
+
},
|
|
505
|
+
[filtersKey]
|
|
506
|
+
);
|
|
466
507
|
|
|
467
508
|
const fetchHelp = async (term: string, forceRegenerate = false) => {
|
|
468
509
|
if (helpData[term] && !forceRegenerate) {
|
|
@@ -614,7 +655,7 @@ function SuggestedKeywordsCard({
|
|
|
614
655
|
{/* Header row with count, sort, filter, pencil */}
|
|
615
656
|
<div style={{ display: "flex", alignItems: "center", gap: 6, marginBottom: 8 }}>
|
|
616
657
|
<div style={{ width: 6, height: 6, borderRadius: "50%", background: MJH_BLUE, flexShrink: 0 }} />
|
|
617
|
-
<span style={{ fontSize: 10, textTransform: "uppercase", letterSpacing: "0.05em", color: "#
|
|
658
|
+
<span style={{ fontSize: 10, textTransform: "uppercase", letterSpacing: "0.05em", color: "#4b5563", fontWeight: 600, flex: 1 }}>
|
|
618
659
|
Supporting Keywords
|
|
619
660
|
</span>
|
|
620
661
|
{/* Refresh volumes */}
|
|
@@ -637,7 +678,7 @@ function SuggestedKeywordsCard({
|
|
|
637
678
|
{/* Sort toggle */}
|
|
638
679
|
<button
|
|
639
680
|
onClick={() => setSortAsc(!sortAsc)}
|
|
640
|
-
style={{ background: "none", border: "none", cursor: "pointer", padding: 2, display: "flex", color: "#
|
|
681
|
+
style={{ background: "none", border: "none", cursor: "pointer", padding: 2, display: "flex", color: "#1f2937", fontSize: 10 }}
|
|
641
682
|
title={sortAsc ? "Sort: least placements first" : "Sort: most placements first"}
|
|
642
683
|
>
|
|
643
684
|
<svg width="12" height="12" viewBox="0 0 20 20" fill="currentColor" style={{ transform: sortAsc ? "rotate(180deg)" : "none", transition: "transform 150ms" }}>
|
|
@@ -673,7 +714,7 @@ function SuggestedKeywordsCard({
|
|
|
673
714
|
style={{
|
|
674
715
|
width: "100%", display: "flex", alignItems: "center", gap: 8,
|
|
675
716
|
padding: "5px 10px", background: "none", border: "none", cursor: "pointer",
|
|
676
|
-
fontSize: 11, color: "#
|
|
717
|
+
fontSize: 11, color: "#1f2937", textAlign: "left",
|
|
677
718
|
}}
|
|
678
719
|
>
|
|
679
720
|
<div style={{
|
|
@@ -685,7 +726,7 @@ function SuggestedKeywordsCard({
|
|
|
685
726
|
<svg width="8" height="8" viewBox="0 0 12 12" fill="white"><path d="M10 3L4.5 8.5 2 6" stroke="white" strokeWidth="2" fill="none" strokeLinecap="round" strokeLinejoin="round" /></svg>
|
|
686
727
|
)}
|
|
687
728
|
</div>
|
|
688
|
-
<span style={{ fontWeight: 600, color: "#
|
|
729
|
+
<span style={{ fontWeight: 600, color: "#1f2937", width: 14 }}>{letter}</span>
|
|
689
730
|
<span>{label}</span>
|
|
690
731
|
</button>
|
|
691
732
|
))}
|
|
@@ -695,7 +736,7 @@ function SuggestedKeywordsCard({
|
|
|
695
736
|
style={{
|
|
696
737
|
width: "100%", display: "flex", alignItems: "center", gap: 8,
|
|
697
738
|
padding: "5px 10px", background: "none", border: "none", cursor: "pointer",
|
|
698
|
-
fontSize: 11, color: "#
|
|
739
|
+
fontSize: 11, color: "#1f2937", textAlign: "left",
|
|
699
740
|
borderTop: "1px solid #f1f5f9",
|
|
700
741
|
}}
|
|
701
742
|
>
|
|
@@ -708,7 +749,7 @@ function SuggestedKeywordsCard({
|
|
|
708
749
|
<svg width="8" height="8" viewBox="0 0 12 12" fill="white"><path d="M10 3L4.5 8.5 2 6" stroke="white" strokeWidth="2" fill="none" strokeLinecap="round" strokeLinejoin="round" /></svg>
|
|
709
750
|
)}
|
|
710
751
|
</div>
|
|
711
|
-
<span style={{ fontWeight: 600, color: "#
|
|
752
|
+
<span style={{ fontWeight: 600, color: "#1f2937", width: 14 }}>-</span>
|
|
712
753
|
<span>None (missing all)</span>
|
|
713
754
|
</button>
|
|
714
755
|
{activeFilters.size > 0 && (
|
|
@@ -770,15 +811,17 @@ function SuggestedKeywordsCard({
|
|
|
770
811
|
width: 8, height: 8, borderRadius: "50%", flexShrink: 0,
|
|
771
812
|
background: kw.inContent ? "#16a34a" : "#d1d5db",
|
|
772
813
|
}} />
|
|
773
|
-
{/* Term
|
|
774
|
-
|
|
814
|
+
{/* Term - always readable dark gray; the status dot on the left
|
|
815
|
+
carries the "this keyword is in your article" signal so the term
|
|
816
|
+
text doesn't have to fade out. */}
|
|
817
|
+
<span style={{ fontSize: 12, fontWeight: kw.inContent ? 500 : 600, flexGrow: 1, color: "#1f2937" }}>
|
|
775
818
|
{kw.term}
|
|
776
819
|
</span>
|
|
777
820
|
{/* Loading indicator for enriching manual keywords */}
|
|
778
|
-
{enrichingTerms.has(kw.term) && <LoadingBars size="xs" color="#
|
|
779
|
-
{/* Abbreviated volume */}
|
|
821
|
+
{enrichingTerms.has(kw.term) && <LoadingBars size="xs" color="#6b7280" />}
|
|
822
|
+
{/* Abbreviated monthly search volume - readable, not whisper-gray. */}
|
|
780
823
|
{!enrichingTerms.has(kw.term) && kw.volume != null && (
|
|
781
|
-
<span style={{ fontSize: 10, color: "#
|
|
824
|
+
<span style={{ fontSize: 10.5, fontWeight: 600, color: "#1f2937", flexShrink: 0 }} title="Monthly searches">{abbrevVol(kw.volume)}/mo</span>
|
|
782
825
|
)}
|
|
783
826
|
{/* Placement indicators */}
|
|
784
827
|
{kw.placement && <PlacementIndicators placement={kw.placement} />}
|
|
@@ -808,7 +851,7 @@ function SuggestedKeywordsCard({
|
|
|
808
851
|
onClick={() => setExpanded(true)}
|
|
809
852
|
style={{
|
|
810
853
|
marginTop: 6, width: "100%", padding: "4px 0", background: "none", border: "none",
|
|
811
|
-
cursor: "pointer", fontSize: 10, color: "#
|
|
854
|
+
cursor: "pointer", fontSize: 10, color: "#1f2937", display: "flex", alignItems: "center",
|
|
812
855
|
justifyContent: "center", gap: 4,
|
|
813
856
|
}}
|
|
814
857
|
>
|
|
@@ -856,22 +899,20 @@ export function KeywordPanel({
|
|
|
856
899
|
onSeedsChange,
|
|
857
900
|
onSelectPrimary,
|
|
858
901
|
documentFields,
|
|
902
|
+
documentId,
|
|
859
903
|
externalAnalysis,
|
|
860
904
|
}: KeywordPanelProps) {
|
|
861
905
|
const { apiUrl } = useConfig();
|
|
862
|
-
const
|
|
863
|
-
const
|
|
864
|
-
const
|
|
865
|
-
const isVolumesLoading = (activeAnalysis as { isVolumesLoading?: boolean }).isVolumesLoading ?? false;
|
|
866
|
-
const refreshVolumes = (activeAnalysis as { refreshVolumes?: () => void }).refreshVolumes;
|
|
867
|
-
const aeoContentChanged = activeAnalysis.aeoContentChanged ?? false;
|
|
906
|
+
const { analysis, isLoading, error, deepAnalysis, isDeepLoading, runDeepAnalysis } = externalAnalysis;
|
|
907
|
+
const isVolumesLoading = externalAnalysis.isVolumesLoading;
|
|
908
|
+
const refreshVolumes = externalAnalysis.refreshVolumes;
|
|
868
909
|
|
|
869
910
|
// Auto-trigger AEO when analysis first loads (no button click needed)
|
|
870
911
|
// Auto-trigger AEO - always run deep analysis once keywords are ready
|
|
871
912
|
const [aeoTriggered, setAeoTriggered] = useState(false);
|
|
872
913
|
useEffect(() => {
|
|
873
|
-
// Only check V2 fields for AEO content.
|
|
874
|
-
const hasV2Aeo = deepAnalysis?.aeo?.questionHeadings?.length
|
|
914
|
+
// Only check V2 fields for AEO content. (FAQ output removed 2026-05.)
|
|
915
|
+
const hasV2Aeo = deepAnalysis?.aeo?.questionHeadings?.length;
|
|
875
916
|
if (analysis && !hasV2Aeo && !isDeepLoading && !aeoTriggered) {
|
|
876
917
|
setAeoTriggered(true);
|
|
877
918
|
// Start immediately - no delay
|
|
@@ -884,27 +925,6 @@ export function KeywordPanel({
|
|
|
884
925
|
setAeoTriggered(false);
|
|
885
926
|
}, [text]);
|
|
886
927
|
|
|
887
|
-
// "More FAQ suggestions" state
|
|
888
|
-
const [moreFaqs, setMoreFaqs] = useState<{ question: string; answer: string }[]>([]);
|
|
889
|
-
const [isMoreFaqsLoading, setIsMoreFaqsLoading] = useState(false);
|
|
890
|
-
const loadMoreFaqs = useCallback(async () => {
|
|
891
|
-
const aeo = deepAnalysis?.aeo;
|
|
892
|
-
const existingQs = [...(aeo?.faqSuggestions ?? aeo?.faqItems ?? []).map((f: { question: string }) => f.question), ...moreFaqs.map(f => f.question)];
|
|
893
|
-
setIsMoreFaqsLoading(true);
|
|
894
|
-
try {
|
|
895
|
-
const res = await fetch(`${apiUrl}/api/seo-copilot/more-faqs`, {
|
|
896
|
-
method: "POST",
|
|
897
|
-
headers: { "Content-Type": "application/json" },
|
|
898
|
-
body: JSON.stringify({ content: text, existingQuestions: existingQs, publication }),
|
|
899
|
-
});
|
|
900
|
-
if (res.ok) {
|
|
901
|
-
const data = await res.json();
|
|
902
|
-
setMoreFaqs(prev => [...prev, ...(data.faqSuggestions || [])]);
|
|
903
|
-
}
|
|
904
|
-
} catch { /* silent */ }
|
|
905
|
-
setIsMoreFaqsLoading(false);
|
|
906
|
-
}, [deepAnalysis, moreFaqs, apiUrl, text, publication]);
|
|
907
|
-
|
|
908
928
|
// Selected primary keyword term (user can override)
|
|
909
929
|
const defaultSelectedTerm = analysis?.primaryKeyword?.term ?? "";
|
|
910
930
|
const [selectedPrimaryTerm, setSelectedPrimaryTerm] = useState(defaultSelectedTerm);
|
|
@@ -922,10 +942,10 @@ export function KeywordPanel({
|
|
|
922
942
|
if ((!text || text.trim().length < 20) && (!seedKeywords || seedKeywords.length === 0)) {
|
|
923
943
|
return (
|
|
924
944
|
<div style={{ padding: 24, textAlign: "center" }}>
|
|
925
|
-
<div style={{ fontSize: 14, color: "#
|
|
945
|
+
<div style={{ fontSize: 14, color: "#1f2937", fontWeight: 500 }}>
|
|
926
946
|
Start writing to see keyword suggestions
|
|
927
947
|
</div>
|
|
928
|
-
<div style={{ fontSize: 12, color: "#
|
|
948
|
+
<div style={{ fontSize: 12, color: "#4b5563", marginTop: 4 }}>
|
|
929
949
|
Need at least a few sentences
|
|
930
950
|
</div>
|
|
931
951
|
</div>
|
|
@@ -936,7 +956,7 @@ export function KeywordPanel({
|
|
|
936
956
|
return (
|
|
937
957
|
<div style={{ padding: 24, display: "flex", alignItems: "center", justifyContent: "center", gap: 8 }}>
|
|
938
958
|
<LoadingBars />
|
|
939
|
-
<span style={{ fontSize: 12, color: "#
|
|
959
|
+
<span style={{ fontSize: 12, color: "#4b5563" }}>Analyzing content...</span>
|
|
940
960
|
</div>
|
|
941
961
|
);
|
|
942
962
|
}
|
|
@@ -974,7 +994,7 @@ export function KeywordPanel({
|
|
|
974
994
|
|
|
975
995
|
return (
|
|
976
996
|
<div style={{ padding: 12, display: "flex", flexDirection: "column", gap: 12 }}>
|
|
977
|
-
{/*
|
|
997
|
+
{/* Desired Keywords */}
|
|
978
998
|
{onSeedsChange && (
|
|
979
999
|
<SeedKeywordInput seeds={seedKeywords} onSeedsChange={onSeedsChange} />
|
|
980
1000
|
)}
|
|
@@ -990,6 +1010,7 @@ export function KeywordPanel({
|
|
|
990
1010
|
{/* Supporting Keywords */}
|
|
991
1011
|
{suggestedKeywords.length > 0 && (
|
|
992
1012
|
<SuggestedKeywordsCard
|
|
1013
|
+
key={documentId || "default"}
|
|
993
1014
|
keywords={suggestedKeywords}
|
|
994
1015
|
text={text}
|
|
995
1016
|
apiUrl={apiUrl}
|
|
@@ -997,167 +1018,17 @@ export function KeywordPanel({
|
|
|
997
1018
|
documentFields={documentFields}
|
|
998
1019
|
refreshVolumes={refreshVolumes}
|
|
999
1020
|
isVolumesLoading={isVolumesLoading}
|
|
1021
|
+
documentId={documentId}
|
|
1000
1022
|
/>
|
|
1001
1023
|
)}
|
|
1002
1024
|
|
|
1003
|
-
{/* AEO
|
|
1004
|
-
{!deepAnalysis && isDeepLoading ? (
|
|
1005
|
-
<div style={{ display: "flex", alignItems: "center", justifyContent: "center", gap: 8, padding: "12px 0" }}>
|
|
1006
|
-
<LoadingBars size="xs" color={AEO_PURPLE} />
|
|
1007
|
-
<span style={{ fontSize: 12, color: "#9ca3af" }}>Generating AEO insights...</span>
|
|
1008
|
-
</div>
|
|
1009
|
-
) : deepAnalysis ? (
|
|
1010
|
-
<div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
|
|
1011
|
-
|
|
1012
|
-
{/* AI Disclaimer */}
|
|
1013
|
-
<div style={{ padding: "6px 10px", background: "#fefce8", borderRadius: 8, border: "1px solid #fde68a" }}>
|
|
1014
|
-
<div style={{ fontSize: 10, color: "#92400e", lineHeight: 1.5 }}>
|
|
1015
|
-
Answers generated by AI may contain inaccuracies. Always verify facts, drug information, and clinical details before publishing.
|
|
1016
|
-
</div>
|
|
1017
|
-
</div>
|
|
1018
|
-
|
|
1019
|
-
{/* Intro - explains both AEO approaches */}
|
|
1020
|
-
{/* AEO Section Header */}
|
|
1021
|
-
<div style={{ ...cardStyle, padding: "8px 14px", background: "rgba(124,58,237,0.03)", borderLeft: "3px solid " + AEO_PURPLE }}>
|
|
1022
|
-
<div style={{ display: "flex", alignItems: "center", gap: 7 }}>
|
|
1023
|
-
<div style={{ width: 7, height: 7, borderRadius: "50%", background: AEO_PURPLE, flexShrink: 0 }} />
|
|
1024
|
-
<span style={{ fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#94a3b8", fontWeight: 600 }}>AEO Insights</span>
|
|
1025
|
-
</div>
|
|
1026
|
-
</div>
|
|
1027
|
-
|
|
1028
|
-
{!deepAnalysis.aeo && (
|
|
1029
|
-
<div style={{ ...cardStyle, textAlign: "center" }}>
|
|
1030
|
-
<span style={{ fontSize: 12, color: "#9ca3af" }}>No AEO data was returned. Try again - the analysis may have timed out.</span>
|
|
1031
|
-
</div>
|
|
1032
|
-
)}
|
|
1033
|
-
|
|
1034
|
-
{/* Section 1: Question Headline Recommendations */}
|
|
1035
|
-
{deepAnalysis.aeo && (deepAnalysis.aeo.questionHeadings ?? deepAnalysis.aeo.headingSuggestions ?? []).length > 0 && (
|
|
1036
|
-
<div style={cardStyle}>
|
|
1037
|
-
<SectionHeader label="Question Headline Recommendations" iconColor={AEO_PURPLE} />
|
|
1038
|
-
<div style={{ fontSize: 10, color: "#9ca3af", marginBottom: 8, marginTop: -4 }}>
|
|
1039
|
-
Rewrite your headings as questions. Google targets these for featured snippets.
|
|
1040
|
-
</div>
|
|
1041
|
-
<div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
|
|
1042
|
-
{(deepAnalysis.aeo.questionHeadings?.map((qh) => ({ heading: qh.suggestedHeading, originalHeading: qh.originalHeading, rationale: qh.rationale })) ?? deepAnalysis.aeo.headingSuggestions?.map((h) => ({ heading: h.heading, originalHeading: undefined as string | undefined, rationale: h.rationale })) ?? []).map((h, i) => (
|
|
1043
|
-
<div key={i} style={{ padding: "8px 10px", background: "rgba(124,58,237,0.03)", borderRadius: 10, borderLeft: "3px solid " + AEO_PURPLE }}>
|
|
1044
|
-
<div style={{ display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: 8 }}>
|
|
1045
|
-
<div style={{ flex: 1 }}>
|
|
1046
|
-
{h.originalHeading && (
|
|
1047
|
-
<div style={{ fontSize: 11, color: "#9ca3af", textDecoration: "line-through", marginBottom: 2 }}>
|
|
1048
|
-
{h.originalHeading}
|
|
1049
|
-
</div>
|
|
1050
|
-
)}
|
|
1051
|
-
<div style={{ fontSize: 12, fontWeight: 700, color: AEO_PURPLE, lineHeight: 1.5 }}>
|
|
1052
|
-
{h.heading}
|
|
1053
|
-
</div>
|
|
1054
|
-
</div>
|
|
1055
|
-
<FeedbackButton
|
|
1056
|
-
suggestionType="aeo_heading"
|
|
1057
|
-
suggestionText={h.heading}
|
|
1058
|
-
publication={publication}
|
|
1059
|
-
/>
|
|
1060
|
-
</div>
|
|
1061
|
-
<div style={{ fontSize: 10, color: "#9ca3af", marginTop: 4, fontStyle: "italic" }}>
|
|
1062
|
-
{h.rationale}
|
|
1063
|
-
</div>
|
|
1064
|
-
</div>
|
|
1065
|
-
))}
|
|
1066
|
-
</div>
|
|
1067
|
-
</div>
|
|
1068
|
-
)}
|
|
1069
|
-
|
|
1070
|
-
{/* Section 2: FAQ Suggestions */}
|
|
1071
|
-
{(() => {
|
|
1072
|
-
const faqs = deepAnalysis.aeo ? [...(deepAnalysis.aeo.faqSuggestions ?? deepAnalysis.aeo.faqItems ?? []), ...moreFaqs] : [];
|
|
1073
|
-
return faqs.length > 0 ? (
|
|
1074
|
-
<div style={cardStyle}>
|
|
1075
|
-
<SectionHeader label="FAQ Suggestions" iconColor={AEO_PURPLE} />
|
|
1076
|
-
<div style={{ fontSize: 10, color: "#9ca3af", marginBottom: 8, marginTop: -4 }}>
|
|
1077
|
-
Add these Q&As at the bottom of your article. Answers are derived from your article content. Can be wrapped with FAQ schema markup.
|
|
1078
|
-
</div>
|
|
1079
|
-
<div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
|
|
1080
|
-
{faqs.map((faq, i) => (
|
|
1081
|
-
<div key={i} style={{ padding: "8px 10px", background: "rgba(124,58,237,0.03)", borderRadius: 10, borderLeft: "3px solid " + AEO_PURPLE }}>
|
|
1082
|
-
<div style={{ display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: 8 }}>
|
|
1083
|
-
<span style={{ fontSize: 12, fontWeight: 700, color: "#1f2937", lineHeight: 1.5 }}>
|
|
1084
|
-
Q: {faq.question}
|
|
1085
|
-
</span>
|
|
1086
|
-
<FeedbackButton
|
|
1087
|
-
suggestionType="aeo_faq"
|
|
1088
|
-
suggestionText={faq.question}
|
|
1089
|
-
publication={publication}
|
|
1090
|
-
/>
|
|
1091
|
-
</div>
|
|
1092
|
-
<div style={{ fontSize: 12, color: "#374151", lineHeight: 1.6, marginTop: 4 }}>
|
|
1093
|
-
<span style={{ fontWeight: 600, color: "#6b7280" }}>A: </span>{faq.answer}
|
|
1094
|
-
</div>
|
|
1095
|
-
</div>
|
|
1096
|
-
))}
|
|
1097
|
-
</div>
|
|
1098
|
-
{/* More FAQ suggestions button */}
|
|
1099
|
-
<button
|
|
1100
|
-
onClick={loadMoreFaqs}
|
|
1101
|
-
disabled={isMoreFaqsLoading}
|
|
1102
|
-
style={{
|
|
1103
|
-
marginTop: 8,
|
|
1104
|
-
width: "100%",
|
|
1105
|
-
padding: "6px 12px",
|
|
1106
|
-
fontSize: 11,
|
|
1107
|
-
fontWeight: 600,
|
|
1108
|
-
color: isMoreFaqsLoading ? "#9ca3af" : AEO_PURPLE,
|
|
1109
|
-
background: isMoreFaqsLoading ? "#f3f4f6" : "rgba(124,58,237,0.06)",
|
|
1110
|
-
border: "1px solid rgba(124,58,237,0.15)",
|
|
1111
|
-
borderRadius: 6,
|
|
1112
|
-
cursor: isMoreFaqsLoading ? "wait" : "pointer",
|
|
1113
|
-
display: "flex",
|
|
1114
|
-
alignItems: "center",
|
|
1115
|
-
justifyContent: "center",
|
|
1116
|
-
gap: 6,
|
|
1117
|
-
transition: "all 150ms",
|
|
1118
|
-
}}
|
|
1119
|
-
>
|
|
1120
|
-
{isMoreFaqsLoading ? (
|
|
1121
|
-
<><LoadingBars size="xs" color={AEO_PURPLE} /> Generating...</>
|
|
1122
|
-
) : (
|
|
1123
|
-
"More FAQ suggestions"
|
|
1124
|
-
)}
|
|
1125
|
-
</button>
|
|
1126
|
-
</div>
|
|
1127
|
-
) : null;
|
|
1128
|
-
})()}
|
|
1129
|
-
|
|
1130
|
-
{/* Content changed notification */}
|
|
1131
|
-
{aeoContentChanged && (
|
|
1132
|
-
<div
|
|
1133
|
-
onClick={runDeepAnalysis}
|
|
1134
|
-
style={{
|
|
1135
|
-
padding: "8px 12px",
|
|
1136
|
-
background: "#fffbeb",
|
|
1137
|
-
border: "1px solid #fde68a",
|
|
1138
|
-
borderRadius: 8,
|
|
1139
|
-
display: "flex",
|
|
1140
|
-
alignItems: "center",
|
|
1141
|
-
justifyContent: "space-between",
|
|
1142
|
-
cursor: "pointer",
|
|
1143
|
-
}}
|
|
1144
|
-
>
|
|
1145
|
-
<span style={{ fontSize: 11, color: "#92400e" }}>
|
|
1146
|
-
Content has changed since this was generated.
|
|
1147
|
-
</span>
|
|
1148
|
-
<span style={{ fontSize: 11, fontWeight: 600, color: AEO_PURPLE, textDecoration: "underline" }}>
|
|
1149
|
-
Update
|
|
1150
|
-
</span>
|
|
1151
|
-
</div>
|
|
1152
|
-
)}
|
|
1153
|
-
</div>
|
|
1154
|
-
) : null}
|
|
1025
|
+
{/* AEO insights moved to dedicated AEO/GEO tab in V3 - this panel is keywords only */}
|
|
1155
1026
|
|
|
1156
1027
|
{/* Volumes loading indicator - shows while SEMrush data is being fetched */}
|
|
1157
1028
|
{isVolumesLoading && (
|
|
1158
1029
|
<div style={{ display: "flex", alignItems: "center", gap: 6, justifyContent: "center", padding: "4px 0" }}>
|
|
1159
1030
|
<LoadingBars size="xs" color={MJH_GOLD} />
|
|
1160
|
-
<span style={{ fontSize: 10, color: "#
|
|
1031
|
+
<span style={{ fontSize: 10, color: "#4b5563" }}>Checking search volumes...</span>
|
|
1161
1032
|
</div>
|
|
1162
1033
|
)}
|
|
1163
1034
|
|
|
@@ -1165,7 +1036,7 @@ export function KeywordPanel({
|
|
|
1165
1036
|
{isLoading && analysis && (
|
|
1166
1037
|
<div style={{ display: "flex", alignItems: "center", gap: 6, justifyContent: "center" }}>
|
|
1167
1038
|
<LoadingBars size="xs" color="#9ca3af" />
|
|
1168
|
-
<span style={{ fontSize: 10, color: "#
|
|
1039
|
+
<span style={{ fontSize: 10, color: "#4b5563" }}>Updating insights...</span>
|
|
1169
1040
|
</div>
|
|
1170
1041
|
)}
|
|
1171
1042
|
</div>
|