@jant/core 0.3.25 → 0.3.26
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/app.js +67 -562
- package/dist/client.js +1 -0
- package/dist/i18n/locales/en.js +1 -1
- package/dist/i18n/locales/zh-Hans.js +1 -1
- package/dist/i18n/locales/zh-Hant.js +1 -1
- package/dist/lib/avatar-upload.js +134 -0
- package/dist/lib/config.js +39 -0
- package/dist/lib/constants.js +10 -10
- package/dist/lib/favicon.js +102 -0
- package/dist/lib/image.js +13 -17
- package/dist/lib/media-helpers.js +2 -2
- package/dist/lib/navigation.js +23 -3
- package/dist/lib/render.js +10 -1
- package/dist/lib/schemas.js +31 -0
- package/dist/lib/timezones.js +388 -0
- package/dist/lib/view.js +1 -1
- package/dist/routes/api/posts.js +1 -1
- package/dist/routes/api/upload.js +3 -3
- package/dist/routes/auth/reset.js +221 -0
- package/dist/routes/auth/setup.js +194 -0
- package/dist/routes/auth/signin.js +176 -0
- package/dist/routes/dash/collections.js +23 -415
- package/dist/routes/dash/media.js +12 -392
- package/dist/routes/dash/pages.js +7 -330
- package/dist/routes/dash/redirects.js +18 -12
- package/dist/routes/dash/settings.js +198 -577
- package/dist/routes/feed/rss.js +2 -1
- package/dist/routes/feed/sitemap.js +4 -2
- package/dist/routes/pages/featured.js +5 -1
- package/dist/routes/pages/home.js +26 -1
- package/dist/routes/pages/latest.js +45 -0
- package/dist/services/post.js +30 -50
- package/dist/types/bindings.js +3 -0
- package/dist/types/config.js +147 -0
- package/dist/types/constants.js +27 -0
- package/dist/types/entities.js +3 -0
- package/dist/types/operations.js +3 -0
- package/dist/types/props.js +3 -0
- package/dist/types/views.js +5 -0
- package/dist/types.js +8 -111
- package/dist/ui/color-themes.js +33 -33
- package/dist/ui/compose/ComposeDialog.js +36 -21
- package/dist/ui/dash/PageForm.js +21 -15
- package/dist/ui/dash/PostForm.js +22 -16
- package/dist/ui/dash/collections/CollectionForm.js +152 -0
- package/dist/ui/dash/collections/CollectionsListContent.js +68 -0
- package/dist/ui/dash/collections/ViewCollectionContent.js +96 -0
- package/dist/ui/dash/media/MediaListContent.js +166 -0
- package/dist/ui/dash/media/ViewMediaContent.js +212 -0
- package/dist/ui/dash/pages/LinkFormContent.js +130 -0
- package/dist/ui/dash/pages/UnifiedPagesContent.js +193 -0
- package/dist/ui/dash/settings/AccountContent.js +209 -0
- package/dist/ui/dash/settings/AppearanceContent.js +259 -0
- package/dist/ui/dash/settings/GeneralContent.js +536 -0
- package/dist/ui/dash/settings/SettingsNav.js +41 -0
- package/dist/ui/font-themes.js +36 -0
- package/dist/ui/layouts/BaseLayout.js +24 -2
- package/dist/ui/layouts/SiteLayout.js +47 -19
- package/package.json +1 -1
- package/src/app.tsx +93 -553
- package/src/client.ts +1 -0
- package/src/i18n/locales/en.po +240 -175
- package/src/i18n/locales/en.ts +1 -1
- package/src/i18n/locales/zh-Hans.po +240 -175
- package/src/i18n/locales/zh-Hans.ts +1 -1
- package/src/i18n/locales/zh-Hant.po +240 -175
- package/src/i18n/locales/zh-Hant.ts +1 -1
- package/src/lib/__tests__/config.test.ts +192 -0
- package/src/lib/__tests__/favicon.test.ts +151 -0
- package/src/lib/__tests__/image.test.ts +2 -6
- package/src/lib/__tests__/timezones.test.ts +61 -0
- package/src/lib/__tests__/view.test.ts +2 -2
- package/src/lib/avatar-upload.ts +165 -0
- package/src/lib/config.ts +47 -0
- package/src/lib/constants.ts +19 -11
- package/src/lib/favicon.ts +115 -0
- package/src/lib/image.ts +13 -21
- package/src/lib/media-helpers.ts +2 -2
- package/src/lib/navigation.ts +33 -2
- package/src/lib/render.tsx +15 -1
- package/src/lib/schemas.ts +39 -0
- package/src/lib/timezones.ts +325 -0
- package/src/lib/view.ts +1 -1
- package/src/routes/api/posts.ts +1 -1
- package/src/routes/api/upload.ts +2 -3
- package/src/routes/auth/reset.tsx +239 -0
- package/src/routes/auth/setup.tsx +189 -0
- package/src/routes/auth/signin.tsx +163 -0
- package/src/routes/dash/__tests__/settings-avatar.test.ts +89 -0
- package/src/routes/dash/collections.tsx +17 -366
- package/src/routes/dash/media.tsx +12 -414
- package/src/routes/dash/pages.tsx +8 -348
- package/src/routes/dash/redirects.tsx +20 -14
- package/src/routes/dash/settings.tsx +243 -534
- package/src/routes/feed/__tests__/rss.test.ts +141 -0
- package/src/routes/feed/rss.ts +3 -1
- package/src/routes/feed/sitemap.ts +4 -2
- package/src/routes/pages/featured.tsx +7 -1
- package/src/routes/pages/home.tsx +25 -2
- package/src/routes/pages/latest.tsx +59 -0
- package/src/services/post.ts +34 -66
- package/src/styles/components.css +0 -65
- package/src/styles/tokens.css +1 -1
- package/src/styles/ui.css +24 -40
- package/src/types/bindings.ts +30 -0
- package/src/types/config.ts +183 -0
- package/src/types/constants.ts +26 -0
- package/src/types/entities.ts +109 -0
- package/src/types/operations.ts +88 -0
- package/src/types/props.ts +115 -0
- package/src/types/views.ts +172 -0
- package/src/types.ts +8 -644
- package/src/ui/__tests__/font-themes.test.ts +34 -0
- package/src/ui/color-themes.ts +34 -34
- package/src/ui/compose/ComposeDialog.tsx +40 -21
- package/src/ui/dash/PageForm.tsx +25 -19
- package/src/ui/dash/PostForm.tsx +26 -20
- package/src/ui/dash/collections/CollectionForm.tsx +153 -0
- package/src/ui/dash/collections/CollectionsListContent.tsx +85 -0
- package/src/ui/dash/collections/ViewCollectionContent.tsx +92 -0
- package/src/ui/dash/media/MediaListContent.tsx +201 -0
- package/src/ui/dash/media/ViewMediaContent.tsx +208 -0
- package/src/ui/dash/pages/LinkFormContent.tsx +119 -0
- package/src/ui/dash/pages/UnifiedPagesContent.tsx +203 -0
- package/src/ui/dash/settings/AccountContent.tsx +176 -0
- package/src/ui/dash/settings/AppearanceContent.tsx +254 -0
- package/src/ui/dash/settings/GeneralContent.tsx +533 -0
- package/src/ui/dash/settings/SettingsNav.tsx +56 -0
- package/src/ui/font-themes.ts +54 -0
- package/src/ui/layouts/BaseLayout.tsx +17 -0
- package/src/ui/layouts/SiteLayout.tsx +45 -31
|
@@ -1,417 +1,16 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
-
import { getSiteName } from "../../lib/config.js";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "hono/jsx/jsx-runtime";
|
|
3
2
|
/**
|
|
4
3
|
* Dashboard Collections Routes
|
|
5
4
|
*/ import { Hono } from "hono";
|
|
6
|
-
import { useLingui as $_useLingui } from "@jant/core/i18n";
|
|
7
5
|
import { DashLayout } from "../../ui/layouts/DashLayout.js";
|
|
8
|
-
import {
|
|
9
|
-
import * as sqid from "../../lib/sqid.js";
|
|
6
|
+
import { DangerZone } from "../../ui/dash/index.js";
|
|
10
7
|
import { dsRedirect } from "../../lib/sse.js";
|
|
8
|
+
import { getSiteName } from "../../lib/config.js";
|
|
9
|
+
import { createMediaContext, toPostViewsFromPosts } from "../../lib/view.js";
|
|
10
|
+
import { CollectionsListContent } from "../../ui/dash/collections/CollectionsListContent.js";
|
|
11
|
+
import { CollectionForm } from "../../ui/dash/collections/CollectionForm.js";
|
|
12
|
+
import { ViewCollectionContent } from "../../ui/dash/collections/ViewCollectionContent.js";
|
|
11
13
|
export const collectionsRoutes = new Hono();
|
|
12
|
-
function CollectionsListContent({ collections }) {
|
|
13
|
-
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
14
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
15
|
-
children: [
|
|
16
|
-
/*#__PURE__*/ _jsx(CrudPageHeader, {
|
|
17
|
-
title: $__i18n._({
|
|
18
|
-
id: "DoJzLz",
|
|
19
|
-
message: "Collections"
|
|
20
|
-
}),
|
|
21
|
-
ctaLabel: $__i18n._({
|
|
22
|
-
id: "vzU4k9",
|
|
23
|
-
message: "New Collection"
|
|
24
|
-
}),
|
|
25
|
-
ctaHref: "/dash/collections/new"
|
|
26
|
-
}),
|
|
27
|
-
collections.length === 0 ? /*#__PURE__*/ _jsx(EmptyState, {
|
|
28
|
-
message: $__i18n._({
|
|
29
|
-
id: "+MACwa",
|
|
30
|
-
message: "No collections yet."
|
|
31
|
-
}),
|
|
32
|
-
ctaText: $__i18n._({
|
|
33
|
-
id: "vzU4k9",
|
|
34
|
-
message: "New Collection"
|
|
35
|
-
}),
|
|
36
|
-
ctaHref: "/dash/collections/new"
|
|
37
|
-
}) : /*#__PURE__*/ _jsx("div", {
|
|
38
|
-
class: "flex flex-col divide-y",
|
|
39
|
-
children: collections.map((col)=>/*#__PURE__*/ _jsxs(ListItemRow, {
|
|
40
|
-
actions: /*#__PURE__*/ _jsx(ActionButtons, {
|
|
41
|
-
editHref: `/dash/collections/${col.id}/edit`,
|
|
42
|
-
editLabel: $__i18n._({
|
|
43
|
-
id: "ePK91l",
|
|
44
|
-
message: "Edit"
|
|
45
|
-
}),
|
|
46
|
-
viewHref: `/c/${col.slug}`,
|
|
47
|
-
viewLabel: $__i18n._({
|
|
48
|
-
id: "jpctdh",
|
|
49
|
-
message: "View"
|
|
50
|
-
})
|
|
51
|
-
}),
|
|
52
|
-
children: [
|
|
53
|
-
/*#__PURE__*/ _jsx("a", {
|
|
54
|
-
href: `/dash/collections/${col.id}`,
|
|
55
|
-
class: "font-medium hover:underline",
|
|
56
|
-
children: col.title
|
|
57
|
-
}),
|
|
58
|
-
/*#__PURE__*/ _jsxs("p", {
|
|
59
|
-
class: "text-sm text-muted-foreground",
|
|
60
|
-
children: [
|
|
61
|
-
"/",
|
|
62
|
-
col.slug
|
|
63
|
-
]
|
|
64
|
-
}),
|
|
65
|
-
col.description && /*#__PURE__*/ _jsx("p", {
|
|
66
|
-
class: "text-sm text-muted-foreground mt-1",
|
|
67
|
-
children: col.description
|
|
68
|
-
})
|
|
69
|
-
]
|
|
70
|
-
}, col.id))
|
|
71
|
-
})
|
|
72
|
-
]
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
function NewCollectionContent() {
|
|
76
|
-
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
77
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
78
|
-
children: [
|
|
79
|
-
/*#__PURE__*/ _jsx("h1", {
|
|
80
|
-
class: "text-2xl font-semibold mb-6",
|
|
81
|
-
children: $__i18n._({
|
|
82
|
-
id: "vzU4k9",
|
|
83
|
-
message: "New Collection"
|
|
84
|
-
})
|
|
85
|
-
}),
|
|
86
|
-
/*#__PURE__*/ _jsxs("form", {
|
|
87
|
-
"data-signals": "{title: '', slug: '', description: ''}",
|
|
88
|
-
"data-on:submit__prevent": "@post('/dash/collections')",
|
|
89
|
-
"data-indicator": "_loading",
|
|
90
|
-
class: "flex flex-col gap-4 max-w-lg",
|
|
91
|
-
children: [
|
|
92
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
93
|
-
class: "field",
|
|
94
|
-
children: [
|
|
95
|
-
/*#__PURE__*/ _jsx("label", {
|
|
96
|
-
class: "label",
|
|
97
|
-
children: $__i18n._({
|
|
98
|
-
id: "MHrjPM",
|
|
99
|
-
message: "Title"
|
|
100
|
-
})
|
|
101
|
-
}),
|
|
102
|
-
/*#__PURE__*/ _jsx("input", {
|
|
103
|
-
type: "text",
|
|
104
|
-
"data-bind": "title",
|
|
105
|
-
class: "input",
|
|
106
|
-
required: true,
|
|
107
|
-
placeholder: $__i18n._({
|
|
108
|
-
id: "fttd2R",
|
|
109
|
-
message: "My Collection"
|
|
110
|
-
})
|
|
111
|
-
})
|
|
112
|
-
]
|
|
113
|
-
}),
|
|
114
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
115
|
-
class: "field",
|
|
116
|
-
children: [
|
|
117
|
-
/*#__PURE__*/ _jsx("label", {
|
|
118
|
-
class: "label",
|
|
119
|
-
children: $__i18n._({
|
|
120
|
-
id: "L85WcV",
|
|
121
|
-
message: "Slug"
|
|
122
|
-
})
|
|
123
|
-
}),
|
|
124
|
-
/*#__PURE__*/ _jsx("input", {
|
|
125
|
-
type: "text",
|
|
126
|
-
"data-bind": "slug",
|
|
127
|
-
class: "input",
|
|
128
|
-
required: true,
|
|
129
|
-
placeholder: "my-collection",
|
|
130
|
-
pattern: "[a-z0-9-]+"
|
|
131
|
-
}),
|
|
132
|
-
/*#__PURE__*/ _jsx("p", {
|
|
133
|
-
class: "text-xs text-muted-foreground mt-1",
|
|
134
|
-
children: $__i18n._({
|
|
135
|
-
id: "1CU1Td",
|
|
136
|
-
message: "URL-safe identifier (lowercase, numbers, hyphens)"
|
|
137
|
-
})
|
|
138
|
-
})
|
|
139
|
-
]
|
|
140
|
-
}),
|
|
141
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
142
|
-
class: "field",
|
|
143
|
-
children: [
|
|
144
|
-
/*#__PURE__*/ _jsx("label", {
|
|
145
|
-
class: "label",
|
|
146
|
-
children: $__i18n._({
|
|
147
|
-
id: "Fxf4jq",
|
|
148
|
-
message: "Description (optional)"
|
|
149
|
-
})
|
|
150
|
-
}),
|
|
151
|
-
/*#__PURE__*/ _jsx("textarea", {
|
|
152
|
-
"data-bind": "description",
|
|
153
|
-
class: "textarea",
|
|
154
|
-
rows: 3,
|
|
155
|
-
placeholder: $__i18n._({
|
|
156
|
-
id: "AyHO4m",
|
|
157
|
-
message: "What's this collection about?"
|
|
158
|
-
})
|
|
159
|
-
})
|
|
160
|
-
]
|
|
161
|
-
}),
|
|
162
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
163
|
-
class: "flex gap-2",
|
|
164
|
-
children: [
|
|
165
|
-
/*#__PURE__*/ _jsxs("button", {
|
|
166
|
-
type: "submit",
|
|
167
|
-
class: "btn",
|
|
168
|
-
"data-attr-disabled": "$_loading",
|
|
169
|
-
children: [
|
|
170
|
-
/*#__PURE__*/ _jsx("span", {
|
|
171
|
-
"data-show": "!$_loading",
|
|
172
|
-
children: $__i18n._({
|
|
173
|
-
id: "Pbm2/N",
|
|
174
|
-
message: "Create Collection"
|
|
175
|
-
})
|
|
176
|
-
}),
|
|
177
|
-
/*#__PURE__*/ _jsx("span", {
|
|
178
|
-
"data-show": "$_loading",
|
|
179
|
-
children: $__i18n._({
|
|
180
|
-
id: "k1ifdL",
|
|
181
|
-
message: "Processing..."
|
|
182
|
-
})
|
|
183
|
-
})
|
|
184
|
-
]
|
|
185
|
-
}),
|
|
186
|
-
/*#__PURE__*/ _jsx("a", {
|
|
187
|
-
href: "/dash/collections",
|
|
188
|
-
class: "btn-outline",
|
|
189
|
-
children: $__i18n._({
|
|
190
|
-
id: "dEgA5A",
|
|
191
|
-
message: "Cancel"
|
|
192
|
-
})
|
|
193
|
-
})
|
|
194
|
-
]
|
|
195
|
-
})
|
|
196
|
-
]
|
|
197
|
-
})
|
|
198
|
-
]
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
function ViewCollectionContent({ collection, posts }) {
|
|
202
|
-
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
203
|
-
const postsHeader = $__i18n._({
|
|
204
|
-
id: "pRhYH2",
|
|
205
|
-
message: "Posts in Collection ({count})"
|
|
206
|
-
});
|
|
207
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
208
|
-
children: [
|
|
209
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
210
|
-
class: "flex items-center justify-between mb-6",
|
|
211
|
-
children: [
|
|
212
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
213
|
-
children: [
|
|
214
|
-
/*#__PURE__*/ _jsx("h1", {
|
|
215
|
-
class: "text-2xl font-semibold",
|
|
216
|
-
children: collection.title
|
|
217
|
-
}),
|
|
218
|
-
/*#__PURE__*/ _jsxs("p", {
|
|
219
|
-
class: "text-sm text-muted-foreground",
|
|
220
|
-
children: [
|
|
221
|
-
"/",
|
|
222
|
-
collection.slug
|
|
223
|
-
]
|
|
224
|
-
})
|
|
225
|
-
]
|
|
226
|
-
}),
|
|
227
|
-
/*#__PURE__*/ _jsx(ActionButtons, {
|
|
228
|
-
editHref: `/dash/collections/${collection.id}/edit`,
|
|
229
|
-
editLabel: $__i18n._({
|
|
230
|
-
id: "ePK91l",
|
|
231
|
-
message: "Edit"
|
|
232
|
-
}),
|
|
233
|
-
viewHref: `/c/${collection.slug}`,
|
|
234
|
-
viewLabel: $__i18n._({
|
|
235
|
-
id: "jpctdh",
|
|
236
|
-
message: "View"
|
|
237
|
-
})
|
|
238
|
-
})
|
|
239
|
-
]
|
|
240
|
-
}),
|
|
241
|
-
collection.description && /*#__PURE__*/ _jsx("p", {
|
|
242
|
-
class: "text-muted-foreground mb-6",
|
|
243
|
-
children: collection.description
|
|
244
|
-
}),
|
|
245
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
246
|
-
class: "card",
|
|
247
|
-
children: [
|
|
248
|
-
/*#__PURE__*/ _jsx("header", {
|
|
249
|
-
children: /*#__PURE__*/ _jsx("h2", {
|
|
250
|
-
children: postsHeader
|
|
251
|
-
})
|
|
252
|
-
}),
|
|
253
|
-
/*#__PURE__*/ _jsx("section", {
|
|
254
|
-
children: posts.length === 0 ? /*#__PURE__*/ _jsx("p", {
|
|
255
|
-
class: "text-muted-foreground",
|
|
256
|
-
children: $__i18n._({
|
|
257
|
-
id: "J4FNfC",
|
|
258
|
-
message: "No posts in this collection."
|
|
259
|
-
})
|
|
260
|
-
}) : /*#__PURE__*/ _jsx("div", {
|
|
261
|
-
class: "flex flex-col divide-y",
|
|
262
|
-
children: posts.map((post)=>/*#__PURE__*/ _jsx("div", {
|
|
263
|
-
class: "py-3 flex items-center gap-4",
|
|
264
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
265
|
-
class: "flex-1 min-w-0",
|
|
266
|
-
children: /*#__PURE__*/ _jsx("a", {
|
|
267
|
-
href: `/dash/posts/${sqid.encode(post.id)}`,
|
|
268
|
-
class: "font-medium hover:underline",
|
|
269
|
-
children: post.title || post.body?.slice(0, 50) || `Post #${post.id}`
|
|
270
|
-
})
|
|
271
|
-
})
|
|
272
|
-
}, post.id))
|
|
273
|
-
})
|
|
274
|
-
})
|
|
275
|
-
]
|
|
276
|
-
}),
|
|
277
|
-
/*#__PURE__*/ _jsx("div", {
|
|
278
|
-
class: "mt-6",
|
|
279
|
-
children: /*#__PURE__*/ _jsx("a", {
|
|
280
|
-
href: "/dash/collections",
|
|
281
|
-
class: "text-sm hover:underline",
|
|
282
|
-
children: $__i18n._({
|
|
283
|
-
id: "e6Jr7Q",
|
|
284
|
-
message: "← Back to Collections"
|
|
285
|
-
})
|
|
286
|
-
})
|
|
287
|
-
})
|
|
288
|
-
]
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
function EditCollectionContent({ collection }) {
|
|
292
|
-
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
293
|
-
const signals = JSON.stringify({
|
|
294
|
-
title: collection.title,
|
|
295
|
-
slug: collection.slug ?? "",
|
|
296
|
-
description: collection.description ?? ""
|
|
297
|
-
}).replace(/</g, "\\u003c");
|
|
298
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
299
|
-
children: [
|
|
300
|
-
/*#__PURE__*/ _jsx("h1", {
|
|
301
|
-
class: "text-2xl font-semibold mb-6",
|
|
302
|
-
children: $__i18n._({
|
|
303
|
-
id: "/0D1Xp",
|
|
304
|
-
message: "Edit Collection"
|
|
305
|
-
})
|
|
306
|
-
}),
|
|
307
|
-
/*#__PURE__*/ _jsxs("form", {
|
|
308
|
-
"data-signals": signals,
|
|
309
|
-
"data-on:submit__prevent": `@post('/dash/collections/${collection.id}')`,
|
|
310
|
-
"data-indicator": "_loading",
|
|
311
|
-
class: "flex flex-col gap-4 max-w-lg",
|
|
312
|
-
children: [
|
|
313
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
314
|
-
class: "field",
|
|
315
|
-
children: [
|
|
316
|
-
/*#__PURE__*/ _jsx("label", {
|
|
317
|
-
class: "label",
|
|
318
|
-
children: $__i18n._({
|
|
319
|
-
id: "MHrjPM",
|
|
320
|
-
message: "Title"
|
|
321
|
-
})
|
|
322
|
-
}),
|
|
323
|
-
/*#__PURE__*/ _jsx("input", {
|
|
324
|
-
type: "text",
|
|
325
|
-
"data-bind": "title",
|
|
326
|
-
class: "input",
|
|
327
|
-
required: true
|
|
328
|
-
})
|
|
329
|
-
]
|
|
330
|
-
}),
|
|
331
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
332
|
-
class: "field",
|
|
333
|
-
children: [
|
|
334
|
-
/*#__PURE__*/ _jsx("label", {
|
|
335
|
-
class: "label",
|
|
336
|
-
children: $__i18n._({
|
|
337
|
-
id: "L85WcV",
|
|
338
|
-
message: "Slug"
|
|
339
|
-
})
|
|
340
|
-
}),
|
|
341
|
-
/*#__PURE__*/ _jsx("input", {
|
|
342
|
-
type: "text",
|
|
343
|
-
"data-bind": "slug",
|
|
344
|
-
class: "input",
|
|
345
|
-
required: true,
|
|
346
|
-
pattern: "[a-z0-9-]+"
|
|
347
|
-
})
|
|
348
|
-
]
|
|
349
|
-
}),
|
|
350
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
351
|
-
class: "field",
|
|
352
|
-
children: [
|
|
353
|
-
/*#__PURE__*/ _jsx("label", {
|
|
354
|
-
class: "label",
|
|
355
|
-
children: $__i18n._({
|
|
356
|
-
id: "Fxf4jq",
|
|
357
|
-
message: "Description (optional)"
|
|
358
|
-
})
|
|
359
|
-
}),
|
|
360
|
-
/*#__PURE__*/ _jsx("textarea", {
|
|
361
|
-
"data-bind": "description",
|
|
362
|
-
class: "textarea",
|
|
363
|
-
rows: 3,
|
|
364
|
-
children: collection.description ?? ""
|
|
365
|
-
})
|
|
366
|
-
]
|
|
367
|
-
}),
|
|
368
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
369
|
-
class: "flex gap-2",
|
|
370
|
-
children: [
|
|
371
|
-
/*#__PURE__*/ _jsxs("button", {
|
|
372
|
-
type: "submit",
|
|
373
|
-
class: "btn",
|
|
374
|
-
"data-attr-disabled": "$_loading",
|
|
375
|
-
children: [
|
|
376
|
-
/*#__PURE__*/ _jsx("span", {
|
|
377
|
-
"data-show": "!$_loading",
|
|
378
|
-
children: $__i18n._({
|
|
379
|
-
id: "7Mk+/h",
|
|
380
|
-
message: "Update Collection"
|
|
381
|
-
})
|
|
382
|
-
}),
|
|
383
|
-
/*#__PURE__*/ _jsx("span", {
|
|
384
|
-
"data-show": "$_loading",
|
|
385
|
-
children: $__i18n._({
|
|
386
|
-
id: "k1ifdL",
|
|
387
|
-
message: "Processing..."
|
|
388
|
-
})
|
|
389
|
-
})
|
|
390
|
-
]
|
|
391
|
-
}),
|
|
392
|
-
/*#__PURE__*/ _jsx("a", {
|
|
393
|
-
href: `/dash/collections/${collection.id}`,
|
|
394
|
-
class: "btn-outline",
|
|
395
|
-
children: $__i18n._({
|
|
396
|
-
id: "dEgA5A",
|
|
397
|
-
message: "Cancel"
|
|
398
|
-
})
|
|
399
|
-
})
|
|
400
|
-
]
|
|
401
|
-
})
|
|
402
|
-
]
|
|
403
|
-
}),
|
|
404
|
-
/*#__PURE__*/ _jsx(DangerZone, {
|
|
405
|
-
actionLabel: $__i18n._({
|
|
406
|
-
id: "GA5A5H",
|
|
407
|
-
message: "Delete Collection"
|
|
408
|
-
}),
|
|
409
|
-
formAction: `/dash/collections/${collection.id}/delete`,
|
|
410
|
-
confirmMessage: "Are you sure you want to delete this collection?"
|
|
411
|
-
})
|
|
412
|
-
]
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
14
|
// List collections
|
|
416
15
|
collectionsRoutes.get("/", async (c)=>{
|
|
417
16
|
const siteName = await getSiteName(c);
|
|
@@ -434,7 +33,7 @@ collectionsRoutes.get("/new", async (c)=>{
|
|
|
434
33
|
title: "New Collection",
|
|
435
34
|
siteName: siteName,
|
|
436
35
|
currentPath: "/dash/collections",
|
|
437
|
-
children: /*#__PURE__*/ _jsx(
|
|
36
|
+
children: /*#__PURE__*/ _jsx(CollectionForm, {})
|
|
438
37
|
}));
|
|
439
38
|
});
|
|
440
39
|
// Create collection
|
|
@@ -453,10 +52,11 @@ collectionsRoutes.get("/:id", async (c)=>{
|
|
|
453
52
|
if (isNaN(id)) return c.notFound();
|
|
454
53
|
const collection = await c.var.services.collections.getById(id);
|
|
455
54
|
if (!collection) return c.notFound();
|
|
456
|
-
|
|
457
|
-
const posts = await c.var.services.posts.list({
|
|
55
|
+
const rawPosts = await c.var.services.posts.list({
|
|
458
56
|
collectionId: id
|
|
459
57
|
});
|
|
58
|
+
const ctx = createMediaContext(c);
|
|
59
|
+
const posts = toPostViewsFromPosts(rawPosts, ctx);
|
|
460
60
|
const siteName = await getSiteName(c);
|
|
461
61
|
return c.html(/*#__PURE__*/ _jsx(DashLayout, {
|
|
462
62
|
c: c,
|
|
@@ -476,14 +76,22 @@ collectionsRoutes.get("/:id/edit", async (c)=>{
|
|
|
476
76
|
const collection = await c.var.services.collections.getById(id);
|
|
477
77
|
if (!collection) return c.notFound();
|
|
478
78
|
const siteName = await getSiteName(c);
|
|
479
|
-
return c.html(/*#__PURE__*/
|
|
79
|
+
return c.html(/*#__PURE__*/ _jsxs(DashLayout, {
|
|
480
80
|
c: c,
|
|
481
81
|
title: `Edit: ${collection.title}`,
|
|
482
82
|
siteName: siteName,
|
|
483
83
|
currentPath: "/dash/collections",
|
|
484
|
-
children:
|
|
485
|
-
|
|
486
|
-
|
|
84
|
+
children: [
|
|
85
|
+
/*#__PURE__*/ _jsx(CollectionForm, {
|
|
86
|
+
collection: collection,
|
|
87
|
+
isEdit: true
|
|
88
|
+
}),
|
|
89
|
+
/*#__PURE__*/ _jsx(DangerZone, {
|
|
90
|
+
actionLabel: "Delete Collection",
|
|
91
|
+
formAction: `/dash/collections/${collection.id}/delete`,
|
|
92
|
+
confirmMessage: "Are you sure you want to delete this collection?"
|
|
93
|
+
})
|
|
94
|
+
]
|
|
487
95
|
}));
|
|
488
96
|
});
|
|
489
97
|
// Update collection
|