@jant/core 0.2.12 → 0.2.13
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/bin/jant.js +3 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +112 -85
- package/dist/auth.d.ts +1 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +2 -1
- package/dist/client.js +1 -1
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/i18n/context.d.ts.map +1 -1
- package/dist/i18n/context.js +0 -3
- package/dist/i18n/detect.d.ts +0 -11
- package/dist/i18n/detect.d.ts.map +1 -1
- package/dist/i18n/detect.js +1 -52
- package/dist/i18n/i18n.d.ts +4 -14
- package/dist/i18n/i18n.d.ts.map +1 -1
- package/dist/i18n/i18n.js +19 -25
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/middleware.d.ts +2 -5
- package/dist/i18n/middleware.d.ts.map +1 -1
- package/dist/i18n/middleware.js +12 -23
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/image.d.ts.map +1 -1
- package/dist/lib/schemas.d.ts.map +1 -1
- package/dist/lib/sse.d.ts +45 -17
- package/dist/lib/sse.d.ts.map +1 -1
- package/dist/lib/sse.js +77 -37
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/routes/api/posts.js +0 -1
- package/dist/routes/api/upload.js +3 -1
- package/dist/routes/dash/collections.d.ts.map +1 -1
- package/dist/routes/dash/collections.js +134 -142
- package/dist/routes/dash/index.js +25 -26
- package/dist/routes/dash/media.d.ts.map +1 -1
- package/dist/routes/dash/media.js +60 -56
- package/dist/routes/dash/pages.js +64 -66
- package/dist/routes/dash/posts.d.ts.map +1 -1
- package/dist/routes/dash/posts.js +50 -59
- package/dist/routes/dash/redirects.d.ts.map +1 -1
- package/dist/routes/dash/redirects.js +63 -60
- package/dist/routes/dash/settings.d.ts.map +1 -1
- package/dist/routes/dash/settings.js +249 -93
- package/dist/routes/feed/rss.js +6 -4
- package/dist/routes/pages/archive.js +60 -62
- package/dist/routes/pages/collection.js +8 -8
- package/dist/routes/pages/home.js +14 -14
- package/dist/routes/pages/page.js +7 -6
- package/dist/routes/pages/post.js +8 -8
- package/dist/routes/pages/search.js +25 -27
- package/dist/services/collection.d.ts.map +1 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/media.d.ts.map +1 -1
- package/dist/services/post.d.ts.map +1 -1
- package/dist/services/redirect.d.ts.map +1 -1
- package/dist/services/settings.d.ts.map +1 -1
- package/dist/theme/components/ActionButtons.d.ts +1 -1
- package/dist/theme/components/ActionButtons.d.ts.map +1 -1
- package/dist/theme/components/ActionButtons.js +17 -21
- package/dist/theme/components/CrudPageHeader.d.ts.map +1 -1
- package/dist/theme/components/DangerZone.d.ts.map +1 -1
- package/dist/theme/components/DangerZone.js +12 -15
- package/dist/theme/components/EmptyState.d.ts.map +1 -1
- package/dist/theme/components/PageForm.d.ts.map +1 -1
- package/dist/theme/components/PageForm.js +58 -56
- package/dist/theme/components/Pagination.d.ts.map +1 -1
- package/dist/theme/components/Pagination.js +22 -25
- package/dist/theme/components/PostForm.d.ts +0 -1
- package/dist/theme/components/PostForm.d.ts.map +1 -1
- package/dist/theme/components/PostForm.js +85 -77
- package/dist/theme/components/PostList.d.ts.map +1 -1
- package/dist/theme/components/PostList.js +17 -17
- package/dist/theme/components/ThreadView.d.ts.map +1 -1
- package/dist/theme/components/ThreadView.js +15 -18
- package/dist/theme/components/TypeBadge.d.ts.map +1 -1
- package/dist/theme/components/TypeBadge.js +20 -20
- package/dist/theme/components/VisibilityBadge.d.ts.map +1 -1
- package/dist/theme/components/VisibilityBadge.js +14 -14
- package/dist/theme/components/index.d.ts +1 -1
- package/dist/theme/components/index.d.ts.map +1 -1
- package/dist/theme/layouts/BaseLayout.d.ts.map +1 -1
- package/dist/theme/layouts/BaseLayout.js +4 -2
- package/dist/theme/layouts/DashLayout.d.ts.map +1 -1
- package/dist/theme/layouts/DashLayout.js +29 -29
- package/dist/types/lingui-react-macro.d.js +9 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/vendor/datastar.js +1606 -0
- package/package.json +5 -2
- package/src/app.tsx +175 -56
- package/src/auth.ts +5 -1
- package/src/client.ts +1 -1
- package/src/db/schema.ts +22 -7
- package/src/i18n/EXAMPLES.md +34 -14
- package/src/i18n/README.md +19 -9
- package/src/i18n/context.tsx +1 -4
- package/src/i18n/detect.ts +1 -67
- package/src/i18n/i18n.ts +15 -19
- package/src/i18n/index.ts +0 -3
- package/src/i18n/middleware.ts +12 -24
- package/src/lib/constants.ts +2 -1
- package/src/lib/image-processor.ts +23 -7
- package/src/lib/image.ts +6 -2
- package/src/lib/schemas.ts +6 -2
- package/src/lib/sse.ts +138 -50
- package/src/middleware/auth.ts +6 -2
- package/src/routes/api/posts.ts +14 -5
- package/src/routes/api/upload.ts +25 -7
- package/src/routes/dash/collections.tsx +162 -70
- package/src/routes/dash/index.tsx +22 -7
- package/src/routes/dash/media.tsx +59 -16
- package/src/routes/dash/pages.tsx +102 -44
- package/src/routes/dash/posts.tsx +87 -54
- package/src/routes/dash/redirects.tsx +74 -26
- package/src/routes/dash/settings.tsx +250 -57
- package/src/routes/feed/rss.ts +6 -4
- package/src/routes/pages/archive.tsx +71 -21
- package/src/routes/pages/collection.tsx +21 -6
- package/src/routes/pages/home.tsx +30 -9
- package/src/routes/pages/page.tsx +14 -5
- package/src/routes/pages/post.tsx +21 -7
- package/src/routes/pages/search.tsx +42 -11
- package/src/services/collection.ts +34 -9
- package/src/services/index.ts +4 -1
- package/src/services/media.ts +15 -3
- package/src/services/post.ts +39 -10
- package/src/services/redirect.ts +4 -1
- package/src/services/settings.ts +14 -3
- package/src/theme/components/ActionButtons.tsx +26 -14
- package/src/theme/components/CrudPageHeader.tsx +6 -1
- package/src/theme/components/DangerZone.tsx +19 -13
- package/src/theme/components/EmptyState.tsx +6 -1
- package/src/theme/components/PageForm.tsx +71 -24
- package/src/theme/components/Pagination.tsx +26 -8
- package/src/theme/components/PostForm.tsx +72 -25
- package/src/theme/components/PostList.tsx +16 -5
- package/src/theme/components/ThreadView.tsx +25 -7
- package/src/theme/components/TypeBadge.tsx +13 -4
- package/src/theme/components/VisibilityBadge.tsx +17 -5
- package/src/theme/components/index.ts +4 -1
- package/src/theme/layouts/BaseLayout.tsx +5 -2
- package/src/theme/layouts/DashLayout.tsx +41 -12
- package/src/types/lingui-react-macro.d.ts +34 -0
- package/src/types.ts +16 -2
- package/src/vendor/datastar.js +9 -0
- package/src/vendor/datastar.js.map +7 -0
|
@@ -2,34 +2,35 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "hono/jsx/jsx-
|
|
|
2
2
|
/**
|
|
3
3
|
* Dashboard Collections Routes
|
|
4
4
|
*/ import { Hono } from "hono";
|
|
5
|
-
import { useLingui } from "
|
|
5
|
+
import { useLingui as $_useLingui } from "@jant/core/i18n";
|
|
6
6
|
import { DashLayout } from "../../theme/layouts/index.js";
|
|
7
7
|
import { EmptyState, ListItemRow, ActionButtons, CrudPageHeader, DangerZone } from "../../theme/components/index.js";
|
|
8
8
|
import * as sqid from "../../lib/sqid.js";
|
|
9
|
+
import { sse } from "../../lib/sse.js";
|
|
9
10
|
export const collectionsRoutes = new Hono();
|
|
10
11
|
function CollectionsListContent({ collections }) {
|
|
11
|
-
const {
|
|
12
|
+
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
12
13
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
13
14
|
children: [
|
|
14
15
|
/*#__PURE__*/ _jsx(CrudPageHeader, {
|
|
15
|
-
title:
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
title: $__i18n._({
|
|
17
|
+
id: "DoJzLz",
|
|
18
|
+
message: "Collections"
|
|
18
19
|
}),
|
|
19
|
-
ctaLabel:
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
ctaLabel: $__i18n._({
|
|
21
|
+
id: "vzU4k9",
|
|
22
|
+
message: "New Collection"
|
|
22
23
|
}),
|
|
23
24
|
ctaHref: "/dash/collections/new"
|
|
24
25
|
}),
|
|
25
26
|
collections.length === 0 ? /*#__PURE__*/ _jsx(EmptyState, {
|
|
26
|
-
message:
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
message: $__i18n._({
|
|
28
|
+
id: "+MACwa",
|
|
29
|
+
message: "No collections yet."
|
|
29
30
|
}),
|
|
30
|
-
ctaText:
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
ctaText: $__i18n._({
|
|
32
|
+
id: "vzU4k9",
|
|
33
|
+
message: "New Collection"
|
|
33
34
|
}),
|
|
34
35
|
ctaHref: "/dash/collections/new"
|
|
35
36
|
}) : /*#__PURE__*/ _jsx("div", {
|
|
@@ -37,14 +38,14 @@ function CollectionsListContent({ collections }) {
|
|
|
37
38
|
children: collections.map((col)=>/*#__PURE__*/ _jsxs(ListItemRow, {
|
|
38
39
|
actions: /*#__PURE__*/ _jsx(ActionButtons, {
|
|
39
40
|
editHref: `/dash/collections/${col.id}/edit`,
|
|
40
|
-
editLabel:
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
editLabel: $__i18n._({
|
|
42
|
+
id: "ePK91l",
|
|
43
|
+
message: "Edit"
|
|
43
44
|
}),
|
|
44
45
|
viewHref: `/c/${col.path}`,
|
|
45
|
-
viewLabel:
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
viewLabel: $__i18n._({
|
|
47
|
+
id: "jpctdh",
|
|
48
|
+
message: "View"
|
|
48
49
|
})
|
|
49
50
|
}),
|
|
50
51
|
children: [
|
|
@@ -71,19 +72,19 @@ function CollectionsListContent({ collections }) {
|
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
74
|
function NewCollectionContent() {
|
|
74
|
-
const {
|
|
75
|
+
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
75
76
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
76
77
|
children: [
|
|
77
78
|
/*#__PURE__*/ _jsx("h1", {
|
|
78
79
|
class: "text-2xl font-semibold mb-6",
|
|
79
|
-
children:
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
children: $__i18n._({
|
|
81
|
+
id: "vzU4k9",
|
|
82
|
+
message: "New Collection"
|
|
82
83
|
})
|
|
83
84
|
}),
|
|
84
85
|
/*#__PURE__*/ _jsxs("form", {
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
"data-signals": "{title: '', path: '', description: ''}",
|
|
87
|
+
"data-on:submit__prevent": "@post('/dash/collections')",
|
|
87
88
|
class: "flex flex-col gap-4 max-w-lg",
|
|
88
89
|
children: [
|
|
89
90
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -91,19 +92,19 @@ function NewCollectionContent() {
|
|
|
91
92
|
children: [
|
|
92
93
|
/*#__PURE__*/ _jsx("label", {
|
|
93
94
|
class: "label",
|
|
94
|
-
children:
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
children: $__i18n._({
|
|
96
|
+
id: "MHrjPM",
|
|
97
|
+
message: "Title"
|
|
97
98
|
})
|
|
98
99
|
}),
|
|
99
100
|
/*#__PURE__*/ _jsx("input", {
|
|
100
101
|
type: "text",
|
|
101
|
-
|
|
102
|
+
"data-bind": "title",
|
|
102
103
|
class: "input",
|
|
103
104
|
required: true,
|
|
104
|
-
placeholder:
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
placeholder: $__i18n._({
|
|
106
|
+
id: "fttd2R",
|
|
107
|
+
message: "My Collection"
|
|
107
108
|
})
|
|
108
109
|
})
|
|
109
110
|
]
|
|
@@ -113,14 +114,14 @@ function NewCollectionContent() {
|
|
|
113
114
|
children: [
|
|
114
115
|
/*#__PURE__*/ _jsx("label", {
|
|
115
116
|
class: "label",
|
|
116
|
-
children:
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
children: $__i18n._({
|
|
118
|
+
id: "L85WcV",
|
|
119
|
+
message: "Slug"
|
|
119
120
|
})
|
|
120
121
|
}),
|
|
121
122
|
/*#__PURE__*/ _jsx("input", {
|
|
122
123
|
type: "text",
|
|
123
|
-
|
|
124
|
+
"data-bind": "path",
|
|
124
125
|
class: "input",
|
|
125
126
|
required: true,
|
|
126
127
|
placeholder: "my-collection",
|
|
@@ -128,9 +129,9 @@ function NewCollectionContent() {
|
|
|
128
129
|
}),
|
|
129
130
|
/*#__PURE__*/ _jsx("p", {
|
|
130
131
|
class: "text-xs text-muted-foreground mt-1",
|
|
131
|
-
children:
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
children: $__i18n._({
|
|
133
|
+
id: "1CU1Td",
|
|
134
|
+
message: "URL-safe identifier (lowercase, numbers, hyphens)"
|
|
134
135
|
})
|
|
135
136
|
})
|
|
136
137
|
]
|
|
@@ -140,18 +141,18 @@ function NewCollectionContent() {
|
|
|
140
141
|
children: [
|
|
141
142
|
/*#__PURE__*/ _jsx("label", {
|
|
142
143
|
class: "label",
|
|
143
|
-
children:
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
children: $__i18n._({
|
|
145
|
+
id: "Fxf4jq",
|
|
146
|
+
message: "Description (optional)"
|
|
146
147
|
})
|
|
147
148
|
}),
|
|
148
149
|
/*#__PURE__*/ _jsx("textarea", {
|
|
149
|
-
|
|
150
|
+
"data-bind": "description",
|
|
150
151
|
class: "textarea",
|
|
151
152
|
rows: 3,
|
|
152
|
-
placeholder:
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
placeholder: $__i18n._({
|
|
154
|
+
id: "AyHO4m",
|
|
155
|
+
message: "What's this collection about?"
|
|
155
156
|
})
|
|
156
157
|
})
|
|
157
158
|
]
|
|
@@ -162,17 +163,17 @@ function NewCollectionContent() {
|
|
|
162
163
|
/*#__PURE__*/ _jsx("button", {
|
|
163
164
|
type: "submit",
|
|
164
165
|
class: "btn",
|
|
165
|
-
children:
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
children: $__i18n._({
|
|
167
|
+
id: "Pbm2/N",
|
|
168
|
+
message: "Create Collection"
|
|
168
169
|
})
|
|
169
170
|
}),
|
|
170
171
|
/*#__PURE__*/ _jsx("a", {
|
|
171
172
|
href: "/dash/collections",
|
|
172
173
|
class: "btn-outline",
|
|
173
|
-
children:
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
children: $__i18n._({
|
|
175
|
+
id: "dEgA5A",
|
|
176
|
+
message: "Cancel"
|
|
176
177
|
})
|
|
177
178
|
})
|
|
178
179
|
]
|
|
@@ -183,13 +184,10 @@ function NewCollectionContent() {
|
|
|
183
184
|
});
|
|
184
185
|
}
|
|
185
186
|
function ViewCollectionContent({ collection, posts }) {
|
|
186
|
-
const {
|
|
187
|
-
const postsHeader =
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
values: {
|
|
191
|
-
count: String(posts.length)
|
|
192
|
-
}
|
|
187
|
+
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
188
|
+
const postsHeader = $__i18n._({
|
|
189
|
+
id: "pRhYH2",
|
|
190
|
+
message: "Posts in Collection ({count})"
|
|
193
191
|
});
|
|
194
192
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
195
193
|
children: [
|
|
@@ -213,14 +211,14 @@ function ViewCollectionContent({ collection, posts }) {
|
|
|
213
211
|
}),
|
|
214
212
|
/*#__PURE__*/ _jsx(ActionButtons, {
|
|
215
213
|
editHref: `/dash/collections/${collection.id}/edit`,
|
|
216
|
-
editLabel:
|
|
217
|
-
|
|
218
|
-
|
|
214
|
+
editLabel: $__i18n._({
|
|
215
|
+
id: "ePK91l",
|
|
216
|
+
message: "Edit"
|
|
219
217
|
}),
|
|
220
218
|
viewHref: `/c/${collection.path}`,
|
|
221
|
-
viewLabel:
|
|
222
|
-
|
|
223
|
-
|
|
219
|
+
viewLabel: $__i18n._({
|
|
220
|
+
id: "jpctdh",
|
|
221
|
+
message: "View"
|
|
224
222
|
})
|
|
225
223
|
})
|
|
226
224
|
]
|
|
@@ -240,9 +238,9 @@ function ViewCollectionContent({ collection, posts }) {
|
|
|
240
238
|
/*#__PURE__*/ _jsx("section", {
|
|
241
239
|
children: posts.length === 0 ? /*#__PURE__*/ _jsx("p", {
|
|
242
240
|
class: "text-muted-foreground",
|
|
243
|
-
children:
|
|
244
|
-
|
|
245
|
-
|
|
241
|
+
children: $__i18n._({
|
|
242
|
+
id: "J4FNfC",
|
|
243
|
+
message: "No posts in this collection."
|
|
246
244
|
})
|
|
247
245
|
}) : /*#__PURE__*/ _jsx("div", {
|
|
248
246
|
class: "flex flex-col divide-y",
|
|
@@ -257,24 +255,14 @@ function ViewCollectionContent({ collection, posts }) {
|
|
|
257
255
|
children: post.title || post.content?.slice(0, 50) || `Post #${post.id}`
|
|
258
256
|
})
|
|
259
257
|
}),
|
|
260
|
-
/*#__PURE__*/
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}),
|
|
269
|
-
/*#__PURE__*/ _jsx("button", {
|
|
270
|
-
type: "submit",
|
|
271
|
-
class: "btn-sm-ghost text-destructive",
|
|
272
|
-
children: t({
|
|
273
|
-
message: "Remove",
|
|
274
|
-
comment: "@context: Button to remove post from collection"
|
|
275
|
-
})
|
|
276
|
-
})
|
|
277
|
-
]
|
|
258
|
+
/*#__PURE__*/ _jsx("button", {
|
|
259
|
+
type: "button",
|
|
260
|
+
class: "btn-sm-ghost text-destructive",
|
|
261
|
+
"data-on:click__prevent": `@post('/dash/collections/${collection.id}/remove-post', {payload: {postId: ${post.id}}})`,
|
|
262
|
+
children: $__i18n._({
|
|
263
|
+
id: "t/YqKh",
|
|
264
|
+
message: "Remove"
|
|
265
|
+
})
|
|
278
266
|
})
|
|
279
267
|
]
|
|
280
268
|
}, post.id))
|
|
@@ -287,9 +275,9 @@ function ViewCollectionContent({ collection, posts }) {
|
|
|
287
275
|
children: /*#__PURE__*/ _jsx("a", {
|
|
288
276
|
href: "/dash/collections",
|
|
289
277
|
class: "text-sm hover:underline",
|
|
290
|
-
children:
|
|
291
|
-
|
|
292
|
-
|
|
278
|
+
children: $__i18n._({
|
|
279
|
+
id: "e6Jr7Q",
|
|
280
|
+
message: "← Back to Collections"
|
|
293
281
|
})
|
|
294
282
|
})
|
|
295
283
|
})
|
|
@@ -297,19 +285,24 @@ function ViewCollectionContent({ collection, posts }) {
|
|
|
297
285
|
});
|
|
298
286
|
}
|
|
299
287
|
function EditCollectionContent({ collection }) {
|
|
300
|
-
const {
|
|
288
|
+
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
289
|
+
const signals = JSON.stringify({
|
|
290
|
+
title: collection.title,
|
|
291
|
+
path: collection.path ?? "",
|
|
292
|
+
description: collection.description ?? ""
|
|
293
|
+
}).replace(/</g, "\\u003c");
|
|
301
294
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
302
295
|
children: [
|
|
303
296
|
/*#__PURE__*/ _jsx("h1", {
|
|
304
297
|
class: "text-2xl font-semibold mb-6",
|
|
305
|
-
children:
|
|
306
|
-
|
|
307
|
-
|
|
298
|
+
children: $__i18n._({
|
|
299
|
+
id: "/0D1Xp",
|
|
300
|
+
message: "Edit Collection"
|
|
308
301
|
})
|
|
309
302
|
}),
|
|
310
303
|
/*#__PURE__*/ _jsxs("form", {
|
|
311
|
-
|
|
312
|
-
|
|
304
|
+
"data-signals": signals,
|
|
305
|
+
"data-on:submit__prevent": `@post('/dash/collections/${collection.id}')`,
|
|
313
306
|
class: "flex flex-col gap-4 max-w-lg",
|
|
314
307
|
children: [
|
|
315
308
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -317,17 +310,16 @@ function EditCollectionContent({ collection }) {
|
|
|
317
310
|
children: [
|
|
318
311
|
/*#__PURE__*/ _jsx("label", {
|
|
319
312
|
class: "label",
|
|
320
|
-
children:
|
|
321
|
-
|
|
322
|
-
|
|
313
|
+
children: $__i18n._({
|
|
314
|
+
id: "MHrjPM",
|
|
315
|
+
message: "Title"
|
|
323
316
|
})
|
|
324
317
|
}),
|
|
325
318
|
/*#__PURE__*/ _jsx("input", {
|
|
326
319
|
type: "text",
|
|
327
|
-
|
|
320
|
+
"data-bind": "title",
|
|
328
321
|
class: "input",
|
|
329
|
-
required: true
|
|
330
|
-
value: collection.title
|
|
322
|
+
required: true
|
|
331
323
|
})
|
|
332
324
|
]
|
|
333
325
|
}),
|
|
@@ -336,17 +328,16 @@ function EditCollectionContent({ collection }) {
|
|
|
336
328
|
children: [
|
|
337
329
|
/*#__PURE__*/ _jsx("label", {
|
|
338
330
|
class: "label",
|
|
339
|
-
children:
|
|
340
|
-
|
|
341
|
-
|
|
331
|
+
children: $__i18n._({
|
|
332
|
+
id: "L85WcV",
|
|
333
|
+
message: "Slug"
|
|
342
334
|
})
|
|
343
335
|
}),
|
|
344
336
|
/*#__PURE__*/ _jsx("input", {
|
|
345
337
|
type: "text",
|
|
346
|
-
|
|
338
|
+
"data-bind": "path",
|
|
347
339
|
class: "input",
|
|
348
340
|
required: true,
|
|
349
|
-
value: collection.path ?? "",
|
|
350
341
|
pattern: "[a-z0-9-]+"
|
|
351
342
|
})
|
|
352
343
|
]
|
|
@@ -356,13 +347,13 @@ function EditCollectionContent({ collection }) {
|
|
|
356
347
|
children: [
|
|
357
348
|
/*#__PURE__*/ _jsx("label", {
|
|
358
349
|
class: "label",
|
|
359
|
-
children:
|
|
360
|
-
|
|
361
|
-
|
|
350
|
+
children: $__i18n._({
|
|
351
|
+
id: "Fxf4jq",
|
|
352
|
+
message: "Description (optional)"
|
|
362
353
|
})
|
|
363
354
|
}),
|
|
364
355
|
/*#__PURE__*/ _jsx("textarea", {
|
|
365
|
-
|
|
356
|
+
"data-bind": "description",
|
|
366
357
|
class: "textarea",
|
|
367
358
|
rows: 3,
|
|
368
359
|
children: collection.description ?? ""
|
|
@@ -375,17 +366,17 @@ function EditCollectionContent({ collection }) {
|
|
|
375
366
|
/*#__PURE__*/ _jsx("button", {
|
|
376
367
|
type: "submit",
|
|
377
368
|
class: "btn",
|
|
378
|
-
children:
|
|
379
|
-
|
|
380
|
-
|
|
369
|
+
children: $__i18n._({
|
|
370
|
+
id: "7Mk+/h",
|
|
371
|
+
message: "Update Collection"
|
|
381
372
|
})
|
|
382
373
|
}),
|
|
383
374
|
/*#__PURE__*/ _jsx("a", {
|
|
384
375
|
href: `/dash/collections/${collection.id}`,
|
|
385
376
|
class: "btn-outline",
|
|
386
|
-
children:
|
|
387
|
-
|
|
388
|
-
|
|
377
|
+
children: $__i18n._({
|
|
378
|
+
id: "dEgA5A",
|
|
379
|
+
message: "Cancel"
|
|
389
380
|
})
|
|
390
381
|
})
|
|
391
382
|
]
|
|
@@ -393,9 +384,9 @@ function EditCollectionContent({ collection }) {
|
|
|
393
384
|
]
|
|
394
385
|
}),
|
|
395
386
|
/*#__PURE__*/ _jsx(DangerZone, {
|
|
396
|
-
actionLabel:
|
|
397
|
-
|
|
398
|
-
|
|
387
|
+
actionLabel: $__i18n._({
|
|
388
|
+
id: "GA5A5H",
|
|
389
|
+
message: "Delete Collection"
|
|
399
390
|
}),
|
|
400
391
|
formAction: `/dash/collections/${collection.id}/delete`,
|
|
401
392
|
confirmMessage: "Are you sure you want to delete this collection?"
|
|
@@ -430,16 +421,15 @@ collectionsRoutes.get("/new", async (c)=>{
|
|
|
430
421
|
});
|
|
431
422
|
// Create collection
|
|
432
423
|
collectionsRoutes.post("/", async (c)=>{
|
|
433
|
-
const
|
|
434
|
-
const title = formData.get("title");
|
|
435
|
-
const path = formData.get("path");
|
|
436
|
-
const description = formData.get("description");
|
|
424
|
+
const body = await c.req.json();
|
|
437
425
|
const collection = await c.var.services.collections.create({
|
|
438
|
-
title,
|
|
439
|
-
path,
|
|
440
|
-
description: description || undefined
|
|
426
|
+
title: body.title,
|
|
427
|
+
path: body.path,
|
|
428
|
+
description: body.description || undefined
|
|
429
|
+
});
|
|
430
|
+
return sse(c, async (stream)=>{
|
|
431
|
+
await stream.redirect(`/dash/collections/${collection.id}`);
|
|
441
432
|
});
|
|
442
|
-
return c.redirect(`/dash/collections/${collection.id}`);
|
|
443
433
|
});
|
|
444
434
|
// View single collection
|
|
445
435
|
collectionsRoutes.get("/:id", async (c)=>{
|
|
@@ -481,32 +471,34 @@ collectionsRoutes.get("/:id/edit", async (c)=>{
|
|
|
481
471
|
collectionsRoutes.post("/:id", async (c)=>{
|
|
482
472
|
const id = parseInt(c.req.param("id"), 10);
|
|
483
473
|
if (isNaN(id)) return c.notFound();
|
|
484
|
-
const
|
|
485
|
-
const title = formData.get("title");
|
|
486
|
-
const path = formData.get("path");
|
|
487
|
-
const description = formData.get("description");
|
|
474
|
+
const body = await c.req.json();
|
|
488
475
|
await c.var.services.collections.update(id, {
|
|
489
|
-
title,
|
|
490
|
-
path,
|
|
491
|
-
description: description || undefined
|
|
476
|
+
title: body.title,
|
|
477
|
+
path: body.path,
|
|
478
|
+
description: body.description || undefined
|
|
479
|
+
});
|
|
480
|
+
return sse(c, async (stream)=>{
|
|
481
|
+
await stream.redirect(`/dash/collections/${id}`);
|
|
492
482
|
});
|
|
493
|
-
return c.redirect(`/dash/collections/${id}`);
|
|
494
483
|
});
|
|
495
484
|
// Delete collection
|
|
496
485
|
collectionsRoutes.post("/:id/delete", async (c)=>{
|
|
497
486
|
const id = parseInt(c.req.param("id"), 10);
|
|
498
487
|
if (isNaN(id)) return c.notFound();
|
|
499
488
|
await c.var.services.collections.delete(id);
|
|
500
|
-
return c
|
|
489
|
+
return sse(c, async (stream)=>{
|
|
490
|
+
await stream.redirect("/dash/collections");
|
|
491
|
+
});
|
|
501
492
|
});
|
|
502
493
|
// Remove post from collection
|
|
503
494
|
collectionsRoutes.post("/:id/remove-post", async (c)=>{
|
|
504
495
|
const id = parseInt(c.req.param("id"), 10);
|
|
505
496
|
if (isNaN(id)) return c.notFound();
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
await c.var.services.collections.removePost(id, postId);
|
|
497
|
+
const body = await c.req.json();
|
|
498
|
+
if (body.postId) {
|
|
499
|
+
await c.var.services.collections.removePost(id, body.postId);
|
|
510
500
|
}
|
|
511
|
-
return c
|
|
501
|
+
return sse(c, async (stream)=>{
|
|
502
|
+
await stream.redirect(`/dash/collections/${id}`);
|
|
503
|
+
});
|
|
512
504
|
});
|
|
@@ -4,7 +4,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "hono/jsx/jsx-runtime";
|
|
|
4
4
|
*
|
|
5
5
|
* Example of using @lingui/react/macro with Hono JSX!
|
|
6
6
|
*/ import { Hono } from "hono";
|
|
7
|
-
import {
|
|
7
|
+
import { useLingui as $_useLingui } from "@jant/core/i18n";
|
|
8
|
+
import { Trans as Trans_ } from "@jant/core/i18n";
|
|
8
9
|
import { DashLayout } from "../../theme/layouts/index.js";
|
|
9
10
|
export const dashIndexRoutes = new Hono();
|
|
10
11
|
/**
|
|
@@ -12,15 +13,15 @@ export const dashIndexRoutes = new Hono();
|
|
|
12
13
|
* Uses useLingui() from @lingui/react/macro - works with Hono JSX!
|
|
13
14
|
*/ function DashboardContent({ publishedCount, draftCount }) {
|
|
14
15
|
// 🎉 Single layer! Just like React!
|
|
15
|
-
const {
|
|
16
|
+
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
16
17
|
return /*#__PURE__*/ _jsxs("div", {
|
|
17
18
|
class: "container py-8",
|
|
18
19
|
children: [
|
|
19
20
|
/*#__PURE__*/ _jsx("h1", {
|
|
20
21
|
class: "text-2xl font-semibold mb-6",
|
|
21
|
-
children:
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
children: $__i18n._({
|
|
23
|
+
id: "7p5kLi",
|
|
24
|
+
message: "Dashboard"
|
|
24
25
|
})
|
|
25
26
|
}),
|
|
26
27
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -31,9 +32,9 @@ export const dashIndexRoutes = new Hono();
|
|
|
31
32
|
children: [
|
|
32
33
|
/*#__PURE__*/ _jsx("p", {
|
|
33
34
|
class: "text-sm text-muted-foreground",
|
|
34
|
-
children:
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
children: $__i18n._({
|
|
36
|
+
id: "u3wRF+",
|
|
37
|
+
message: "Published"
|
|
37
38
|
})
|
|
38
39
|
}),
|
|
39
40
|
/*#__PURE__*/ _jsx("p", {
|
|
@@ -47,9 +48,9 @@ export const dashIndexRoutes = new Hono();
|
|
|
47
48
|
children: [
|
|
48
49
|
/*#__PURE__*/ _jsx("p", {
|
|
49
50
|
class: "text-sm text-muted-foreground",
|
|
50
|
-
children:
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
children: $__i18n._({
|
|
52
|
+
id: "M8kJqa",
|
|
53
|
+
message: "Drafts"
|
|
53
54
|
})
|
|
54
55
|
}),
|
|
55
56
|
/*#__PURE__*/ _jsx("p", {
|
|
@@ -63,17 +64,17 @@ export const dashIndexRoutes = new Hono();
|
|
|
63
64
|
children: [
|
|
64
65
|
/*#__PURE__*/ _jsx("p", {
|
|
65
66
|
class: "text-sm text-muted-foreground mb-2",
|
|
66
|
-
children:
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
children: $__i18n._({
|
|
68
|
+
id: "UDMjsP",
|
|
69
|
+
message: "Quick Actions"
|
|
69
70
|
})
|
|
70
71
|
}),
|
|
71
72
|
/*#__PURE__*/ _jsx("a", {
|
|
72
73
|
href: "/dash/posts/new",
|
|
73
74
|
class: "btn btn-primary w-full",
|
|
74
|
-
children:
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
children: $__i18n._({
|
|
76
|
+
id: "FGrimz",
|
|
77
|
+
message: "New Post"
|
|
77
78
|
})
|
|
78
79
|
})
|
|
79
80
|
]
|
|
@@ -81,17 +82,15 @@ export const dashIndexRoutes = new Hono();
|
|
|
81
82
|
]
|
|
82
83
|
}),
|
|
83
84
|
/*#__PURE__*/ _jsx("p", {
|
|
84
|
-
children: /*#__PURE__*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
/*#__PURE__*/ _jsx("a", {
|
|
85
|
+
children: /*#__PURE__*/ _jsx(Trans_, {
|
|
86
|
+
message: "Need help? Visit the <0>documentation</0>",
|
|
87
|
+
id: "Jed1wB",
|
|
88
|
+
components: {
|
|
89
|
+
0: /*#__PURE__*/ _jsx("a", {
|
|
90
90
|
href: "/docs",
|
|
91
|
-
class: "underline"
|
|
92
|
-
children: "documentation"
|
|
91
|
+
class: "underline"
|
|
93
92
|
})
|
|
94
|
-
|
|
93
|
+
}
|
|
95
94
|
})
|
|
96
95
|
})
|
|
97
96
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/routes/dash/media.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,QAAQ,EAAS,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/routes/dash/media.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,QAAQ,EAAS,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAOjD,KAAK,GAAG,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;AAE3D,eAAO,MAAM,WAAW,kDAAkB,CAAC"}
|