@kidecms/core 0.1.11 → 0.13.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/LICENSE +21 -0
- package/admin/components/AssetsGrid.tsx +366 -173
- package/admin/components/BlockEditor.tsx +260 -679
- package/admin/components/CheckboxField.tsx +2 -2
- package/admin/components/CollaborationReviewBar.tsx +384 -0
- package/admin/components/ColorField.tsx +87 -0
- package/admin/components/CommandPalette.tsx +169 -0
- package/admin/components/ContentEditor.tsx +687 -0
- package/admin/components/DocumentActions.tsx +4 -2
- package/admin/components/DocumentsDataTable.tsx +91 -10
- package/admin/components/FieldControl.astro +151 -26
- package/admin/components/FocalPointSelector.tsx +27 -1
- package/admin/components/InternalLinkPicker.tsx +4 -3
- package/admin/components/LinkField.tsx +126 -0
- package/admin/components/RelationField.tsx +105 -26
- package/admin/components/RepeaterInput.tsx +46 -0
- package/admin/components/RichTextEditor.tsx +44 -9
- package/admin/components/SharedSectionBlockField.tsx +93 -0
- package/admin/components/SidebarUserMenu.tsx +1 -1
- package/admin/components/Toast.astro +1 -1
- package/admin/components/TreeItemsEditor.tsx +20 -19
- package/admin/components/TreeSelect.tsx +2 -2
- package/admin/components/YoutubeField.tsx +48 -0
- package/admin/components/block-fields.tsx +777 -0
- package/admin/components/content-block-spec.ts +114 -0
- package/admin/components/slash-command.tsx +242 -0
- package/admin/components/tree-utils.ts +14 -2
- package/admin/components/ui/badge.tsx +2 -3
- package/admin/components/ui/button.tsx +5 -4
- package/admin/components/ui/checkbox.tsx +1 -1
- package/admin/components/ui/input.tsx +1 -1
- package/admin/components/ui/select.tsx +1 -1
- package/admin/components/ui/table.tsx +1 -1
- package/admin/components/ui/textarea.tsx +1 -1
- package/admin/layouts/AdminLayout.astro +323 -123
- package/admin/lib/access.ts +54 -0
- package/admin/lib/collaboration.ts +178 -0
- package/admin/lib/edit-data.ts +448 -0
- package/admin/views/AccessDeniedView.astro +8 -0
- package/admin/views/EditView.astro +706 -0
- package/admin/views/ListView.astro +202 -0
- package/admin/views/RecentView.astro +76 -0
- package/admin/views/SinglesView.astro +65 -0
- package/admin/views/edit/EditScripts.astro +145 -0
- package/admin/views/edit/ReverseReferencesList.astro +68 -0
- package/core/admin.ts +193 -0
- package/core/ai.ts +87 -0
- package/core/api.ts +1392 -0
- package/core/assets.ts +336 -0
- package/core/audit.ts +84 -0
- package/core/auth-config.ts +44 -0
- package/core/auth.ts +303 -0
- package/core/collaboration.ts +276 -0
- package/core/content.ts +27 -0
- package/core/create-admin.ts +28 -0
- package/core/define.ts +625 -0
- package/core/field-model.ts +172 -0
- package/core/generator.ts +519 -0
- package/core/http.ts +42 -0
- package/core/image.ts +219 -0
- package/core/index.ts +211 -0
- package/core/locks.ts +52 -0
- package/core/log.ts +37 -0
- package/core/migrate.ts +278 -0
- package/core/rate-limit.ts +110 -0
- package/core/request-scope.ts +33 -0
- package/core/richtext.ts +1 -0
- package/core/runtime.ts +63 -0
- package/core/schema.ts +32 -0
- package/core/search.ts +489 -0
- package/core/seed.ts +101 -0
- package/core/shared-sections.ts +96 -0
- package/core/tasks.ts +176 -0
- package/core/values.ts +433 -0
- package/core/webhooks.ts +85 -0
- package/core/youtube.ts +39 -0
- package/internals/cli.mjs +34 -0
- package/internals/context.ts +67 -0
- package/internals/create-admin.ts +40 -0
- package/internals/describe.ts +25 -0
- package/internals/eject.ts +144 -0
- package/internals/generator.ts +11 -0
- package/internals/integration.ts +481 -0
- package/internals/mcp.ts +397 -0
- package/internals/project.ts +26 -0
- package/internals/push.ts +160 -0
- package/internals/reindex.ts +11 -0
- package/internals/restore.ts +257 -0
- package/internals/seed.data.ts +7 -0
- package/internals/seed.ts +11 -0
- package/internals/upgrade.ts +776 -0
- package/{virtual.d.ts → internals/virtual.d.ts} +39 -5
- package/middleware/auth.ts +130 -17
- package/middleware/push.ts +121 -0
- package/package.json +55 -67
- package/platform/cloudflare/cf-env.ts +60 -0
- package/platform/cloudflare/database.ts +28 -0
- package/platform/cloudflare/globals.d.ts +5 -0
- package/platform/cloudflare/storage.ts +33 -0
- package/platform/cloudflare/uploads-route.ts +37 -0
- package/platform/node/database.ts +39 -0
- package/platform/node/storage.ts +52 -0
- package/routes/admin/[...path].astro +71 -0
- package/routes/{pages/admin → admin}/assets/[id].astro +25 -19
- package/routes/admin/assets/index.astro +90 -0
- package/routes/{pages/admin/login.astro → admin/forgot-password.astro} +21 -19
- package/routes/{pages/admin → admin}/invite.astro +6 -6
- package/routes/admin/login.astro +103 -0
- package/routes/admin/reset-password.astro +73 -0
- package/routes/{pages/admin → admin}/setup.astro +31 -8
- package/routes/api/{cms/[collection] → [collection]}/[...path].ts +66 -14
- package/routes/api/admin/search.ts +89 -0
- package/routes/api/{cms/assets → assets}/[id].ts +24 -14
- package/routes/api/{cms/assets → assets}/index.ts +4 -2
- package/routes/api/assets/upload.ts +147 -0
- package/routes/api/auth/forgot-password.ts +77 -0
- package/routes/api/{cms/auth → auth}/invite.ts +41 -9
- package/routes/api/auth/login.ts +167 -0
- package/routes/api/{cms/auth → auth}/logout.ts +11 -2
- package/routes/api/auth/reset-password.ts +85 -0
- package/routes/api/auth/setup.ts +110 -0
- package/routes/api/auth/sso/[provider]/start.ts +34 -0
- package/routes/api/collaboration/index.ts +106 -0
- package/routes/api/cron/_authorize.ts +25 -0
- package/routes/api/{cms/cron → cron}/publish.ts +3 -9
- package/routes/api/cron/tasks.ts +33 -0
- package/routes/api/forms/submit/[slug].ts +143 -0
- package/routes/api/img/[...path].ts +65 -0
- package/routes/api/{cms/preview → preview}/render.ts +8 -3
- package/routes/api/{cms/references → references}/[collection]/[id].ts +31 -1
- package/routes/api/webhooks/[provider].ts +54 -0
- package/README.md +0 -28
- package/dist/admin.d.ts +0 -33
- package/dist/admin.js +0 -92
- package/dist/ai.d.ts +0 -15
- package/dist/ai.js +0 -70
- package/dist/api.d.ts +0 -14
- package/dist/api.js +0 -833
- package/dist/assets.d.ts +0 -51
- package/dist/assets.js +0 -163
- package/dist/auth.d.ts +0 -30
- package/dist/auth.js +0 -132
- package/dist/content.d.ts +0 -3
- package/dist/content.js +0 -29
- package/dist/create-admin.d.ts +0 -5
- package/dist/create-admin.js +0 -23
- package/dist/define.d.ts +0 -254
- package/dist/define.js +0 -36
- package/dist/generator.d.ts +0 -9
- package/dist/generator.js +0 -370
- package/dist/image.d.ts +0 -9
- package/dist/image.js +0 -69
- package/dist/index.d.ts +0 -28
- package/dist/index.js +0 -16
- package/dist/integration.d.ts +0 -14
- package/dist/integration.js +0 -327
- package/dist/locks.d.ts +0 -7
- package/dist/locks.js +0 -37
- package/dist/richtext.d.ts +0 -1
- package/dist/richtext.js +0 -1
- package/dist/runtime.d.ts +0 -24
- package/dist/runtime.js +0 -26
- package/dist/schema.d.ts +0 -17
- package/dist/schema.js +0 -13
- package/dist/seed.d.ts +0 -2
- package/dist/seed.js +0 -84
- package/dist/values.d.ts +0 -8
- package/dist/values.js +0 -102
- package/dist/webhooks.d.ts +0 -2
- package/dist/webhooks.js +0 -73
- package/routes/api/cms/assets/upload.ts +0 -112
- package/routes/api/cms/auth/login.ts +0 -124
- package/routes/api/cms/auth/setup.ts +0 -77
- package/routes/api/cms/img/[...path].ts +0 -24
- package/routes/pages/admin/[...path].astro +0 -1107
- package/routes/pages/admin/assets/index.astro +0 -63
- /package/routes/api/{cms/ai → ai}/alt-text.ts +0 -0
- /package/routes/api/{cms/ai → ai}/seo.ts +0 -0
- /package/routes/api/{cms/ai → ai}/translate.ts +0 -0
- /package/routes/api/{cms/assets → assets}/folders.ts +0 -0
- /package/routes/api/{cms/locks → locks}/[...path].ts +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
import "virtual:kide/admin-css";
|
|
3
|
+
import { cms } from "virtual:kide/api";
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
+
ChevronDown,
|
|
6
7
|
Clock,
|
|
7
8
|
FileText,
|
|
8
9
|
FolderTree,
|
|
@@ -20,8 +21,10 @@ import {
|
|
|
20
21
|
Database,
|
|
21
22
|
Globe,
|
|
22
23
|
Home,
|
|
24
|
+
Inbox,
|
|
23
25
|
Key,
|
|
24
26
|
Link,
|
|
27
|
+
Link2,
|
|
25
28
|
Lock,
|
|
26
29
|
Mail,
|
|
27
30
|
MessageSquare,
|
|
@@ -48,10 +51,12 @@ const navIconMap: Record<string, any> = {
|
|
|
48
51
|
Globe,
|
|
49
52
|
Home,
|
|
50
53
|
Image,
|
|
54
|
+
Inbox,
|
|
51
55
|
Key,
|
|
52
56
|
Layers,
|
|
53
57
|
LayoutGrid,
|
|
54
58
|
Link,
|
|
59
|
+
Link2,
|
|
55
60
|
Lock,
|
|
56
61
|
Mail,
|
|
57
62
|
Menu,
|
|
@@ -69,10 +74,10 @@ const navIconMap: Record<string, any> = {
|
|
|
69
74
|
Zap,
|
|
70
75
|
};
|
|
71
76
|
|
|
77
|
+
import CommandPalette from "../components/CommandPalette";
|
|
72
78
|
import MobileSidebar from "../components/MobileSidebar";
|
|
73
79
|
import SidebarUserMenu from "../components/SidebarUserMenu";
|
|
74
80
|
import Toast from "../components/Toast.astro";
|
|
75
|
-
import { Separator } from "../components/ui/separator";
|
|
76
81
|
import { cn } from "../lib/utils";
|
|
77
82
|
|
|
78
83
|
const {
|
|
@@ -83,10 +88,15 @@ const {
|
|
|
83
88
|
customNav = [],
|
|
84
89
|
} = Astro.props as {
|
|
85
90
|
title?: string;
|
|
86
|
-
collections?: Array<{
|
|
91
|
+
collections?: Array<{
|
|
92
|
+
slug: string;
|
|
93
|
+
labels: { singular: string; plural: string };
|
|
94
|
+
singleton?: boolean;
|
|
95
|
+
admin?: CollectionNavConfig;
|
|
96
|
+
}>;
|
|
87
97
|
activeCollection?: string | null;
|
|
88
98
|
embed?: boolean;
|
|
89
|
-
customNav?: Array<{ label: string; href: string; icon?: string }>;
|
|
99
|
+
customNav?: Array<{ label: string; href: string; icon?: string; weight?: number }>;
|
|
90
100
|
};
|
|
91
101
|
|
|
92
102
|
const user = Astro.locals.user;
|
|
@@ -96,26 +106,77 @@ const toastStatus = Astro.url.searchParams.get("_toast") as "success" | "error"
|
|
|
96
106
|
const toastMessage =
|
|
97
107
|
Astro.url.searchParams.get("_msg") ?? (toastStatus === "success" ? "Saved successfully" : "Something went wrong");
|
|
98
108
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
109
|
+
type CollectionNavConfig = {
|
|
110
|
+
group?: string;
|
|
111
|
+
sidebar?: boolean;
|
|
112
|
+
icon?: string;
|
|
113
|
+
weight?: number;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
type CollectionNavEntry = {
|
|
117
|
+
slug: string;
|
|
118
|
+
labels: { singular: string; plural: string };
|
|
119
|
+
singleton?: boolean;
|
|
120
|
+
admin?: CollectionNavConfig;
|
|
121
|
+
};
|
|
104
122
|
|
|
105
|
-
const
|
|
106
|
-
const
|
|
123
|
+
const collectionEntries = collections as CollectionNavEntry[];
|
|
124
|
+
const librarySlugs = new Set(["shared-sections", "taxonomies", "menus", "forms", "authors"]);
|
|
107
125
|
const pinnedIcons: Record<string, any> = {
|
|
126
|
+
"shared-sections": Link2,
|
|
108
127
|
taxonomies: FolderTree,
|
|
109
128
|
menus: Menu,
|
|
129
|
+
forms: MessageSquare,
|
|
110
130
|
authors: PencilRuler,
|
|
111
131
|
users: Users,
|
|
112
132
|
};
|
|
113
133
|
|
|
114
|
-
|
|
115
|
-
|
|
134
|
+
// Unread submissions badge — shown next to "Forms" in the sidebar.
|
|
135
|
+
let unreadSubmissions = 0;
|
|
136
|
+
try {
|
|
137
|
+
const cmsAny = cms as Record<string, any>;
|
|
138
|
+
if (cmsAny["form-submissions"]) {
|
|
139
|
+
unreadSubmissions = await cmsAny["form-submissions"].count({ where: { status: "new" } }, { _system: true });
|
|
140
|
+
}
|
|
141
|
+
} catch {
|
|
142
|
+
// Table may not exist yet on first run — ignore.
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Collections that should never appear as a top-level sidebar entry.
|
|
146
|
+
const hiddenFromSidebar = new Set<string>();
|
|
147
|
+
|
|
148
|
+
const visibleCollections = collectionEntries.filter(
|
|
149
|
+
(c) => !hiddenFromSidebar.has(c.slug) && c.admin?.sidebar !== false,
|
|
150
|
+
);
|
|
151
|
+
const hasSingletons = visibleCollections.some((c) => c.singleton);
|
|
152
|
+
const singletonSlugs = new Set(visibleCollections.filter((c) => c.singleton).map((c) => c.slug));
|
|
116
153
|
const isActiveSingles =
|
|
117
154
|
activeCollection === "singles" || (activeCollection !== null && singletonSlugs.has(activeCollection));
|
|
118
155
|
|
|
156
|
+
const fallbackGroupFor = (collection: CollectionNavEntry) => {
|
|
157
|
+
if (collection.slug === "users") return "Team";
|
|
158
|
+
if (librarySlugs.has(collection.slug)) return "Library";
|
|
159
|
+
return "Content";
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const fallbackWeightFor = (collection: CollectionNavEntry) => {
|
|
163
|
+
if (collection.slug === "shared-sections") return 5;
|
|
164
|
+
if (collection.slug === "taxonomies") return 20;
|
|
165
|
+
if (collection.slug === "menus") return 30;
|
|
166
|
+
if (collection.slug === "forms") return 40;
|
|
167
|
+
if (collection.slug === "authors") return 50;
|
|
168
|
+
if (collection.slug === "users") return 10;
|
|
169
|
+
return 10;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const groupWeightFor = (group: string) => {
|
|
173
|
+
if (group === "Content") return 0;
|
|
174
|
+
if (group === "Library") return 10;
|
|
175
|
+
if (group === "Team") return 20;
|
|
176
|
+
if (group === "Custom") return 100;
|
|
177
|
+
return 50;
|
|
178
|
+
};
|
|
179
|
+
|
|
119
180
|
type NavItem = {
|
|
120
181
|
href: string;
|
|
121
182
|
label: string;
|
|
@@ -124,6 +185,8 @@ type NavItem = {
|
|
|
124
185
|
active: boolean;
|
|
125
186
|
newHref?: string;
|
|
126
187
|
weight: number;
|
|
188
|
+
group: string;
|
|
189
|
+
badge?: number;
|
|
127
190
|
};
|
|
128
191
|
const navItems: NavItem[] = [];
|
|
129
192
|
|
|
@@ -134,40 +197,35 @@ navItems.push({
|
|
|
134
197
|
Icon: Clock,
|
|
135
198
|
active: activeCollection === "recent",
|
|
136
199
|
weight: 0,
|
|
200
|
+
group: "Content",
|
|
137
201
|
});
|
|
138
202
|
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
for (const c of contentCollections) {
|
|
203
|
+
const navCollections = visibleCollections.filter((c) => !c.singleton);
|
|
204
|
+
for (const c of navCollections) {
|
|
205
|
+
const group = c.admin?.group ?? fallbackGroupFor(c);
|
|
143
206
|
navItems.push({
|
|
144
207
|
href: `/admin/${c.slug}`,
|
|
145
208
|
label: c.labels.plural,
|
|
146
209
|
singularLabel: c.labels.singular,
|
|
147
|
-
Icon: Layers,
|
|
210
|
+
Icon: c.admin?.icon ? (navIconMap[c.admin.icon] ?? LayoutGrid) : (pinnedIcons[c.slug] ?? Layers),
|
|
148
211
|
active: activeCollection === c.slug,
|
|
149
|
-
|
|
150
|
-
|
|
212
|
+
// Submissions are created by end users filling out forms, not added manually.
|
|
213
|
+
newHref: c.slug === "form-submissions" ? undefined : `/admin/${c.slug}/new`,
|
|
214
|
+
weight: c.admin?.weight ?? fallbackWeightFor(c),
|
|
215
|
+
group,
|
|
216
|
+
badge: c.slug === "form-submissions" && unreadSubmissions > 0 ? unreadSubmissions : undefined,
|
|
151
217
|
});
|
|
152
218
|
}
|
|
153
219
|
|
|
154
220
|
if (hasSingletons) {
|
|
155
|
-
navItems.push({
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
label: c.labels.plural,
|
|
164
|
-
singularLabel: c.labels.singular,
|
|
165
|
-
Icon: pinnedIcons[slug] ?? LayoutGrid,
|
|
166
|
-
active: activeCollection === c.slug,
|
|
167
|
-
newHref: `/admin/${c.slug}/new`,
|
|
168
|
-
weight: 30,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
221
|
+
navItems.push({
|
|
222
|
+
href: "/admin/singles",
|
|
223
|
+
label: "Singles",
|
|
224
|
+
Icon: FileText,
|
|
225
|
+
active: isActiveSingles,
|
|
226
|
+
weight: 20,
|
|
227
|
+
group: "Content",
|
|
228
|
+
});
|
|
171
229
|
}
|
|
172
230
|
|
|
173
231
|
navItems.push({
|
|
@@ -176,6 +234,7 @@ navItems.push({
|
|
|
176
234
|
Icon: Image,
|
|
177
235
|
active: activeCollection === "assets",
|
|
178
236
|
weight: 40,
|
|
237
|
+
group: "Library",
|
|
179
238
|
});
|
|
180
239
|
|
|
181
240
|
// Custom nav items from admin config
|
|
@@ -187,11 +246,23 @@ for (const item of customNav) {
|
|
|
187
246
|
Icon: navIconMap[item.icon ?? ""] ?? LayoutGrid,
|
|
188
247
|
active: currentPath === item.href || currentPath.startsWith(item.href + "/"),
|
|
189
248
|
weight: item.weight ?? 50,
|
|
249
|
+
group: "Custom",
|
|
190
250
|
});
|
|
191
251
|
}
|
|
192
252
|
|
|
193
253
|
// Sort all items by weight (stable sort preserves order within same weight)
|
|
194
|
-
navItems.sort(
|
|
254
|
+
navItems.sort(
|
|
255
|
+
(a, b) => groupWeightFor(a.group) - groupWeightFor(b.group) || a.weight - b.weight || a.label.localeCompare(b.label),
|
|
256
|
+
);
|
|
257
|
+
const navGroups = [...new Set(navItems.map((item) => item.group))]
|
|
258
|
+
.sort((a, b) => groupWeightFor(a) - groupWeightFor(b) || a.localeCompare(b))
|
|
259
|
+
.map((group) => {
|
|
260
|
+
const items = navItems.filter((item) => item.group === group);
|
|
261
|
+
const active = items.some((item) => item.active);
|
|
262
|
+
const collapsed = !active && !["Content", "Library", "Team"].includes(group);
|
|
263
|
+
return { group, items, active, collapsed };
|
|
264
|
+
})
|
|
265
|
+
.filter((entry) => entry.items.length > 0);
|
|
195
266
|
---
|
|
196
267
|
|
|
197
268
|
<!doctype html>
|
|
@@ -199,11 +270,8 @@ navItems.sort((a, b) => a.weight - b.weight);
|
|
|
199
270
|
<head>
|
|
200
271
|
<meta charset="utf-8" />
|
|
201
272
|
<meta name="viewport" content="width=device-width" />
|
|
202
|
-
<link
|
|
203
|
-
|
|
204
|
-
type="image/svg+xml"
|
|
205
|
-
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='85' height='107' viewBox='0 0 85 107' fill='none'%3E%3Cpath d='M27.5894 91.1365C22.7555 86.7178 21.3444 77.4335 23.3583 70.7072C26.8503 74.948 31.6888 76.2914 36.7005 77.0497C44.4375 78.2199 52.0359 77.7822 59.2232 74.2459C60.0454 73.841 60.8052 73.3027 61.7036 72.7574C62.378 74.714 62.5535 76.6892 62.318 78.6996C61.7452 83.5957 59.3086 87.3778 55.4332 90.2448C53.8835 91.3916 52.2437 92.4167 50.6432 93.4979C45.7262 96.8213 44.3959 100.718 46.2435 106.386C46.2874 106.525 46.3267 106.663 46.426 107C43.9155 105.876 42.0817 104.24 40.6845 102.089C39.2087 99.8193 38.5066 97.3081 38.4696 94.5909C38.4511 93.2686 38.4511 91.9345 38.2733 90.6309C37.8391 87.4527 36.3471 86.0297 33.5364 85.9478C30.6518 85.8636 28.37 87.6469 27.7649 90.4554C27.7187 90.6707 27.6517 90.8837 27.5847 91.1341L27.5894 91.1365Z' fill='white'/%3E%3Cpath d='M27.5894 91.1365C22.7555 86.7178 21.3444 77.4335 23.3583 70.7072C26.8503 74.948 31.6888 76.2914 36.7005 77.0497C44.4375 78.2199 52.0359 77.7822 59.2232 74.2459C60.0454 73.841 60.8052 73.3027 61.7036 72.7574C62.378 74.714 62.5535 76.6892 62.318 78.6996C61.7452 83.5957 59.3086 87.3778 55.4332 90.2448C53.8835 91.3916 52.2437 92.4167 50.6432 93.4979C45.7262 96.8213 44.3959 100.718 46.2435 106.386C46.2874 106.525 46.3267 106.663 46.426 107C43.9155 105.876 42.0817 104.24 40.6845 102.089C39.2087 99.8193 38.5066 97.3081 38.4696 94.5909C38.4511 93.2686 38.4511 91.9345 38.2733 90.6309C37.8391 87.4527 36.3471 86.0297 33.5364 85.9478C30.6518 85.8636 28.37 87.6469 27.7649 90.4554C27.7187 90.6707 27.6517 90.8837 27.5847 91.1341L27.5894 91.1365Z' fill='url(%23paint0_linear_1_59)'/%3E%3Cpath d='M0 69.5866C0 69.5866 14.3139 62.6137 28.6678 62.6137L39.4901 29.1204C39.8953 27.5007 41.0783 26.3999 42.4139 26.3999C43.7495 26.3999 44.9325 27.5007 45.3377 29.1204L56.1601 62.6137C73.1601 62.6137 84.8278 69.5866 84.8278 69.5866C84.8278 69.5866 60.5145 3.35233 60.467 3.21944C59.7692 1.2612 58.5911 0 57.0029 0H27.8274C26.2392 0 25.1087 1.2612 24.3634 3.21944C24.3108 3.34983 0 69.5866 0 69.5866Z' fill='white'/%3E%3Cdefs%3E%3ClinearGradient id='paint0_linear_1_59' x1='22.4702' y1='107' x2='69.1451' y2='84.9468' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%23D83333'/%3E%3Cstop offset='1' stop-color='%23F041FF'/%3E%3C/linearGradient%3E%3C/defs%3E%3C/svg%3E"
|
|
206
|
-
/>
|
|
273
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
274
|
+
<link rel="icon" href="/favicon.ico" />
|
|
207
275
|
<title>{title}</title>
|
|
208
276
|
<script is:inline>
|
|
209
277
|
if (!document.cookie.includes("tz="))
|
|
@@ -216,8 +284,47 @@ navItems.sort((a, b) => a.weight - b.weight);
|
|
|
216
284
|
if (dark) document.documentElement.classList.add("dark");
|
|
217
285
|
})();
|
|
218
286
|
</script>
|
|
287
|
+
{
|
|
288
|
+
/* No-flash: if a content field was in fullscreen before a save reload, cover the
|
|
289
|
+
chrome until the editor re-enters fullscreen (see ContentEditor restore logic). */
|
|
290
|
+
}
|
|
291
|
+
<style is:global>
|
|
292
|
+
html.cms-fullscreen-restoring::before {
|
|
293
|
+
content: "";
|
|
294
|
+
position: fixed;
|
|
295
|
+
inset: 0;
|
|
296
|
+
background: var(--background);
|
|
297
|
+
z-index: 45;
|
|
298
|
+
}
|
|
299
|
+
</style>
|
|
300
|
+
<script is:inline>
|
|
301
|
+
(function () {
|
|
302
|
+
try {
|
|
303
|
+
var prefix = "cms-content-fullscreen:";
|
|
304
|
+
var path = location.pathname;
|
|
305
|
+
for (var i = 0; i < sessionStorage.length; i++) {
|
|
306
|
+
var k = sessionStorage.key(i);
|
|
307
|
+
if (
|
|
308
|
+
k &&
|
|
309
|
+
k.indexOf(prefix) === 0 &&
|
|
310
|
+
sessionStorage.getItem(k) === "1" &&
|
|
311
|
+
k.slice(prefix.length).indexOf(path + ":") === 0
|
|
312
|
+
) {
|
|
313
|
+
var root = document.documentElement;
|
|
314
|
+
root.classList.add("cms-fullscreen-restoring");
|
|
315
|
+
// Safety net: never leave the cover up if the editor fails to mount.
|
|
316
|
+
setTimeout(function () {
|
|
317
|
+
root.classList.remove("cms-fullscreen-restoring");
|
|
318
|
+
}, 1500);
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
} catch (e) {}
|
|
323
|
+
})();
|
|
324
|
+
</script>
|
|
219
325
|
</head>
|
|
220
326
|
<body class="bg-background text-foreground min-h-screen antialiased">
|
|
327
|
+
<CommandPalette client:load />
|
|
221
328
|
{
|
|
222
329
|
embed ? (
|
|
223
330
|
<main class="mx-auto w-full px-4 py-6 lg:px-8 lg:py-8">
|
|
@@ -230,78 +337,39 @@ navItems.sort((a, b) => a.weight - b.weight);
|
|
|
230
337
|
>
|
|
231
338
|
{/* ── Desktop sidebar ──────────────────────────────────────────── */}
|
|
232
339
|
<aside class="bg-sidebar/40 sticky top-0 mt-1 hidden h-screen overflow-hidden border-r backdrop-blur transition-transform duration-150 ease-in-out lg:flex lg:flex-col">
|
|
233
|
-
<div class="px-3 pt-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
/>
|
|
241
|
-
)}
|
|
242
|
-
</div>
|
|
243
|
-
|
|
244
|
-
<nav class="flex-1 space-y-1 overflow-y-auto px-3 py-3">
|
|
245
|
-
{navItems.map((item) => (
|
|
246
|
-
<div
|
|
247
|
-
class={cn(
|
|
248
|
-
"group relative rounded-lg",
|
|
249
|
-
item.active ? "bg-foreground/10 dark:bg-accent" : "hover:bg-foreground/5 dark:hover:bg-accent/60",
|
|
250
|
-
)}
|
|
251
|
-
>
|
|
252
|
-
<a
|
|
253
|
-
href={item.href}
|
|
254
|
-
class={cn(
|
|
255
|
-
"flex items-center gap-3 px-3 py-2.5 text-sm",
|
|
256
|
-
item.newHref && "pr-8",
|
|
257
|
-
item.active ? "text-accent-foreground" : "text-foreground/70 group-hover:text-foreground",
|
|
258
|
-
)}
|
|
259
|
-
>
|
|
260
|
-
<item.Icon className="size-4 shrink-0 stroke-1" />
|
|
261
|
-
<span>{item.label}</span>
|
|
262
|
-
</a>
|
|
263
|
-
{item.newHref && (
|
|
264
|
-
<a
|
|
265
|
-
href={item.newHref}
|
|
266
|
-
title={`Add new ${(item.singularLabel ?? item.label).toLowerCase()}`}
|
|
267
|
-
class="text-foreground/40 hover:text-foreground/70 absolute top-1/2 right-1.5 hidden -translate-y-1/2 rounded p-1 group-hover:block"
|
|
268
|
-
>
|
|
269
|
-
<Plus className="size-3.5" />
|
|
270
|
-
</a>
|
|
271
|
-
)}
|
|
272
|
-
</div>
|
|
273
|
-
))}
|
|
274
|
-
</nav>
|
|
275
|
-
<div class="border-t px-3 pt-2.5 pb-3">
|
|
276
|
-
<a
|
|
277
|
-
href="/"
|
|
278
|
-
target="_blank"
|
|
279
|
-
class="text-foreground/70 hover:text-foreground hover:bg-foreground/5 dark:hover:bg-accent/60 flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm"
|
|
340
|
+
<div class="px-3 pt-4 pb-1">
|
|
341
|
+
<button
|
|
342
|
+
type="button"
|
|
343
|
+
data-cms-search-trigger
|
|
344
|
+
data-slot="button"
|
|
345
|
+
class="bg-background/60 hover:bg-background border-input text-muted-foreground hover:text-foreground/90 flex w-full items-center gap-2 rounded-md border px-3 py-2 text-sm transition-colors hover:cursor-text"
|
|
346
|
+
aria-label="Search content"
|
|
280
347
|
>
|
|
281
|
-
<
|
|
282
|
-
<span>
|
|
283
|
-
|
|
348
|
+
<Search className="size-4 shrink-0 stroke-1" />
|
|
349
|
+
<span class="flex-1 text-left">Search…</span>
|
|
350
|
+
<kbd
|
|
351
|
+
data-cms-search-kbd
|
|
352
|
+
class="text-foreground/45 inline-flex items-center gap-1 rounded border px-1.5 py-0.5 font-sans text-[12px] leading-none font-medium"
|
|
353
|
+
>
|
|
354
|
+
<span class="text-[13px] leading-none">⌘</span>
|
|
355
|
+
<span>K</span>
|
|
356
|
+
</kbd>
|
|
357
|
+
</button>
|
|
284
358
|
</div>
|
|
285
|
-
</aside>
|
|
286
359
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
{
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
)
|
|
300
|
-
<Separator className="mt-3" />
|
|
301
|
-
</div>
|
|
302
|
-
|
|
303
|
-
<nav class="flex-1 space-y-1 overflow-y-auto px-3 py-3">
|
|
304
|
-
{navItems.map((item) => (
|
|
360
|
+
<nav class="flex-1 space-y-2 overflow-y-auto px-3 py-3">
|
|
361
|
+
{navGroups.map(({ group, items, active, collapsed }) => (
|
|
362
|
+
<details
|
|
363
|
+
class="group/nav-section space-y-1"
|
|
364
|
+
data-nav-group={group}
|
|
365
|
+
data-active={active ? "true" : "false"}
|
|
366
|
+
open={!collapsed}
|
|
367
|
+
>
|
|
368
|
+
<summary class="text-muted-foreground/80 hover:text-foreground flex cursor-pointer list-none items-center justify-between rounded-md px-3 py-1 text-[11px] font-medium tracking-wide uppercase transition-colors marker:hidden [&::-webkit-details-marker]:hidden">
|
|
369
|
+
<span>{group}</span>
|
|
370
|
+
<ChevronDown className="size-3.5 transition-transform group-open/nav-section:rotate-180" />
|
|
371
|
+
</summary>
|
|
372
|
+
{items.map((item) => (
|
|
305
373
|
<div
|
|
306
374
|
class={cn(
|
|
307
375
|
"group relative rounded-lg",
|
|
@@ -313,13 +381,18 @@ navItems.sort((a, b) => a.weight - b.weight);
|
|
|
313
381
|
<a
|
|
314
382
|
href={item.href}
|
|
315
383
|
class={cn(
|
|
316
|
-
"flex items-center gap-3 px-3 py-
|
|
384
|
+
"flex items-center gap-3 rounded-lg px-3 py-1.5 text-sm",
|
|
317
385
|
item.newHref && "pr-8",
|
|
318
386
|
item.active ? "text-accent-foreground" : "text-foreground/70 group-hover:text-foreground",
|
|
319
387
|
)}
|
|
320
388
|
>
|
|
321
389
|
<item.Icon className="size-4 shrink-0 stroke-1" />
|
|
322
|
-
<span>{item.label}</span>
|
|
390
|
+
<span class="flex-1">{item.label}</span>
|
|
391
|
+
{item.badge ? (
|
|
392
|
+
<span class="text-muted-foreground/80 text-xs tabular-nums">
|
|
393
|
+
{item.badge > 99 ? "99+" : item.badge} new
|
|
394
|
+
</span>
|
|
395
|
+
) : null}
|
|
323
396
|
</a>
|
|
324
397
|
{item.newHref && (
|
|
325
398
|
<a
|
|
@@ -332,21 +405,103 @@ navItems.sort((a, b) => a.weight - b.weight);
|
|
|
332
405
|
)}
|
|
333
406
|
</div>
|
|
334
407
|
))}
|
|
335
|
-
</
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
408
|
+
</details>
|
|
409
|
+
))}
|
|
410
|
+
</nav>
|
|
411
|
+
<div class="border-t px-3 pt-2 pb-2">
|
|
412
|
+
{user && (
|
|
413
|
+
<SidebarUserMenu
|
|
414
|
+
client:load
|
|
415
|
+
userName={user.name}
|
|
416
|
+
userEmail={user.email}
|
|
417
|
+
logoutAction="/api/cms/auth/logout"
|
|
418
|
+
/>
|
|
419
|
+
)}
|
|
420
|
+
</div>
|
|
421
|
+
</aside>
|
|
422
|
+
|
|
423
|
+
<div class="min-w-0">
|
|
424
|
+
{/* ── Mobile header ────────────────────────────────────────── */}
|
|
425
|
+
<header class="bg-background/95 supports-backdrop-filter:bg-background/75 flex items-center gap-3 border-b px-4 py-3 backdrop-blur lg:hidden">
|
|
426
|
+
<MobileSidebar client:load>
|
|
427
|
+
<div class="px-3 pt-4 pb-1">
|
|
428
|
+
<button
|
|
429
|
+
type="button"
|
|
430
|
+
data-cms-search-trigger
|
|
431
|
+
data-slot="button"
|
|
432
|
+
class="bg-background/60 hover:bg-background border-input text-muted-foreground hover:text-foreground flex w-full items-center gap-2 rounded-md border px-3 py-2 text-sm transition-colors"
|
|
433
|
+
aria-label="Search content"
|
|
341
434
|
>
|
|
342
|
-
<
|
|
343
|
-
<span>
|
|
344
|
-
</
|
|
435
|
+
<Search className="size-4 shrink-0 stroke-1" />
|
|
436
|
+
<span class="flex-1 text-left">Search…</span>
|
|
437
|
+
</button>
|
|
438
|
+
</div>
|
|
439
|
+
|
|
440
|
+
<nav class="flex-1 space-y-2 overflow-y-auto px-3 py-3">
|
|
441
|
+
{navGroups.map(({ group, items, active, collapsed }) => (
|
|
442
|
+
<details
|
|
443
|
+
class="group/nav-section space-y-1"
|
|
444
|
+
data-nav-group={group}
|
|
445
|
+
data-active={active ? "true" : "false"}
|
|
446
|
+
open={!collapsed}
|
|
447
|
+
>
|
|
448
|
+
<summary class="text-muted-foreground/70 hover:text-foreground flex cursor-pointer list-none items-center justify-between rounded-md px-3 py-1 text-[11px] font-medium tracking-wide uppercase transition-colors marker:hidden [&::-webkit-details-marker]:hidden">
|
|
449
|
+
<span>{group}</span>
|
|
450
|
+
<ChevronDown className="size-3 transition-transform group-open/nav-section:rotate-180" />
|
|
451
|
+
</summary>
|
|
452
|
+
{items.map((item) => (
|
|
453
|
+
<div
|
|
454
|
+
class={cn(
|
|
455
|
+
"group relative rounded-lg",
|
|
456
|
+
item.active
|
|
457
|
+
? "bg-foreground/10 dark:bg-accent"
|
|
458
|
+
: "hover:bg-foreground/5 dark:hover:bg-accent/60",
|
|
459
|
+
)}
|
|
460
|
+
>
|
|
461
|
+
<a
|
|
462
|
+
href={item.href}
|
|
463
|
+
class={cn(
|
|
464
|
+
"flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm",
|
|
465
|
+
item.newHref && "pr-8",
|
|
466
|
+
item.active ? "text-accent-foreground" : "text-foreground/70 group-hover:text-foreground",
|
|
467
|
+
)}
|
|
468
|
+
>
|
|
469
|
+
<item.Icon className="size-4 shrink-0 stroke-1" />
|
|
470
|
+
<span class="flex-1">{item.label}</span>
|
|
471
|
+
{item.badge ? (
|
|
472
|
+
<span class="text-muted-foreground/80 text-xs tabular-nums">
|
|
473
|
+
{item.badge > 99 ? "99+" : item.badge} new
|
|
474
|
+
</span>
|
|
475
|
+
) : null}
|
|
476
|
+
</a>
|
|
477
|
+
{item.newHref && (
|
|
478
|
+
<a
|
|
479
|
+
href={item.newHref}
|
|
480
|
+
title={`Add new ${(item.singularLabel ?? item.label).toLowerCase()}`}
|
|
481
|
+
class="text-foreground/40 hover:text-foreground/70 absolute top-1/2 right-1.5 hidden -translate-y-1/2 rounded p-1 group-hover:block"
|
|
482
|
+
>
|
|
483
|
+
<Plus className="size-3.5" />
|
|
484
|
+
</a>
|
|
485
|
+
)}
|
|
486
|
+
</div>
|
|
487
|
+
))}
|
|
488
|
+
</details>
|
|
489
|
+
))}
|
|
490
|
+
</nav>
|
|
491
|
+
<div class="border-t px-3 py-2">
|
|
492
|
+
{user && (
|
|
493
|
+
<SidebarUserMenu
|
|
494
|
+
client:load
|
|
495
|
+
userName={user.name}
|
|
496
|
+
userEmail={user.email}
|
|
497
|
+
logoutAction="/api/cms/auth/logout"
|
|
498
|
+
/>
|
|
499
|
+
)}
|
|
345
500
|
</div>
|
|
346
501
|
</MobileSidebar>
|
|
347
502
|
</header>
|
|
348
503
|
|
|
349
|
-
<main class="mx-auto w-full max-w-[1900px]
|
|
504
|
+
<main class="mx-auto w-full max-w-[1900px]">
|
|
350
505
|
<slot />
|
|
351
506
|
</main>
|
|
352
507
|
</div>
|
|
@@ -356,6 +511,51 @@ navItems.sort((a, b) => a.weight - b.weight);
|
|
|
356
511
|
|
|
357
512
|
{toastStatus && <Toast status={toastStatus} message={toastMessage} />}
|
|
358
513
|
|
|
514
|
+
{/* Persist collapsible sidebar groups locally. Active groups always open. */}
|
|
515
|
+
<script is:inline>
|
|
516
|
+
(function () {
|
|
517
|
+
var prefix = "cms-sidebar-group:";
|
|
518
|
+
document.querySelectorAll("details[data-nav-group]").forEach(function (el) {
|
|
519
|
+
var group = el.getAttribute("data-nav-group");
|
|
520
|
+
if (!group) return;
|
|
521
|
+
if (el.getAttribute("data-active") === "true") {
|
|
522
|
+
el.open = true;
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
var stored = localStorage.getItem(prefix + group);
|
|
526
|
+
if (stored === "open") el.open = true;
|
|
527
|
+
if (stored === "closed") el.open = false;
|
|
528
|
+
});
|
|
529
|
+
document.addEventListener(
|
|
530
|
+
"toggle",
|
|
531
|
+
function (e) {
|
|
532
|
+
var el = e.target instanceof HTMLDetailsElement ? e.target : null;
|
|
533
|
+
if (!el || !el.matches("details[data-nav-group]")) return;
|
|
534
|
+
var group = el.getAttribute("data-nav-group");
|
|
535
|
+
if (!group) return;
|
|
536
|
+
localStorage.setItem(prefix + group, el.open ? "open" : "closed");
|
|
537
|
+
},
|
|
538
|
+
true,
|
|
539
|
+
);
|
|
540
|
+
})();
|
|
541
|
+
</script>
|
|
542
|
+
|
|
543
|
+
{/* Wire sidebar search triggers to the CommandPalette */}
|
|
544
|
+
<script is:inline>
|
|
545
|
+
(function () {
|
|
546
|
+
document.addEventListener("click", function (e) {
|
|
547
|
+
var t = e.target instanceof Element ? e.target.closest("[data-cms-search-trigger]") : null;
|
|
548
|
+
if (t) window.dispatchEvent(new Event("cms:open-search"));
|
|
549
|
+
});
|
|
550
|
+
var isMac = /Mac|iPhone|iPad|iPod/i.test(navigator.userAgent || "");
|
|
551
|
+
if (!isMac) {
|
|
552
|
+
document.querySelectorAll("[data-cms-search-kbd]").forEach(function (el) {
|
|
553
|
+
el.textContent = "Ctrl+K";
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
})();
|
|
557
|
+
</script>
|
|
558
|
+
|
|
359
559
|
{/* Clean toast params from URL and remove toast element after animation */}
|
|
360
560
|
<script is:inline>
|
|
361
561
|
(function () {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { CMSConfig } from "../../core";
|
|
2
|
+
|
|
3
|
+
type User = { id: string; role?: string; email?: string } | null | undefined;
|
|
4
|
+
|
|
5
|
+
export function canRead(config: CMSConfig, user: User, slug: string): boolean {
|
|
6
|
+
const c = config.collections.find((col) => col.slug === slug);
|
|
7
|
+
const rule = c?.access?.read;
|
|
8
|
+
// Mirrors the auth-collection defaults in core/api.ts: non-admins reach their own
|
|
9
|
+
// row only, so the list still opens (filtered to themselves) rather than vanishing.
|
|
10
|
+
if (!rule) return c?.auth ? !!user : true;
|
|
11
|
+
// Access rules are synchronous in practice; cast to unwrap the boolean | Promise<boolean> return type.
|
|
12
|
+
return rule({ user: user ?? null, doc: null, operation: "read", collection: slug }) as boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function canWrite(config: CMSConfig, user: User, slug: string): boolean {
|
|
16
|
+
const c = config.collections.find((col) => col.slug === slug);
|
|
17
|
+
const rule = c?.access?.create;
|
|
18
|
+
if (!rule) return c?.auth ? user?.role === "admin" : true;
|
|
19
|
+
return rule({ user: user ?? null, doc: null, operation: "create", collection: slug }) as boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function isFieldHidden(
|
|
23
|
+
collection: { slug: string; fields: Record<string, any> } | null,
|
|
24
|
+
user: User,
|
|
25
|
+
fieldName: string,
|
|
26
|
+
): boolean {
|
|
27
|
+
if (!collection) return false;
|
|
28
|
+
const field = collection.fields[fieldName];
|
|
29
|
+
if (!field?.access?.read) return false;
|
|
30
|
+
return !field.access.read({ user: user ?? null, doc: null, operation: "read", collection: collection.slug });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function isFieldReadOnly(
|
|
34
|
+
collection: { slug: string; fields: Record<string, any> } | null,
|
|
35
|
+
user: User,
|
|
36
|
+
fieldName: string,
|
|
37
|
+
): boolean {
|
|
38
|
+
if (!collection) return false;
|
|
39
|
+
const field = collection.fields[fieldName];
|
|
40
|
+
if (!field?.access?.update) return false;
|
|
41
|
+
return !field.access.update({ user: user ?? null, doc: null, operation: "update", collection: collection.slug });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function getVisualStatus(d: Record<string, unknown>): string {
|
|
45
|
+
const status = String(d._status ?? "draft");
|
|
46
|
+
if (status === "scheduled") return "scheduled";
|
|
47
|
+
if (status === "published" && d._published) return "changed";
|
|
48
|
+
return status;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function getFormAction(collectionSlug: string, documentId?: string): string {
|
|
52
|
+
if (collectionSlug === "users" && !documentId) return "/api/cms/auth/invite";
|
|
53
|
+
return documentId ? `/api/cms/${collectionSlug}/${documentId}` : `/api/cms/${collectionSlug}`;
|
|
54
|
+
}
|