@actuate-media/cms-admin 0.19.0 → 0.21.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 (129) hide show
  1. package/dist/AdminRoot.d.ts.map +1 -1
  2. package/dist/AdminRoot.js +13 -9
  3. package/dist/AdminRoot.js.map +1 -1
  4. package/dist/__tests__/layout/sidebar-posts.test.js +6 -4
  5. package/dist/__tests__/layout/sidebar-posts.test.js.map +1 -1
  6. package/dist/__tests__/lib/seo-service-errors.test.d.ts +2 -0
  7. package/dist/__tests__/lib/seo-service-errors.test.d.ts.map +1 -0
  8. package/dist/__tests__/lib/seo-service-errors.test.js +46 -0
  9. package/dist/__tests__/lib/seo-service-errors.test.js.map +1 -0
  10. package/dist/__tests__/views/use-seo-resource.test.d.ts +2 -0
  11. package/dist/__tests__/views/use-seo-resource.test.d.ts.map +1 -0
  12. package/dist/__tests__/views/use-seo-resource.test.js +56 -0
  13. package/dist/__tests__/views/use-seo-resource.test.js.map +1 -0
  14. package/dist/actuate-admin.css +1 -1
  15. package/dist/components/Breadcrumbs.d.ts.map +1 -1
  16. package/dist/components/Breadcrumbs.js +4 -1
  17. package/dist/components/Breadcrumbs.js.map +1 -1
  18. package/dist/components/seo/Drawer.d.ts +11 -0
  19. package/dist/components/seo/Drawer.d.ts.map +1 -0
  20. package/dist/components/seo/Drawer.js +17 -0
  21. package/dist/components/seo/Drawer.js.map +1 -0
  22. package/dist/components/seo/RedirectEditorDrawer.d.ts +9 -0
  23. package/dist/components/seo/RedirectEditorDrawer.d.ts.map +1 -0
  24. package/dist/components/seo/RedirectEditorDrawer.js +94 -0
  25. package/dist/components/seo/RedirectEditorDrawer.js.map +1 -0
  26. package/dist/components/seo/SeoCopilotDrawer.d.ts +10 -0
  27. package/dist/components/seo/SeoCopilotDrawer.d.ts.map +1 -0
  28. package/dist/components/seo/SeoCopilotDrawer.js +34 -0
  29. package/dist/components/seo/SeoCopilotDrawer.js.map +1 -0
  30. package/dist/components/seo/SeoEditorDrawer.d.ts +8 -0
  31. package/dist/components/seo/SeoEditorDrawer.d.ts.map +1 -0
  32. package/dist/components/seo/SeoEditorDrawer.js +120 -0
  33. package/dist/components/seo/SeoEditorDrawer.js.map +1 -0
  34. package/dist/components/seo/SeoIssueFixDrawer.d.ts +8 -0
  35. package/dist/components/seo/SeoIssueFixDrawer.d.ts.map +1 -0
  36. package/dist/components/seo/SeoIssueFixDrawer.js +111 -0
  37. package/dist/components/seo/SeoIssueFixDrawer.js.map +1 -0
  38. package/dist/components/seo/primitives.d.ts +53 -0
  39. package/dist/components/seo/primitives.d.ts.map +1 -0
  40. package/dist/components/seo/primitives.js +101 -0
  41. package/dist/components/seo/primitives.js.map +1 -0
  42. package/dist/layout/Sidebar.d.ts.map +1 -1
  43. package/dist/layout/Sidebar.js +8 -5
  44. package/dist/layout/Sidebar.js.map +1 -1
  45. package/dist/lib/seo-service.d.ts +322 -0
  46. package/dist/lib/seo-service.d.ts.map +1 -0
  47. package/dist/lib/seo-service.js +331 -0
  48. package/dist/lib/seo-service.js.map +1 -0
  49. package/dist/router/index.d.ts.map +1 -1
  50. package/dist/router/index.js +4 -1
  51. package/dist/router/index.js.map +1 -1
  52. package/dist/views/ApiKeys.d.ts +4 -1
  53. package/dist/views/ApiKeys.d.ts.map +1 -1
  54. package/dist/views/ApiKeys.js +5 -3
  55. package/dist/views/ApiKeys.js.map +1 -1
  56. package/dist/views/Dashboard.js +2 -2
  57. package/dist/views/Dashboard.js.map +1 -1
  58. package/dist/views/MediaBrowser.d.ts.map +1 -1
  59. package/dist/views/MediaBrowser.js +36 -25
  60. package/dist/views/MediaBrowser.js.map +1 -1
  61. package/dist/views/Posts/NewPostTypeInstructions.js +2 -2
  62. package/dist/views/Posts/post-type-presets.d.ts +5 -0
  63. package/dist/views/Posts/post-type-presets.d.ts.map +1 -1
  64. package/dist/views/Posts/post-type-presets.js +10 -64
  65. package/dist/views/Posts/post-type-presets.js.map +1 -1
  66. package/dist/views/SEO.d.ts.map +1 -1
  67. package/dist/views/SEO.js +89 -132
  68. package/dist/views/SEO.js.map +1 -1
  69. package/dist/views/Settings.d.ts +4 -1
  70. package/dist/views/Settings.d.ts.map +1 -1
  71. package/dist/views/Settings.js +45 -6
  72. package/dist/views/Settings.js.map +1 -1
  73. package/dist/views/Users.d.ts +4 -1
  74. package/dist/views/Users.d.ts.map +1 -1
  75. package/dist/views/Users.js +5 -3
  76. package/dist/views/Users.js.map +1 -1
  77. package/dist/views/seo/AuditTab.d.ts +6 -0
  78. package/dist/views/seo/AuditTab.d.ts.map +1 -0
  79. package/dist/views/seo/AuditTab.js +57 -0
  80. package/dist/views/seo/AuditTab.js.map +1 -0
  81. package/dist/views/seo/ContentTab.d.ts +5 -0
  82. package/dist/views/seo/ContentTab.d.ts.map +1 -0
  83. package/dist/views/seo/ContentTab.js +27 -0
  84. package/dist/views/seo/ContentTab.js.map +1 -0
  85. package/dist/views/seo/OverviewTab.d.ts +8 -0
  86. package/dist/views/seo/OverviewTab.d.ts.map +1 -0
  87. package/dist/views/seo/OverviewTab.js +35 -0
  88. package/dist/views/seo/OverviewTab.js.map +1 -0
  89. package/dist/views/seo/RedirectsTab.d.ts +2 -0
  90. package/dist/views/seo/RedirectsTab.d.ts.map +1 -0
  91. package/dist/views/seo/RedirectsTab.js +130 -0
  92. package/dist/views/seo/RedirectsTab.js.map +1 -0
  93. package/dist/views/seo/TechnicalTab.d.ts +2 -0
  94. package/dist/views/seo/TechnicalTab.d.ts.map +1 -0
  95. package/dist/views/seo/TechnicalTab.js +105 -0
  96. package/dist/views/seo/TechnicalTab.js.map +1 -0
  97. package/dist/views/seo/useSeoResource.d.ts +8 -0
  98. package/dist/views/seo/useSeoResource.d.ts.map +1 -0
  99. package/dist/views/seo/useSeoResource.js +55 -0
  100. package/dist/views/seo/useSeoResource.js.map +1 -0
  101. package/package.json +2 -2
  102. package/src/AdminRoot.tsx +13 -9
  103. package/src/__tests__/layout/sidebar-posts.test.ts +6 -4
  104. package/src/__tests__/lib/seo-service-errors.test.ts +60 -0
  105. package/src/__tests__/views/use-seo-resource.test.tsx +68 -0
  106. package/src/components/Breadcrumbs.tsx +4 -1
  107. package/src/components/seo/Drawer.tsx +65 -0
  108. package/src/components/seo/RedirectEditorDrawer.tsx +235 -0
  109. package/src/components/seo/SeoCopilotDrawer.tsx +76 -0
  110. package/src/components/seo/SeoEditorDrawer.tsx +359 -0
  111. package/src/components/seo/SeoIssueFixDrawer.tsx +244 -0
  112. package/src/components/seo/primitives.tsx +240 -0
  113. package/src/layout/Sidebar.tsx +7 -10
  114. package/src/lib/seo-service.ts +660 -0
  115. package/src/router/index.ts +4 -1
  116. package/src/views/ApiKeys.tsx +10 -5
  117. package/src/views/Dashboard.tsx +2 -2
  118. package/src/views/MediaBrowser.tsx +89 -67
  119. package/src/views/Posts/NewPostTypeInstructions.tsx +2 -2
  120. package/src/views/Posts/post-type-presets.ts +15 -64
  121. package/src/views/SEO.tsx +186 -863
  122. package/src/views/Settings.tsx +93 -40
  123. package/src/views/Users.tsx +10 -4
  124. package/src/views/seo/AuditTab.tsx +229 -0
  125. package/src/views/seo/ContentTab.tsx +164 -0
  126. package/src/views/seo/OverviewTab.tsx +257 -0
  127. package/src/views/seo/RedirectsTab.tsx +398 -0
  128. package/src/views/seo/TechnicalTab.tsx +315 -0
  129. package/src/views/seo/useSeoResource.ts +66 -0
@@ -0,0 +1,65 @@
1
+ 'use client'
2
+
3
+ /**
4
+ * Right-side drawer built on Radix Dialog — focus-trapped, escape-closable,
5
+ * token-only styling. Shared by the SEO editor / fix / copilot drawers.
6
+ */
7
+ import * as Dialog from '@radix-ui/react-dialog'
8
+ import { X } from 'lucide-react'
9
+ import type { ReactNode } from 'react'
10
+ import { btnGhostIcon } from './primitives.js'
11
+
12
+ export function Drawer({
13
+ open,
14
+ onOpenChange,
15
+ title,
16
+ description,
17
+ footer,
18
+ children,
19
+ width = 'max-w-xl',
20
+ }: {
21
+ open: boolean
22
+ onOpenChange: (open: boolean) => void
23
+ title: string
24
+ description?: string
25
+ footer?: ReactNode
26
+ children: ReactNode
27
+ width?: string
28
+ }) {
29
+ return (
30
+ <Dialog.Root open={open} onOpenChange={onOpenChange}>
31
+ <Dialog.Portal>
32
+ <Dialog.Overlay className="bg-foreground/40 motion-safe:animate-in motion-safe:fade-in fixed inset-0 z-50" />
33
+ <Dialog.Content
34
+ // Radix auto-associates `aria-describedby` with the Dialog.Description
35
+ // when one is present; when it isn't, explicitly clear the attribute so
36
+ // Radix doesn't emit its "Missing Description" console warning.
37
+ {...(description ? {} : { 'aria-describedby': undefined })}
38
+ className={`bg-card text-foreground fixed inset-y-0 right-0 z-50 flex w-full ${width} motion-safe:animate-in motion-safe:slide-in-from-right flex-col shadow-xl outline-none`}
39
+ >
40
+ <header className="border-border flex items-start justify-between gap-3 border-b px-5 py-4">
41
+ <div className="min-w-0">
42
+ <Dialog.Title className="text-foreground text-lg font-medium">{title}</Dialog.Title>
43
+ {description && (
44
+ <Dialog.Description className="text-muted-foreground mt-0.5 text-sm">
45
+ {description}
46
+ </Dialog.Description>
47
+ )}
48
+ </div>
49
+ <Dialog.Close asChild>
50
+ <button className={btnGhostIcon} aria-label="Close">
51
+ <X size={20} aria-hidden />
52
+ </button>
53
+ </Dialog.Close>
54
+ </header>
55
+ <div className="min-h-0 flex-1 overflow-y-auto px-5 py-4">{children}</div>
56
+ {footer && (
57
+ <footer className="border-border bg-card flex items-center justify-end gap-2 border-t px-5 py-4">
58
+ {footer}
59
+ </footer>
60
+ )}
61
+ </Dialog.Content>
62
+ </Dialog.Portal>
63
+ </Dialog.Root>
64
+ )
65
+ }
@@ -0,0 +1,235 @@
1
+ 'use client'
2
+
3
+ import { useEffect, useState } from 'react'
4
+ import { toast } from 'sonner'
5
+ import {
6
+ createRedirectRule,
7
+ updateRedirectRule,
8
+ type RedirectRule,
9
+ type RedirectRulePayload,
10
+ type RedirectStatusCode,
11
+ } from '../../lib/seo-service.js'
12
+ import { Drawer } from './Drawer.js'
13
+ import { btnPrimary, btnSecondary } from './primitives.js'
14
+
15
+ const STATUS_CODES: { value: RedirectStatusCode; label: string }[] = [
16
+ { value: 301, label: '301 — Permanent' },
17
+ { value: 302, label: '302 — Temporary' },
18
+ { value: 307, label: '307 — Temporary (preserve method)' },
19
+ { value: 308, label: '308 — Permanent (preserve method)' },
20
+ { value: 410, label: '410 — Gone (no destination)' },
21
+ ]
22
+
23
+ const inputCls =
24
+ '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'
25
+
26
+ function normalizePath(p: string): string {
27
+ const t = p.trim()
28
+ if (!t) return ''
29
+ if (/^https?:\/\//i.test(t)) return t
30
+ return t.startsWith('/') ? t : `/${t}`
31
+ }
32
+
33
+ export function RedirectEditorDrawer({
34
+ open,
35
+ onOpenChange,
36
+ rule,
37
+ onSaved,
38
+ }: {
39
+ open: boolean
40
+ onOpenChange: (open: boolean) => void
41
+ /** null = create mode */
42
+ rule: RedirectRule | null
43
+ onSaved?: () => void
44
+ }) {
45
+ const [form, setForm] = useState<RedirectRulePayload>({
46
+ type: 301,
47
+ fromPath: '',
48
+ toPath: '',
49
+ enabled: true,
50
+ preserveQuery: false,
51
+ notes: '',
52
+ })
53
+ const [saving, setSaving] = useState(false)
54
+ const [clientError, setClientError] = useState<string | null>(null)
55
+
56
+ useEffect(() => {
57
+ if (!open) return
58
+ if (rule) {
59
+ setForm({
60
+ type: rule.type,
61
+ fromPath: rule.fromPath,
62
+ toPath: rule.toPath,
63
+ enabled: rule.enabled,
64
+ preserveQuery: rule.preserveQuery,
65
+ notes: rule.notes ?? '',
66
+ })
67
+ } else {
68
+ setForm({
69
+ type: 301,
70
+ fromPath: '',
71
+ toPath: '',
72
+ enabled: true,
73
+ preserveQuery: false,
74
+ notes: '',
75
+ })
76
+ }
77
+ setClientError(null)
78
+ }, [open, rule])
79
+
80
+ const isGone = form.type === 410
81
+ const update = (patch: Partial<RedirectRulePayload>) => setForm((f) => ({ ...f, ...patch }))
82
+
83
+ async function handleSave() {
84
+ const fromPath = normalizePath(form.fromPath)
85
+ const toPath = isGone ? '' : normalizePath(form.toPath)
86
+ if (!fromPath) {
87
+ setClientError('Source path is required.')
88
+ return
89
+ }
90
+ if (!isGone && !toPath) {
91
+ setClientError('Destination is required for redirect status codes.')
92
+ return
93
+ }
94
+ if (!isGone && fromPath === toPath) {
95
+ setClientError('Source and destination cannot be identical (would create a loop).')
96
+ return
97
+ }
98
+ setClientError(null)
99
+ setSaving(true)
100
+ const payload: RedirectRulePayload = { ...form, fromPath, toPath }
101
+ const res = rule
102
+ ? await updateRedirectRule(rule.id, payload)
103
+ : await createRedirectRule(payload)
104
+ setSaving(false)
105
+ if (res.error) {
106
+ toast.error(res.error)
107
+ return
108
+ }
109
+ toast.success(rule ? 'Redirect updated.' : 'Redirect created.')
110
+ onOpenChange(false)
111
+ onSaved?.()
112
+ }
113
+
114
+ return (
115
+ <Drawer
116
+ open={open}
117
+ onOpenChange={onOpenChange}
118
+ title={rule ? 'Edit redirect' : 'New redirect'}
119
+ width="max-w-lg"
120
+ footer={
121
+ <>
122
+ <button className={btnSecondary} onClick={() => onOpenChange(false)} disabled={saving}>
123
+ Cancel
124
+ </button>
125
+ <button className={btnPrimary} onClick={handleSave} disabled={saving}>
126
+ {saving ? 'Saving…' : rule ? 'Save changes' : 'Create redirect'}
127
+ </button>
128
+ </>
129
+ }
130
+ >
131
+ <div className="space-y-4">
132
+ {clientError && (
133
+ <p
134
+ className="text-destructive bg-destructive/10 rounded-md px-3 py-2 text-sm"
135
+ role="alert"
136
+ >
137
+ {clientError}
138
+ </p>
139
+ )}
140
+ <div className="space-y-1.5">
141
+ <label className="text-foreground text-sm font-medium" htmlFor="redir-type">
142
+ Status code
143
+ </label>
144
+ <select
145
+ id="redir-type"
146
+ className={inputCls}
147
+ value={form.type}
148
+ onChange={(e) => update({ type: Number(e.target.value) as RedirectStatusCode })}
149
+ >
150
+ {STATUS_CODES.map((s) => (
151
+ <option key={s.value} value={s.value}>
152
+ {s.label}
153
+ </option>
154
+ ))}
155
+ </select>
156
+ </div>
157
+
158
+ <div className="space-y-1.5">
159
+ <label className="text-foreground text-sm font-medium" htmlFor="redir-from">
160
+ Source path
161
+ </label>
162
+ <input
163
+ id="redir-from"
164
+ className={inputCls}
165
+ value={form.fromPath}
166
+ onChange={(e) => update({ fromPath: e.target.value })}
167
+ placeholder="/old-path"
168
+ />
169
+ </div>
170
+
171
+ {!isGone && (
172
+ <div className="space-y-1.5">
173
+ <label className="text-foreground text-sm font-medium" htmlFor="redir-to">
174
+ Destination
175
+ </label>
176
+ <input
177
+ id="redir-to"
178
+ className={inputCls}
179
+ value={form.toPath}
180
+ onChange={(e) => update({ toPath: e.target.value })}
181
+ placeholder="/new-path or https://example.com/page"
182
+ />
183
+ </div>
184
+ )}
185
+
186
+ <div className="space-y-1.5">
187
+ <label className="text-foreground text-sm font-medium" htmlFor="redir-notes">
188
+ Notes <span className="text-muted-foreground font-normal">(optional)</span>
189
+ </label>
190
+ <input
191
+ id="redir-notes"
192
+ className={inputCls}
193
+ value={form.notes ?? ''}
194
+ onChange={(e) => update({ notes: e.target.value })}
195
+ placeholder="Why this redirect exists"
196
+ />
197
+ </div>
198
+
199
+ <div className="border-border space-y-3 rounded-lg border p-4">
200
+ <label className="flex items-center justify-between gap-3">
201
+ <span className="text-foreground text-sm font-medium">Enabled</span>
202
+ <input
203
+ type="checkbox"
204
+ role="switch"
205
+ aria-checked={!!form.enabled}
206
+ checked={!!form.enabled}
207
+ onChange={(e) => update({ enabled: e.target.checked })}
208
+ className="accent-primary h-4 w-4"
209
+ />
210
+ </label>
211
+ {!isGone && (
212
+ <label className="flex items-center justify-between gap-3">
213
+ <span className="min-w-0">
214
+ <span className="text-foreground block text-sm font-medium">
215
+ Preserve query string
216
+ </span>
217
+ <span className="text-muted-foreground block text-sm">
218
+ Append the original query params to the destination.
219
+ </span>
220
+ </span>
221
+ <input
222
+ type="checkbox"
223
+ role="switch"
224
+ aria-checked={!!form.preserveQuery}
225
+ checked={!!form.preserveQuery}
226
+ onChange={(e) => update({ preserveQuery: e.target.checked })}
227
+ className="accent-primary h-4 w-4 shrink-0"
228
+ />
229
+ </label>
230
+ )}
231
+ </div>
232
+ </div>
233
+ </Drawer>
234
+ )
235
+ }
@@ -0,0 +1,76 @@
1
+ 'use client'
2
+
3
+ import { useState } from 'react'
4
+ import { Sparkles, Bot } from 'lucide-react'
5
+ import { toast } from 'sonner'
6
+ import { summarizeSeoAudit } from '../../lib/seo-service.js'
7
+ import { Drawer } from './Drawer.js'
8
+ import { SeoLoading, SeoEmptyState, btnPrimary } from './primitives.js'
9
+
10
+ /**
11
+ * AI Copilot drawer — summarizes the current SEO state and surfaces the top
12
+ * priorities. Degrades gracefully when AI is unconfigured. All AI text is
13
+ * advisory; the editor takes action via the tabs/drawers.
14
+ */
15
+ export function SeoCopilotDrawer({
16
+ open,
17
+ onOpenChange,
18
+ }: {
19
+ open: boolean
20
+ onOpenChange: (open: boolean) => void
21
+ }) {
22
+ const [loading, setLoading] = useState(false)
23
+ const [summary, setSummary] = useState<string | null>(null)
24
+ const [unavailable, setUnavailable] = useState(false)
25
+
26
+ async function handleSummarize() {
27
+ setLoading(true)
28
+ setUnavailable(false)
29
+ const res = await summarizeSeoAudit()
30
+ setLoading(false)
31
+ if (res.unavailable) {
32
+ setUnavailable(true)
33
+ return
34
+ }
35
+ if (res.text) setSummary(res.text)
36
+ else toast.error('No summary was returned.')
37
+ }
38
+
39
+ return (
40
+ <Drawer
41
+ open={open}
42
+ onOpenChange={onOpenChange}
43
+ title="SEO Copilot"
44
+ description="AI-assisted analysis of your site's SEO health"
45
+ width="max-w-md"
46
+ footer={
47
+ <button className={btnPrimary} onClick={handleSummarize} disabled={loading}>
48
+ <Sparkles className={`h-4 w-4 ${loading ? 'animate-pulse' : ''}`} aria-hidden />
49
+ {loading ? 'Analyzing…' : summary ? 'Re-analyze' : 'Analyze my SEO'}
50
+ </button>
51
+ }
52
+ >
53
+ {loading ? (
54
+ <SeoLoading label="Analyzing your SEO…" />
55
+ ) : unavailable ? (
56
+ <SeoEmptyState
57
+ icon={<Bot size={24} />}
58
+ title="AI is not configured"
59
+ description="Install and configure an AI provider (plugin-ai) to enable the SEO Copilot."
60
+ />
61
+ ) : summary ? (
62
+ <div className="text-foreground space-y-3 text-sm leading-relaxed">
63
+ {summary.split(/\n+/).map((para, i) => (
64
+ <p key={i}>{para}</p>
65
+ ))}
66
+ </div>
67
+ ) : (
68
+ <SeoEmptyState
69
+ icon={<Bot size={24} />}
70
+ title="Ask the Copilot"
71
+ description="Get an AI summary of your open issues and the top priorities to fix first."
72
+ />
73
+ )}
74
+ </Drawer>
75
+ )
76
+ }