@jant/core 0.2.11 → 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/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/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 +13 -3
- 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 -25
- package/dist/routes/dash/media.d.ts.map +1 -1
- package/dist/routes/dash/media.js +60 -56
- package/dist/routes/dash/pages.d.ts.map +1 -1
- 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 +2 -2
- 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 +7 -15
- package/src/app.tsx +222 -59
- package/src/auth.ts +5 -1
- package/src/client.ts +1 -1
- package/src/db/migrations/meta/0000_snapshot.json +16 -47
- package/src/db/migrations/meta/_journal.json +1 -1
- package/src/db/schema.ts +22 -7
- package/src/i18n/EXAMPLES.md +45 -23
- package/src/i18n/README.md +39 -25
- 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 +14 -6
- package/src/lib/image.ts +2 -2
- package/src/lib/schemas.ts +7 -3
- package/src/lib/sse.ts +133 -51
- package/src/middleware/auth.ts +6 -2
- package/src/routes/api/posts.ts +9 -9
- package/src/routes/api/upload.ts +39 -10
- package/src/routes/dash/collections.tsx +249 -81
- package/src/routes/dash/index.tsx +22 -7
- package/src/routes/dash/media.tsx +94 -24
- package/src/routes/dash/pages.tsx +132 -54
- package/src/routes/dash/posts.tsx +99 -57
- package/src/routes/dash/redirects.tsx +117 -36
- package/src/routes/dash/settings.tsx +268 -55
- package/src/routes/feed/rss.ts +6 -4
- package/src/routes/pages/archive.tsx +78 -24
- package/src/routes/pages/collection.tsx +32 -8
- package/src/routes/pages/home.tsx +38 -10
- package/src/routes/pages/page.tsx +15 -5
- package/src/routes/pages/post.tsx +17 -6
- package/src/routes/pages/search.tsx +50 -13
- package/src/services/collection.ts +29 -8
- package/src/services/index.ts +4 -1
- package/src/services/media.ts +15 -3
- package/src/services/post.ts +37 -10
- package/src/services/redirect.ts +4 -1
- package/src/services/settings.ts +14 -3
- package/src/theme/components/ActionButtons.tsx +31 -15
- package/src/theme/components/CrudPageHeader.tsx +3 -4
- package/src/theme/components/DangerZone.tsx +19 -13
- package/src/theme/components/EmptyState.tsx +1 -5
- package/src/theme/components/PageForm.tsx +80 -25
- package/src/theme/components/Pagination.tsx +34 -31
- package/src/theme/components/PostForm.tsx +91 -27
- package/src/theme/components/PostList.tsx +23 -6
- package/src/theme/components/ThreadView.tsx +25 -10
- package/src/theme/components/TypeBadge.tsx +13 -4
- package/src/theme/components/VisibilityBadge.tsx +17 -5
- package/src/theme/components/index.ts +12 -2
- package/src/theme/layouts/BaseLayout.tsx +6 -5
- package/src/theme/layouts/DashLayout.tsx +71 -18
- package/src/types/lingui-react-macro.d.ts +34 -0
- package/src/types.ts +16 -4
- package/src/vendor/datastar.js +9 -0
- package/src/vendor/datastar.js.map +7 -0
- package/dist/plugin.d.ts +0 -3
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js +0 -20
- package/dist/tailwind.d.ts +0 -12
- package/dist/tailwind.d.ts.map +0 -1
- package/dist/tailwind.js +0 -15
|
@@ -5,11 +5,12 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "hono/jsx/jsx-
|
|
|
5
5
|
* Media management with Datastar-powered uploads.
|
|
6
6
|
* Uses SSE for real-time UI updates without page reloads.
|
|
7
7
|
*/ import { Hono } from "hono";
|
|
8
|
-
import { useLingui } from "
|
|
8
|
+
import { useLingui as $_useLingui } from "@jant/core/i18n";
|
|
9
9
|
import { DashLayout } from "../../theme/layouts/index.js";
|
|
10
10
|
import { EmptyState, DangerZone } from "../../theme/components/index.js";
|
|
11
11
|
import * as time from "../../lib/time.js";
|
|
12
12
|
import { getMediaUrl, getImageUrl } from "../../lib/image.js";
|
|
13
|
+
import { sse } from "../../lib/sse.js";
|
|
13
14
|
export const mediaRoutes = new Hono();
|
|
14
15
|
/**
|
|
15
16
|
* Format file size for display
|
|
@@ -73,22 +74,22 @@ export const mediaRoutes = new Hono();
|
|
|
73
74
|
* Uses plain JavaScript for upload state management (more reliable than Datastar signals
|
|
74
75
|
* for complex async flows like file uploads with SSE responses).
|
|
75
76
|
*/ function MediaListContent({ mediaList, r2PublicUrl, imageTransformUrl }) {
|
|
76
|
-
const {
|
|
77
|
-
const processingText =
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
78
|
+
const processingText = $__i18n._({
|
|
79
|
+
id: "k1ifdL",
|
|
80
|
+
message: "Processing..."
|
|
80
81
|
});
|
|
81
|
-
const uploadingText =
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
const uploadingText = $__i18n._({
|
|
83
|
+
id: "GxkJXS",
|
|
84
|
+
message: "Uploading..."
|
|
84
85
|
});
|
|
85
|
-
const uploadText =
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
const uploadText = $__i18n._({
|
|
87
|
+
id: "ONWvwQ",
|
|
88
|
+
message: "Upload"
|
|
88
89
|
});
|
|
89
|
-
const errorText =
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
const errorText = $__i18n._({
|
|
91
|
+
id: "pZq3aX",
|
|
92
|
+
message: "Upload failed. Please try again."
|
|
92
93
|
});
|
|
93
94
|
// Plain JavaScript upload handler - shows progress in the list
|
|
94
95
|
const uploadScript = `
|
|
@@ -254,9 +255,9 @@ function processSSEEvent(event) {
|
|
|
254
255
|
children: [
|
|
255
256
|
/*#__PURE__*/ _jsx("h1", {
|
|
256
257
|
class: "text-2xl font-semibold",
|
|
257
|
-
children:
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
children: $__i18n._({
|
|
259
|
+
id: "xYilR2",
|
|
260
|
+
message: "Media"
|
|
260
261
|
})
|
|
261
262
|
}),
|
|
262
263
|
/*#__PURE__*/ _jsxs("label", {
|
|
@@ -284,9 +285,9 @@ function processSSEEvent(event) {
|
|
|
284
285
|
children: /*#__PURE__*/ _jsx("section", {
|
|
285
286
|
class: "text-sm text-muted-foreground",
|
|
286
287
|
children: /*#__PURE__*/ _jsx("p", {
|
|
287
|
-
children:
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
children: $__i18n._({
|
|
289
|
+
id: "x+doid",
|
|
290
|
+
message: "Images are automatically optimized: resized to max 1920px, converted to WebP, and metadata stripped."
|
|
290
291
|
})
|
|
291
292
|
})
|
|
292
293
|
})
|
|
@@ -296,9 +297,9 @@ function processSSEEvent(event) {
|
|
|
296
297
|
children: mediaList.length === 0 ? /*#__PURE__*/ _jsx("div", {
|
|
297
298
|
id: "empty-state",
|
|
298
299
|
children: /*#__PURE__*/ _jsx(EmptyState, {
|
|
299
|
-
message:
|
|
300
|
-
|
|
301
|
-
|
|
300
|
+
message: $__i18n._({
|
|
301
|
+
id: "ST+lN2",
|
|
302
|
+
message: "No media uploaded yet."
|
|
302
303
|
})
|
|
303
304
|
})
|
|
304
305
|
}) : /*#__PURE__*/ _jsx("div", {
|
|
@@ -328,7 +329,7 @@ function processSSEEvent(event) {
|
|
|
328
329
|
/**
|
|
329
330
|
* View single media content
|
|
330
331
|
*/ function ViewMediaContent({ media, r2PublicUrl, imageTransformUrl }) {
|
|
331
|
-
const {
|
|
332
|
+
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
332
333
|
const url = getMediaUrl(media.id, media.r2Key, r2PublicUrl);
|
|
333
334
|
const thumbnailUrl = getImageUrl(url, imageTransformUrl, {
|
|
334
335
|
width: 600,
|
|
@@ -353,7 +354,8 @@ function processSSEEvent(event) {
|
|
|
353
354
|
formatSize(media.size),
|
|
354
355
|
" · ",
|
|
355
356
|
media.mimeType,
|
|
356
|
-
" ·
|
|
357
|
+
" ·",
|
|
358
|
+
" ",
|
|
357
359
|
time.formatDate(media.createdAt)
|
|
358
360
|
]
|
|
359
361
|
})
|
|
@@ -362,9 +364,9 @@ function processSSEEvent(event) {
|
|
|
362
364
|
/*#__PURE__*/ _jsx("a", {
|
|
363
365
|
href: "/dash/media",
|
|
364
366
|
class: "btn-outline",
|
|
365
|
-
children:
|
|
366
|
-
|
|
367
|
-
|
|
367
|
+
children: $__i18n._({
|
|
368
|
+
id: "iH8pgl",
|
|
369
|
+
message: "Back"
|
|
368
370
|
})
|
|
369
371
|
})
|
|
370
372
|
]
|
|
@@ -377,9 +379,9 @@ function processSSEEvent(event) {
|
|
|
377
379
|
children: [
|
|
378
380
|
/*#__PURE__*/ _jsx("header", {
|
|
379
381
|
children: /*#__PURE__*/ _jsx("h2", {
|
|
380
|
-
children:
|
|
381
|
-
|
|
382
|
-
|
|
382
|
+
children: $__i18n._({
|
|
383
|
+
id: "rdUucN",
|
|
384
|
+
message: "Preview"
|
|
383
385
|
})
|
|
384
386
|
})
|
|
385
387
|
}),
|
|
@@ -398,9 +400,9 @@ function processSSEEvent(event) {
|
|
|
398
400
|
}),
|
|
399
401
|
/*#__PURE__*/ _jsx("p", {
|
|
400
402
|
class: "text-xs text-muted-foreground mt-2",
|
|
401
|
-
children:
|
|
402
|
-
|
|
403
|
-
|
|
403
|
+
children: $__i18n._({
|
|
404
|
+
id: "M1RvTd",
|
|
405
|
+
message: "Click image to view full size"
|
|
404
406
|
})
|
|
405
407
|
})
|
|
406
408
|
]
|
|
@@ -421,9 +423,9 @@ function processSSEEvent(event) {
|
|
|
421
423
|
children: [
|
|
422
424
|
/*#__PURE__*/ _jsx("header", {
|
|
423
425
|
children: /*#__PURE__*/ _jsx("h2", {
|
|
424
|
-
children:
|
|
425
|
-
|
|
426
|
-
|
|
426
|
+
children: $__i18n._({
|
|
427
|
+
id: "IagCbF",
|
|
428
|
+
message: "URL"
|
|
427
429
|
})
|
|
428
430
|
})
|
|
429
431
|
}),
|
|
@@ -442,18 +444,18 @@ function processSSEEvent(event) {
|
|
|
442
444
|
type: "button",
|
|
443
445
|
class: "btn-outline",
|
|
444
446
|
onclick: `navigator.clipboard.writeText('${url}')`,
|
|
445
|
-
children:
|
|
446
|
-
|
|
447
|
-
|
|
447
|
+
children: $__i18n._({
|
|
448
|
+
id: "he3ygx",
|
|
449
|
+
message: "Copy"
|
|
448
450
|
})
|
|
449
451
|
})
|
|
450
452
|
]
|
|
451
453
|
}),
|
|
452
454
|
/*#__PURE__*/ _jsx("p", {
|
|
453
455
|
class: "text-xs text-muted-foreground mt-2",
|
|
454
|
-
children:
|
|
455
|
-
|
|
456
|
-
|
|
456
|
+
children: $__i18n._({
|
|
457
|
+
id: "K9NcLu",
|
|
458
|
+
message: "Use this URL to embed the media in your posts."
|
|
457
459
|
})
|
|
458
460
|
})
|
|
459
461
|
]
|
|
@@ -465,9 +467,9 @@ function processSSEEvent(event) {
|
|
|
465
467
|
children: [
|
|
466
468
|
/*#__PURE__*/ _jsx("header", {
|
|
467
469
|
children: /*#__PURE__*/ _jsx("h2", {
|
|
468
|
-
children:
|
|
469
|
-
|
|
470
|
-
|
|
470
|
+
children: $__i18n._({
|
|
471
|
+
id: "u6Hp4N",
|
|
472
|
+
message: "Markdown"
|
|
471
473
|
})
|
|
472
474
|
})
|
|
473
475
|
}),
|
|
@@ -485,9 +487,9 @@ function processSSEEvent(event) {
|
|
|
485
487
|
type: "button",
|
|
486
488
|
class: "btn-outline",
|
|
487
489
|
onclick: `navigator.clipboard.writeText('')`,
|
|
488
|
-
children:
|
|
489
|
-
|
|
490
|
-
|
|
490
|
+
children: $__i18n._({
|
|
491
|
+
id: "he3ygx",
|
|
492
|
+
message: "Copy"
|
|
491
493
|
})
|
|
492
494
|
})
|
|
493
495
|
]
|
|
@@ -496,15 +498,15 @@ function processSSEEvent(event) {
|
|
|
496
498
|
]
|
|
497
499
|
}),
|
|
498
500
|
/*#__PURE__*/ _jsx(DangerZone, {
|
|
499
|
-
actionLabel:
|
|
500
|
-
|
|
501
|
-
|
|
501
|
+
actionLabel: $__i18n._({
|
|
502
|
+
id: "wM5UXj",
|
|
503
|
+
message: "Delete Media"
|
|
502
504
|
}),
|
|
503
505
|
formAction: `/dash/media/${media.id}/delete`,
|
|
504
506
|
confirmMessage: "Are you sure you want to delete this media?",
|
|
505
|
-
description:
|
|
506
|
-
|
|
507
|
-
|
|
507
|
+
description: $__i18n._({
|
|
508
|
+
id: "E80cJw",
|
|
509
|
+
message: "Deleting this media will remove it permanently from storage."
|
|
508
510
|
})
|
|
509
511
|
})
|
|
510
512
|
]
|
|
@@ -579,5 +581,7 @@ mediaRoutes.post("/:id/delete", async (c)=>{
|
|
|
579
581
|
}
|
|
580
582
|
// Delete from database
|
|
581
583
|
await c.var.services.media.delete(id);
|
|
582
|
-
return c
|
|
584
|
+
return sse(c, async (stream)=>{
|
|
585
|
+
await stream.redirect("/dash/media");
|
|
586
|
+
});
|
|
583
587
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../../src/routes/dash/pages.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,QAAQ,EAAQ,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../../src/routes/dash/pages.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,QAAQ,EAAQ,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAejD,KAAK,GAAG,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;AAE3D,eAAO,MAAM,WAAW,kDAAkB,CAAC"}
|
|
@@ -4,36 +4,36 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "hono/jsx/jsx-
|
|
|
4
4
|
*
|
|
5
5
|
* Management for custom pages (posts with type="page")
|
|
6
6
|
*/ import { Hono } from "hono";
|
|
7
|
-
import { useLingui } from "
|
|
7
|
+
import { useLingui as $_useLingui } from "@jant/core/i18n";
|
|
8
8
|
import { DashLayout } from "../../theme/layouts/index.js";
|
|
9
9
|
import { PageForm, VisibilityBadge, EmptyState, ListItemRow, ActionButtons, CrudPageHeader, DangerZone } from "../../theme/components/index.js";
|
|
10
10
|
import * as sqid from "../../lib/sqid.js";
|
|
11
11
|
import * as time from "../../lib/time.js";
|
|
12
|
-
import {
|
|
12
|
+
import { sse } from "../../lib/sse.js";
|
|
13
13
|
export const pagesRoutes = new Hono();
|
|
14
14
|
function PagesListContent({ pages }) {
|
|
15
|
-
const {
|
|
15
|
+
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
16
16
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
17
17
|
children: [
|
|
18
18
|
/*#__PURE__*/ _jsx(CrudPageHeader, {
|
|
19
|
-
title:
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
title: $__i18n._({
|
|
20
|
+
id: "wRR604",
|
|
21
|
+
message: "Pages"
|
|
22
22
|
}),
|
|
23
|
-
ctaLabel:
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
ctaLabel: $__i18n._({
|
|
24
|
+
id: "GrZ6fH",
|
|
25
|
+
message: "New Page"
|
|
26
26
|
}),
|
|
27
27
|
ctaHref: "/dash/pages/new"
|
|
28
28
|
}),
|
|
29
29
|
pages.length === 0 ? /*#__PURE__*/ _jsx(EmptyState, {
|
|
30
|
-
message:
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
message: $__i18n._({
|
|
31
|
+
id: "LkvLQe",
|
|
32
|
+
message: "No pages yet."
|
|
33
33
|
}),
|
|
34
|
-
ctaText:
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
ctaText: $__i18n._({
|
|
35
|
+
id: "0JkyS7",
|
|
36
|
+
message: "Create your first page"
|
|
37
37
|
}),
|
|
38
38
|
ctaHref: "/dash/pages/new"
|
|
39
39
|
}) : /*#__PURE__*/ _jsx("div", {
|
|
@@ -41,14 +41,14 @@ function PagesListContent({ pages }) {
|
|
|
41
41
|
children: pages.map((page)=>/*#__PURE__*/ _jsxs(ListItemRow, {
|
|
42
42
|
actions: /*#__PURE__*/ _jsx(ActionButtons, {
|
|
43
43
|
editHref: `/dash/pages/${sqid.encode(page.id)}/edit`,
|
|
44
|
-
editLabel:
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
editLabel: $__i18n._({
|
|
45
|
+
id: "ePK91l",
|
|
46
|
+
message: "Edit"
|
|
47
47
|
}),
|
|
48
48
|
viewHref: page.visibility !== "draft" && page.path ? `/${page.path}` : undefined,
|
|
49
|
-
viewLabel:
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
viewLabel: $__i18n._({
|
|
50
|
+
id: "jpctdh",
|
|
51
|
+
message: "View"
|
|
52
52
|
})
|
|
53
53
|
}),
|
|
54
54
|
children: [
|
|
@@ -67,9 +67,9 @@ function PagesListContent({ pages }) {
|
|
|
67
67
|
/*#__PURE__*/ _jsx("a", {
|
|
68
68
|
href: `/dash/pages/${sqid.encode(page.id)}`,
|
|
69
69
|
class: "font-medium hover:underline",
|
|
70
|
-
children: page.title ||
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
children: page.title || $__i18n._({
|
|
71
|
+
id: "wja8aL",
|
|
72
|
+
message: "Untitled"
|
|
73
73
|
})
|
|
74
74
|
}),
|
|
75
75
|
/*#__PURE__*/ _jsxs("p", {
|
|
@@ -86,14 +86,14 @@ function PagesListContent({ pages }) {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
function NewPageContent() {
|
|
89
|
-
const {
|
|
89
|
+
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
90
90
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
91
91
|
children: [
|
|
92
92
|
/*#__PURE__*/ _jsx("h1", {
|
|
93
93
|
class: "text-2xl font-semibold mb-6",
|
|
94
|
-
children:
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
children: $__i18n._({
|
|
95
|
+
id: "GrZ6fH",
|
|
96
|
+
message: "New Page"
|
|
97
97
|
})
|
|
98
98
|
}),
|
|
99
99
|
/*#__PURE__*/ _jsx(PageForm, {
|
|
@@ -103,7 +103,7 @@ function NewPageContent() {
|
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
function ViewPageContent({ page }) {
|
|
106
|
-
const {
|
|
106
|
+
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
107
107
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
108
108
|
children: [
|
|
109
109
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -113,9 +113,9 @@ function ViewPageContent({ page }) {
|
|
|
113
113
|
children: [
|
|
114
114
|
/*#__PURE__*/ _jsx("h1", {
|
|
115
115
|
class: "text-2xl font-semibold",
|
|
116
|
-
children: page.title ||
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
children: page.title || $__i18n._({
|
|
117
|
+
id: "6WdDG7",
|
|
118
|
+
message: "Page"
|
|
119
119
|
})
|
|
120
120
|
}),
|
|
121
121
|
page.path && /*#__PURE__*/ _jsxs("p", {
|
|
@@ -129,14 +129,14 @@ function ViewPageContent({ page }) {
|
|
|
129
129
|
}),
|
|
130
130
|
/*#__PURE__*/ _jsx(ActionButtons, {
|
|
131
131
|
editHref: `/dash/pages/${sqid.encode(page.id)}/edit`,
|
|
132
|
-
editLabel:
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
editLabel: $__i18n._({
|
|
133
|
+
id: "ePK91l",
|
|
134
|
+
message: "Edit"
|
|
135
135
|
}),
|
|
136
136
|
viewHref: page.visibility !== "draft" && page.path ? `/${page.path}` : undefined,
|
|
137
|
-
viewLabel:
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
viewLabel: $__i18n._({
|
|
138
|
+
id: "jpctdh",
|
|
139
|
+
message: "View"
|
|
140
140
|
})
|
|
141
141
|
})
|
|
142
142
|
]
|
|
@@ -153,9 +153,9 @@ function ViewPageContent({ page }) {
|
|
|
153
153
|
})
|
|
154
154
|
}),
|
|
155
155
|
/*#__PURE__*/ _jsx(DangerZone, {
|
|
156
|
-
actionLabel:
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
actionLabel: $__i18n._({
|
|
157
|
+
id: "4KzVT6",
|
|
158
|
+
message: "Delete Page"
|
|
159
159
|
}),
|
|
160
160
|
formAction: `/dash/pages/${sqid.encode(page.id)}/delete`,
|
|
161
161
|
confirmMessage: "Are you sure you want to delete this page?"
|
|
@@ -164,14 +164,14 @@ function ViewPageContent({ page }) {
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
function EditPageContent({ page }) {
|
|
167
|
-
const {
|
|
167
|
+
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
168
168
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
169
169
|
children: [
|
|
170
170
|
/*#__PURE__*/ _jsx("h1", {
|
|
171
171
|
class: "text-2xl font-semibold mb-6",
|
|
172
|
-
children:
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
children: $__i18n._({
|
|
173
|
+
id: "U5v6Gh",
|
|
174
|
+
message: "Edit Page"
|
|
175
175
|
})
|
|
176
176
|
}),
|
|
177
177
|
/*#__PURE__*/ _jsx(PageForm, {
|
|
@@ -215,19 +215,17 @@ pagesRoutes.get("/new", async (c)=>{
|
|
|
215
215
|
});
|
|
216
216
|
// Create page
|
|
217
217
|
pagesRoutes.post("/", async (c)=>{
|
|
218
|
-
const
|
|
219
|
-
const title = formData.get("title");
|
|
220
|
-
const content = formData.get("content");
|
|
221
|
-
const visibility = parseFormData(formData, "visibility", VisibilitySchema);
|
|
222
|
-
const path = formData.get("path");
|
|
218
|
+
const body = await c.req.json();
|
|
223
219
|
const page = await c.var.services.posts.create({
|
|
224
220
|
type: "page",
|
|
225
|
-
title,
|
|
226
|
-
content,
|
|
227
|
-
visibility,
|
|
228
|
-
path: path.toLowerCase().replace(/[^a-z0-9-]/g, "-")
|
|
221
|
+
title: body.title,
|
|
222
|
+
content: body.content,
|
|
223
|
+
visibility: body.visibility,
|
|
224
|
+
path: body.path.toLowerCase().replace(/[^a-z0-9-]/g, "-")
|
|
225
|
+
});
|
|
226
|
+
return sse(c, async (stream)=>{
|
|
227
|
+
await stream.redirect(`/dash/pages/${sqid.encode(page.id)}`);
|
|
229
228
|
});
|
|
230
|
-
return c.redirect(`/dash/pages/${sqid.encode(page.id)}`);
|
|
231
229
|
});
|
|
232
230
|
// View single page
|
|
233
231
|
pagesRoutes.get("/:id", async (c)=>{
|
|
@@ -267,24 +265,24 @@ pagesRoutes.get("/:id/edit", async (c)=>{
|
|
|
267
265
|
pagesRoutes.post("/:id", async (c)=>{
|
|
268
266
|
const id = sqid.decode(c.req.param("id"));
|
|
269
267
|
if (!id) return c.notFound();
|
|
270
|
-
const
|
|
271
|
-
const title = formData.get("title");
|
|
272
|
-
const content = formData.get("content");
|
|
273
|
-
const visibility = parseFormData(formData, "visibility", VisibilitySchema);
|
|
274
|
-
const path = formData.get("path");
|
|
268
|
+
const body = await c.req.json();
|
|
275
269
|
await c.var.services.posts.update(id, {
|
|
276
270
|
type: "page",
|
|
277
|
-
title,
|
|
278
|
-
content,
|
|
279
|
-
visibility,
|
|
280
|
-
path: path.toLowerCase().replace(/[^a-z0-9-]/g, "-")
|
|
271
|
+
title: body.title,
|
|
272
|
+
content: body.content,
|
|
273
|
+
visibility: body.visibility,
|
|
274
|
+
path: body.path.toLowerCase().replace(/[^a-z0-9-]/g, "-")
|
|
275
|
+
});
|
|
276
|
+
return sse(c, async (stream)=>{
|
|
277
|
+
await stream.redirect(`/dash/pages/${sqid.encode(id)}`);
|
|
281
278
|
});
|
|
282
|
-
return c.redirect(`/dash/pages/${sqid.encode(id)}`);
|
|
283
279
|
});
|
|
284
280
|
// Delete page
|
|
285
281
|
pagesRoutes.post("/:id/delete", async (c)=>{
|
|
286
282
|
const id = sqid.decode(c.req.param("id"));
|
|
287
283
|
if (!id) return c.notFound();
|
|
288
284
|
await c.var.services.posts.delete(id);
|
|
289
|
-
return c
|
|
285
|
+
return sse(c, async (stream)=>{
|
|
286
|
+
await stream.redirect("/dash/pages");
|
|
287
|
+
});
|
|
290
288
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posts.d.ts","sourceRoot":"","sources":["../../../src/routes/dash/posts.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"posts.d.ts","sourceRoot":"","sources":["../../../src/routes/dash/posts.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,QAAQ,EAAQ,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAWjD,KAAK,GAAG,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;AAE3D,eAAO,MAAM,WAAW,kDAAkB,CAAC"}
|