@actuate-media/cms-admin 0.19.0 → 0.20.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.
Files changed (94) hide show
  1. package/dist/AdminRoot.d.ts.map +1 -1
  2. package/dist/AdminRoot.js +9 -5
  3. package/dist/AdminRoot.js.map +1 -1
  4. package/dist/actuate-admin.css +1 -1
  5. package/dist/components/seo/Drawer.d.ts +11 -0
  6. package/dist/components/seo/Drawer.d.ts.map +1 -0
  7. package/dist/components/seo/Drawer.js +13 -0
  8. package/dist/components/seo/Drawer.js.map +1 -0
  9. package/dist/components/seo/RedirectEditorDrawer.d.ts +9 -0
  10. package/dist/components/seo/RedirectEditorDrawer.d.ts.map +1 -0
  11. package/dist/components/seo/RedirectEditorDrawer.js +94 -0
  12. package/dist/components/seo/RedirectEditorDrawer.js.map +1 -0
  13. package/dist/components/seo/SeoCopilotDrawer.d.ts +10 -0
  14. package/dist/components/seo/SeoCopilotDrawer.d.ts.map +1 -0
  15. package/dist/components/seo/SeoCopilotDrawer.js +34 -0
  16. package/dist/components/seo/SeoCopilotDrawer.js.map +1 -0
  17. package/dist/components/seo/SeoEditorDrawer.d.ts +8 -0
  18. package/dist/components/seo/SeoEditorDrawer.d.ts.map +1 -0
  19. package/dist/components/seo/SeoEditorDrawer.js +111 -0
  20. package/dist/components/seo/SeoEditorDrawer.js.map +1 -0
  21. package/dist/components/seo/SeoIssueFixDrawer.d.ts +8 -0
  22. package/dist/components/seo/SeoIssueFixDrawer.d.ts.map +1 -0
  23. package/dist/components/seo/SeoIssueFixDrawer.js +111 -0
  24. package/dist/components/seo/SeoIssueFixDrawer.js.map +1 -0
  25. package/dist/components/seo/primitives.d.ts +53 -0
  26. package/dist/components/seo/primitives.d.ts.map +1 -0
  27. package/dist/components/seo/primitives.js +100 -0
  28. package/dist/components/seo/primitives.js.map +1 -0
  29. package/dist/layout/Sidebar.d.ts.map +1 -1
  30. package/dist/layout/Sidebar.js +3 -0
  31. package/dist/layout/Sidebar.js.map +1 -1
  32. package/dist/lib/seo-service.d.ts +322 -0
  33. package/dist/lib/seo-service.d.ts.map +1 -0
  34. package/dist/lib/seo-service.js +295 -0
  35. package/dist/lib/seo-service.js.map +1 -0
  36. package/dist/router/index.d.ts.map +1 -1
  37. package/dist/router/index.js +4 -1
  38. package/dist/router/index.js.map +1 -1
  39. package/dist/views/MediaBrowser.d.ts.map +1 -1
  40. package/dist/views/MediaBrowser.js +36 -25
  41. package/dist/views/MediaBrowser.js.map +1 -1
  42. package/dist/views/Posts/NewPostTypeInstructions.js +2 -2
  43. package/dist/views/Posts/post-type-presets.d.ts +5 -0
  44. package/dist/views/Posts/post-type-presets.d.ts.map +1 -1
  45. package/dist/views/Posts/post-type-presets.js +10 -64
  46. package/dist/views/Posts/post-type-presets.js.map +1 -1
  47. package/dist/views/SEO.d.ts.map +1 -1
  48. package/dist/views/SEO.js +89 -132
  49. package/dist/views/SEO.js.map +1 -1
  50. package/dist/views/seo/AuditTab.d.ts +6 -0
  51. package/dist/views/seo/AuditTab.d.ts.map +1 -0
  52. package/dist/views/seo/AuditTab.js +57 -0
  53. package/dist/views/seo/AuditTab.js.map +1 -0
  54. package/dist/views/seo/ContentTab.d.ts +5 -0
  55. package/dist/views/seo/ContentTab.d.ts.map +1 -0
  56. package/dist/views/seo/ContentTab.js +27 -0
  57. package/dist/views/seo/ContentTab.js.map +1 -0
  58. package/dist/views/seo/OverviewTab.d.ts +8 -0
  59. package/dist/views/seo/OverviewTab.d.ts.map +1 -0
  60. package/dist/views/seo/OverviewTab.js +35 -0
  61. package/dist/views/seo/OverviewTab.js.map +1 -0
  62. package/dist/views/seo/RedirectsTab.d.ts +2 -0
  63. package/dist/views/seo/RedirectsTab.d.ts.map +1 -0
  64. package/dist/views/seo/RedirectsTab.js +124 -0
  65. package/dist/views/seo/RedirectsTab.js.map +1 -0
  66. package/dist/views/seo/TechnicalTab.d.ts +2 -0
  67. package/dist/views/seo/TechnicalTab.d.ts.map +1 -0
  68. package/dist/views/seo/TechnicalTab.js +102 -0
  69. package/dist/views/seo/TechnicalTab.js.map +1 -0
  70. package/dist/views/seo/useSeoResource.d.ts +8 -0
  71. package/dist/views/seo/useSeoResource.d.ts.map +1 -0
  72. package/dist/views/seo/useSeoResource.js +42 -0
  73. package/dist/views/seo/useSeoResource.js.map +1 -0
  74. package/package.json +2 -2
  75. package/src/AdminRoot.tsx +9 -5
  76. package/src/components/seo/Drawer.tsx +61 -0
  77. package/src/components/seo/RedirectEditorDrawer.tsx +235 -0
  78. package/src/components/seo/SeoCopilotDrawer.tsx +76 -0
  79. package/src/components/seo/SeoEditorDrawer.tsx +347 -0
  80. package/src/components/seo/SeoIssueFixDrawer.tsx +244 -0
  81. package/src/components/seo/primitives.tsx +237 -0
  82. package/src/layout/Sidebar.tsx +3 -0
  83. package/src/lib/seo-service.ts +623 -0
  84. package/src/router/index.ts +4 -1
  85. package/src/views/MediaBrowser.tsx +89 -67
  86. package/src/views/Posts/NewPostTypeInstructions.tsx +2 -2
  87. package/src/views/Posts/post-type-presets.ts +15 -64
  88. package/src/views/SEO.tsx +186 -863
  89. package/src/views/seo/AuditTab.tsx +229 -0
  90. package/src/views/seo/ContentTab.tsx +164 -0
  91. package/src/views/seo/OverviewTab.tsx +257 -0
  92. package/src/views/seo/RedirectsTab.tsx +392 -0
  93. package/src/views/seo/TechnicalTab.tsx +303 -0
  94. package/src/views/seo/useSeoResource.ts +52 -0
@@ -0,0 +1,347 @@
1
+ 'use client'
2
+
3
+ import { useEffect, useState } from 'react'
4
+ import { Sparkles, Check } from 'lucide-react'
5
+ import { toast } from 'sonner'
6
+ import {
7
+ fetchSeoContentRecord,
8
+ updateSeoFields,
9
+ generateSeoField,
10
+ type SeoContentRecord,
11
+ type SeoFieldPayload,
12
+ } from '../../lib/seo-service.js'
13
+ import { Drawer } from './Drawer.js'
14
+ import { SeoLoading, SeoErrorState, btnPrimary, btnSecondary, gradeMeta } from './primitives.js'
15
+
16
+ const META_TITLE_MAX = 60
17
+ const META_DESC_MAX = 160
18
+
19
+ type AiField = 'metaTitle' | 'metaDescription' | 'ogTitle' | 'ogDescription' | 'focusKeyword'
20
+
21
+ function CharCount({ value, max }: { value: string; max: number }) {
22
+ const over = value.length > max
23
+ return (
24
+ <span className={`text-xs ${over ? 'text-destructive' : 'text-muted-foreground'}`}>
25
+ {value.length}/{max}
26
+ </span>
27
+ )
28
+ }
29
+
30
+ function Field({
31
+ label,
32
+ children,
33
+ hint,
34
+ }: {
35
+ label: string
36
+ children: React.ReactNode
37
+ hint?: React.ReactNode
38
+ }) {
39
+ return (
40
+ <div className="space-y-1.5">
41
+ <div className="flex items-center justify-between">
42
+ <label className="text-foreground text-sm font-medium">{label}</label>
43
+ {hint}
44
+ </div>
45
+ {children}
46
+ </div>
47
+ )
48
+ }
49
+
50
+ const inputCls =
51
+ 'w-full rounded-md border border-border bg-input-background px-3 py-2 text-base text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring'
52
+
53
+ export function SeoEditorDrawer({
54
+ open,
55
+ onOpenChange,
56
+ entityType,
57
+ entityId,
58
+ onSaved,
59
+ }: {
60
+ open: boolean
61
+ onOpenChange: (open: boolean) => void
62
+ entityType: string | null
63
+ entityId: string | null
64
+ onSaved?: () => void
65
+ }) {
66
+ const [record, setRecord] = useState<SeoContentRecord | null>(null)
67
+ const [loading, setLoading] = useState(false)
68
+ const [error, setError] = useState<string | null>(null)
69
+ const [saving, setSaving] = useState(false)
70
+ const [aiBusy, setAiBusy] = useState<AiField | null>(null)
71
+ const [form, setForm] = useState<SeoFieldPayload>({})
72
+
73
+ useEffect(() => {
74
+ if (!open || !entityType || !entityId) return
75
+ let alive = true
76
+ setLoading(true)
77
+ setError(null)
78
+ fetchSeoContentRecord(entityType, entityId)
79
+ .then((rec) => {
80
+ if (!alive) return
81
+ if (!rec) {
82
+ setError('Could not load this record.')
83
+ return
84
+ }
85
+ setRecord(rec)
86
+ setForm({
87
+ metaTitle: rec.metaTitle ?? '',
88
+ metaDescription: rec.metaDescription ?? '',
89
+ canonicalUrl: rec.canonicalUrl ?? '',
90
+ focusKeyword: rec.focusKeyword ?? '',
91
+ ogTitle: rec.ogTitle ?? '',
92
+ ogDescription: rec.ogDescription ?? '',
93
+ noindex: rec.noindex,
94
+ nofollow: rec.nofollow,
95
+ })
96
+ })
97
+ .catch((e) => alive && setError(e instanceof Error ? e.message : 'Failed to load'))
98
+ .finally(() => alive && setLoading(false))
99
+ return () => {
100
+ alive = false
101
+ }
102
+ }, [open, entityType, entityId])
103
+
104
+ const update = (patch: Partial<SeoFieldPayload>) => setForm((f) => ({ ...f, ...patch }))
105
+
106
+ async function handleAiGenerate(field: AiField) {
107
+ if (!entityType || !entityId) return
108
+ setAiBusy(field)
109
+ try {
110
+ const result = await generateSeoField(field, { entityType, entityId })
111
+ if (result.unavailable) {
112
+ toast.error('AI is not configured. Add an AI provider to enable suggestions.')
113
+ return
114
+ }
115
+ if (result.text) {
116
+ update({ [field]: result.text } as Partial<SeoFieldPayload>)
117
+ toast.success('AI suggestion applied — review before saving.')
118
+ } else {
119
+ toast.error('No suggestion was returned.')
120
+ }
121
+ } catch {
122
+ toast.error('AI request failed.')
123
+ } finally {
124
+ setAiBusy(null)
125
+ }
126
+ }
127
+
128
+ async function handleSave() {
129
+ if (!entityType || !entityId) return
130
+ setSaving(true)
131
+ const res = await updateSeoFields(entityType, entityId, form)
132
+ setSaving(false)
133
+ if (res.error) {
134
+ toast.error(res.error)
135
+ return
136
+ }
137
+ toast.success('SEO fields saved.')
138
+ onOpenChange(false)
139
+ onSaved?.()
140
+ }
141
+
142
+ const title = form.metaTitle || record?.title || 'Untitled'
143
+ const desc = form.metaDescription || 'No meta description set. Search engines may generate one.'
144
+ const url = record?.url ?? ''
145
+
146
+ function aiButton(field: AiField) {
147
+ return (
148
+ <button
149
+ type="button"
150
+ onClick={() => handleAiGenerate(field)}
151
+ disabled={aiBusy !== null}
152
+ className="text-primary hover:bg-accent focus-visible:ring-ring inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium focus-visible:ring-2 focus-visible:outline-none disabled:opacity-60"
153
+ >
154
+ <Sparkles
155
+ className={`h-3.5 w-3.5 ${aiBusy === field ? 'animate-pulse' : ''}`}
156
+ aria-hidden
157
+ />
158
+ {aiBusy === field ? 'Generating…' : 'AI Generate'}
159
+ </button>
160
+ )
161
+ }
162
+
163
+ return (
164
+ <Drawer
165
+ open={open}
166
+ onOpenChange={onOpenChange}
167
+ title="Edit SEO"
168
+ description={record?.title}
169
+ footer={
170
+ <>
171
+ <button className={btnSecondary} onClick={() => onOpenChange(false)} disabled={saving}>
172
+ Cancel
173
+ </button>
174
+ <button className={btnPrimary} onClick={handleSave} disabled={saving || loading}>
175
+ {saving ? 'Saving…' : 'Save changes'}
176
+ </button>
177
+ </>
178
+ }
179
+ >
180
+ {loading ? (
181
+ <SeoLoading />
182
+ ) : error ? (
183
+ <SeoErrorState message={error} />
184
+ ) : record ? (
185
+ <div className="space-y-6">
186
+ {/* SERP preview */}
187
+ <div className="border-border rounded-lg border p-4">
188
+ <p className="text-muted-foreground mb-2 text-xs font-medium tracking-wide uppercase">
189
+ Google preview
190
+ </p>
191
+ <p className="text-success truncate text-sm">{url}</p>
192
+ <p className="text-primary text-lg leading-snug">{title}</p>
193
+ <p className="text-muted-foreground line-clamp-2 text-sm">{desc}</p>
194
+ </div>
195
+
196
+ <Field
197
+ label="Meta title"
198
+ hint={
199
+ <span className="flex items-center gap-2">
200
+ <CharCount value={form.metaTitle ?? ''} max={META_TITLE_MAX} />
201
+ {aiButton('metaTitle')}
202
+ </span>
203
+ }
204
+ >
205
+ <input
206
+ className={inputCls}
207
+ value={form.metaTitle ?? ''}
208
+ onChange={(e) => update({ metaTitle: e.target.value })}
209
+ placeholder="Page title for search results"
210
+ />
211
+ </Field>
212
+
213
+ <Field
214
+ label="Meta description"
215
+ hint={
216
+ <span className="flex items-center gap-2">
217
+ <CharCount value={form.metaDescription ?? ''} max={META_DESC_MAX} />
218
+ {aiButton('metaDescription')}
219
+ </span>
220
+ }
221
+ >
222
+ <textarea
223
+ className={`${inputCls} min-h-20 resize-y`}
224
+ value={form.metaDescription ?? ''}
225
+ onChange={(e) => update({ metaDescription: e.target.value })}
226
+ placeholder="Short summary shown under the title in search results"
227
+ />
228
+ </Field>
229
+
230
+ <Field label="Focus keyword" hint={aiButton('focusKeyword')}>
231
+ <input
232
+ className={inputCls}
233
+ value={form.focusKeyword ?? ''}
234
+ onChange={(e) => update({ focusKeyword: e.target.value })}
235
+ placeholder="Primary keyword this page targets"
236
+ />
237
+ </Field>
238
+
239
+ <Field label="Canonical URL">
240
+ <input
241
+ className={inputCls}
242
+ value={form.canonicalUrl ?? ''}
243
+ onChange={(e) => update({ canonicalUrl: e.target.value })}
244
+ placeholder={url || 'https://example.com/page'}
245
+ />
246
+ </Field>
247
+
248
+ {/* Social preview */}
249
+ <div className="space-y-4">
250
+ <p className="text-foreground text-sm font-medium">Social sharing</p>
251
+ <Field label="Open Graph title" hint={aiButton('ogTitle')}>
252
+ <input
253
+ className={inputCls}
254
+ value={form.ogTitle ?? ''}
255
+ onChange={(e) => update({ ogTitle: e.target.value })}
256
+ placeholder={form.metaTitle || 'Title when shared on social media'}
257
+ />
258
+ </Field>
259
+ <Field label="Open Graph description" hint={aiButton('ogDescription')}>
260
+ <textarea
261
+ className={`${inputCls} min-h-16 resize-y`}
262
+ value={form.ogDescription ?? ''}
263
+ onChange={(e) => update({ ogDescription: e.target.value })}
264
+ placeholder={form.metaDescription || 'Description when shared on social media'}
265
+ />
266
+ </Field>
267
+ <div className="border-border overflow-hidden rounded-lg border">
268
+ {record.ogImage ? (
269
+ // eslint-disable-next-line @next/next/no-img-element
270
+ <img
271
+ src={record.ogImage}
272
+ alt={`Social preview for ${record.title}`}
273
+ className="bg-muted aspect-[1200/630] w-full object-cover"
274
+ />
275
+ ) : (
276
+ <div className="bg-muted text-muted-foreground flex aspect-[1200/630] w-full items-center justify-center text-sm">
277
+ No OG image set
278
+ </div>
279
+ )}
280
+ <div className="p-3">
281
+ <p className="text-muted-foreground truncate text-xs uppercase">
282
+ {url.replace(/^https?:\/\//, '').split('/')[0]}
283
+ </p>
284
+ <p className="text-foreground truncate text-sm font-medium">
285
+ {form.ogTitle || title}
286
+ </p>
287
+ <p className="text-muted-foreground line-clamp-1 text-sm">
288
+ {form.ogDescription || desc}
289
+ </p>
290
+ </div>
291
+ </div>
292
+ </div>
293
+
294
+ {/* Indexing toggles */}
295
+ <div className="border-border space-y-3 rounded-lg border p-4">
296
+ <label className="flex items-center justify-between gap-3">
297
+ <span className="min-w-0">
298
+ <span className="text-foreground block text-sm font-medium">No-index</span>
299
+ <span className="text-muted-foreground block text-sm">
300
+ Hide this page from search engines.
301
+ </span>
302
+ </span>
303
+ <input
304
+ type="checkbox"
305
+ role="switch"
306
+ aria-checked={!!form.noindex}
307
+ checked={!!form.noindex}
308
+ onChange={(e) => update({ noindex: e.target.checked })}
309
+ className="accent-primary h-4 w-4"
310
+ />
311
+ </label>
312
+ <label className="flex items-center justify-between gap-3">
313
+ <span className="min-w-0">
314
+ <span className="text-foreground block text-sm font-medium">No-follow</span>
315
+ <span className="text-muted-foreground block text-sm">
316
+ Tell crawlers not to follow links on this page.
317
+ </span>
318
+ </span>
319
+ <input
320
+ type="checkbox"
321
+ role="switch"
322
+ aria-checked={!!form.nofollow}
323
+ checked={!!form.nofollow}
324
+ onChange={(e) => update({ nofollow: e.target.checked })}
325
+ className="accent-primary h-4 w-4"
326
+ />
327
+ </label>
328
+ </div>
329
+
330
+ {/* Score summary */}
331
+ {(() => {
332
+ const meta = gradeMeta(record.seoGrade)
333
+ return (
334
+ <div
335
+ className={`flex items-center gap-2 rounded-lg px-3 py-2 text-sm ${meta.bg} ${meta.text}`}
336
+ >
337
+ <Check className="h-4 w-4" aria-hidden />
338
+ Current SEO score: <span className="font-medium">{record.seoScore}</span> (
339
+ {meta.label})
340
+ </div>
341
+ )
342
+ })()}
343
+ </div>
344
+ ) : null}
345
+ </Drawer>
346
+ )
347
+ }
@@ -0,0 +1,244 @@
1
+ 'use client'
2
+
3
+ import { useEffect, useState } from 'react'
4
+ import { Sparkles, ArrowRight, ExternalLink, Image as ImageIcon, Gauge } from 'lucide-react'
5
+ import { toast } from 'sonner'
6
+ import {
7
+ fetchSeoIssue,
8
+ resolveSeoIssue,
9
+ ignoreSeoIssue,
10
+ reopenSeoIssue,
11
+ explainSeoIssue,
12
+ type SeoIssue,
13
+ } from '../../lib/seo-service.js'
14
+ import { Drawer } from './Drawer.js'
15
+ import { SeoLoading, SeoErrorState, severityMeta, btnPrimary, btnSecondary } from './primitives.js'
16
+
17
+ /** Map a fix action to a destination route within the admin. */
18
+ function fixRoute(issue: SeoIssue): { label: string; path: string; icon: React.ReactNode } | null {
19
+ const ent = issue.entityType
20
+ const id = issue.entityId
21
+ switch (issue.fixActionType) {
22
+ case 'edit-metadata':
23
+ case 'edit-canonical':
24
+ case 'edit-og':
25
+ case 'edit-schema':
26
+ if (ent && id) {
27
+ return {
28
+ label: 'Edit content SEO',
29
+ path: `/seo?tab=content&entityType=${ent}&entityId=${encodeURIComponent(id)}`,
30
+ icon: <ArrowRight className="h-4 w-4" aria-hidden />,
31
+ }
32
+ }
33
+ return null
34
+ case 'fix-broken-link':
35
+ case 'create-redirect':
36
+ return {
37
+ label: 'Open redirects',
38
+ path: '/seo?tab=redirects',
39
+ icon: <ArrowRight className="h-4 w-4" aria-hidden />,
40
+ }
41
+ case 'optimize-media':
42
+ return {
43
+ label: 'Open Media Center',
44
+ path: '/media',
45
+ icon: <ImageIcon className="h-4 w-4" aria-hidden />,
46
+ }
47
+ case 'improve-speed':
48
+ return {
49
+ label: 'Technical settings',
50
+ path: '/seo?tab=technical',
51
+ icon: <Gauge className="h-4 w-4" aria-hidden />,
52
+ }
53
+ default:
54
+ return null
55
+ }
56
+ }
57
+
58
+ export function SeoIssueFixDrawer({
59
+ open,
60
+ onOpenChange,
61
+ issueId,
62
+ onChanged,
63
+ onNavigate,
64
+ }: {
65
+ open: boolean
66
+ onOpenChange: (open: boolean) => void
67
+ issueId: string | null
68
+ onChanged?: () => void
69
+ onNavigate?: (path: string) => void
70
+ }) {
71
+ const [issue, setIssue] = useState<SeoIssue | null>(null)
72
+ const [loading, setLoading] = useState(false)
73
+ const [error, setError] = useState<string | null>(null)
74
+ const [busy, setBusy] = useState(false)
75
+ const [explanation, setExplanation] = useState<string | null>(null)
76
+ const [explaining, setExplaining] = useState(false)
77
+
78
+ useEffect(() => {
79
+ if (!open || !issueId) return
80
+ let alive = true
81
+ setLoading(true)
82
+ setError(null)
83
+ setExplanation(null)
84
+ fetchSeoIssue(issueId)
85
+ .then((i) => {
86
+ if (!alive) return
87
+ if (!i) setError('Issue not found.')
88
+ else setIssue(i)
89
+ })
90
+ .catch((e) => alive && setError(e instanceof Error ? e.message : 'Failed to load'))
91
+ .finally(() => alive && setLoading(false))
92
+ return () => {
93
+ alive = false
94
+ }
95
+ }, [open, issueId])
96
+
97
+ async function mutate(fn: (id: string) => Promise<{ error?: string }>, successMsg: string) {
98
+ if (!issue) return
99
+ setBusy(true)
100
+ const res = await fn(issue.id)
101
+ setBusy(false)
102
+ if (res.error) return toast.error(res.error)
103
+ toast.success(successMsg)
104
+ onOpenChange(false)
105
+ onChanged?.()
106
+ }
107
+
108
+ async function handleExplain() {
109
+ if (!issue) return
110
+ setExplaining(true)
111
+ const res = await explainSeoIssue(issue.id)
112
+ setExplaining(false)
113
+ if (res.unavailable) {
114
+ toast.error('AI is not configured.')
115
+ return
116
+ }
117
+ setExplanation(res.text ?? 'No explanation available.')
118
+ }
119
+
120
+ const route = issue ? fixRoute(issue) : null
121
+
122
+ return (
123
+ <Drawer
124
+ open={open}
125
+ onOpenChange={onOpenChange}
126
+ title="Issue detail"
127
+ width="max-w-lg"
128
+ footer={
129
+ issue ? (
130
+ <>
131
+ {issue.status === 'ignored' ? (
132
+ <button
133
+ className={btnSecondary}
134
+ onClick={() => mutate(reopenSeoIssue, 'Issue reopened.')}
135
+ disabled={busy}
136
+ >
137
+ Reopen
138
+ </button>
139
+ ) : (
140
+ <button
141
+ className={btnSecondary}
142
+ onClick={() => mutate(ignoreSeoIssue, 'Issue ignored.')}
143
+ disabled={busy}
144
+ >
145
+ Ignore
146
+ </button>
147
+ )}
148
+ {route && onNavigate ? (
149
+ <button
150
+ className={btnPrimary}
151
+ onClick={() => {
152
+ onNavigate(route.path)
153
+ onOpenChange(false)
154
+ }}
155
+ >
156
+ {route.icon}
157
+ {route.label}
158
+ </button>
159
+ ) : (
160
+ <button
161
+ className={btnPrimary}
162
+ onClick={() => mutate(resolveSeoIssue, 'Issue resolved.')}
163
+ disabled={busy}
164
+ >
165
+ Mark resolved
166
+ </button>
167
+ )}
168
+ </>
169
+ ) : null
170
+ }
171
+ >
172
+ {loading ? (
173
+ <SeoLoading />
174
+ ) : error ? (
175
+ <SeoErrorState message={error} />
176
+ ) : issue ? (
177
+ <div className="space-y-4">
178
+ {(() => {
179
+ const meta = severityMeta(issue.severity)
180
+ return (
181
+ <span
182
+ className={`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium ${meta.bg} ${meta.text}`}
183
+ >
184
+ <span className={`h-1.5 w-1.5 rounded-full ${meta.dot}`} aria-hidden />
185
+ {meta.label} · {issue.category}
186
+ </span>
187
+ )
188
+ })()}
189
+
190
+ <div>
191
+ <h3 className="text-foreground text-base font-medium">{issue.title}</h3>
192
+ {issue.entityTitle && (
193
+ <p className="text-muted-foreground mt-0.5 text-sm">{issue.entityTitle}</p>
194
+ )}
195
+ </div>
196
+
197
+ {issue.url && (
198
+ <a
199
+ href={issue.url}
200
+ target="_blank"
201
+ rel="noopener noreferrer"
202
+ className="text-primary inline-flex items-center gap-1 text-sm hover:underline"
203
+ >
204
+ {issue.url}
205
+ <ExternalLink className="h-3.5 w-3.5" aria-hidden />
206
+ </a>
207
+ )}
208
+
209
+ {issue.description && <p className="text-foreground text-sm">{issue.description}</p>}
210
+
211
+ {issue.impact && (
212
+ <div className="border-border rounded-md border p-3">
213
+ <p className="text-muted-foreground text-xs font-medium tracking-wide uppercase">
214
+ Impact
215
+ </p>
216
+ <p className="text-foreground mt-1 text-sm">{issue.impact}</p>
217
+ </div>
218
+ )}
219
+
220
+ {issue.recommendation && (
221
+ <div className="border-border rounded-md border p-3">
222
+ <p className="text-muted-foreground text-xs font-medium tracking-wide uppercase">
223
+ Recommendation
224
+ </p>
225
+ <p className="text-foreground mt-1 text-sm">{issue.recommendation}</p>
226
+ </div>
227
+ )}
228
+
229
+ <div className="border-border rounded-md border p-3">
230
+ <button
231
+ onClick={handleExplain}
232
+ disabled={explaining}
233
+ className="text-primary focus-visible:ring-ring inline-flex items-center gap-1.5 text-sm font-medium focus-visible:ring-2 focus-visible:outline-none disabled:opacity-60"
234
+ >
235
+ <Sparkles className={`h-4 w-4 ${explaining ? 'animate-pulse' : ''}`} aria-hidden />
236
+ {explaining ? 'Asking AI…' : 'Explain with AI'}
237
+ </button>
238
+ {explanation && <p className="text-foreground mt-2 text-sm">{explanation}</p>}
239
+ </div>
240
+ </div>
241
+ ) : null}
242
+ </Drawer>
243
+ )
244
+ }