@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.
Files changed (153) hide show
  1. package/dist/app.d.ts.map +1 -1
  2. package/dist/app.js +112 -85
  3. package/dist/auth.d.ts +1 -0
  4. package/dist/auth.d.ts.map +1 -1
  5. package/dist/auth.js +2 -1
  6. package/dist/client.js +1 -1
  7. package/dist/db/schema.d.ts.map +1 -1
  8. package/dist/i18n/context.d.ts.map +1 -1
  9. package/dist/i18n/context.js +0 -3
  10. package/dist/i18n/detect.d.ts +0 -11
  11. package/dist/i18n/detect.d.ts.map +1 -1
  12. package/dist/i18n/detect.js +1 -52
  13. package/dist/i18n/i18n.d.ts +4 -14
  14. package/dist/i18n/i18n.d.ts.map +1 -1
  15. package/dist/i18n/i18n.js +19 -25
  16. package/dist/i18n/index.d.ts +1 -1
  17. package/dist/i18n/index.d.ts.map +1 -1
  18. package/dist/i18n/index.js +1 -1
  19. package/dist/i18n/middleware.d.ts +2 -5
  20. package/dist/i18n/middleware.d.ts.map +1 -1
  21. package/dist/i18n/middleware.js +12 -23
  22. package/dist/lib/constants.d.ts.map +1 -1
  23. package/dist/lib/schemas.d.ts.map +1 -1
  24. package/dist/lib/sse.d.ts +45 -17
  25. package/dist/lib/sse.d.ts.map +1 -1
  26. package/dist/lib/sse.js +77 -37
  27. package/dist/middleware/auth.d.ts.map +1 -1
  28. package/dist/routes/api/posts.js +0 -1
  29. package/dist/routes/api/upload.js +13 -3
  30. package/dist/routes/dash/collections.d.ts.map +1 -1
  31. package/dist/routes/dash/collections.js +134 -142
  32. package/dist/routes/dash/index.js +25 -25
  33. package/dist/routes/dash/media.d.ts.map +1 -1
  34. package/dist/routes/dash/media.js +60 -56
  35. package/dist/routes/dash/pages.d.ts.map +1 -1
  36. package/dist/routes/dash/pages.js +64 -66
  37. package/dist/routes/dash/posts.d.ts.map +1 -1
  38. package/dist/routes/dash/posts.js +50 -59
  39. package/dist/routes/dash/redirects.d.ts.map +1 -1
  40. package/dist/routes/dash/redirects.js +63 -60
  41. package/dist/routes/dash/settings.d.ts.map +1 -1
  42. package/dist/routes/dash/settings.js +249 -93
  43. package/dist/routes/feed/rss.js +6 -4
  44. package/dist/routes/pages/archive.js +60 -62
  45. package/dist/routes/pages/collection.js +8 -8
  46. package/dist/routes/pages/home.js +14 -14
  47. package/dist/routes/pages/page.js +7 -6
  48. package/dist/routes/pages/post.js +8 -8
  49. package/dist/routes/pages/search.js +25 -27
  50. package/dist/services/collection.d.ts.map +1 -1
  51. package/dist/services/index.d.ts.map +1 -1
  52. package/dist/services/media.d.ts.map +1 -1
  53. package/dist/services/post.d.ts.map +1 -1
  54. package/dist/services/redirect.d.ts.map +1 -1
  55. package/dist/services/settings.d.ts.map +1 -1
  56. package/dist/theme/components/ActionButtons.d.ts +1 -1
  57. package/dist/theme/components/ActionButtons.d.ts.map +1 -1
  58. package/dist/theme/components/ActionButtons.js +17 -21
  59. package/dist/theme/components/CrudPageHeader.d.ts.map +1 -1
  60. package/dist/theme/components/DangerZone.d.ts.map +1 -1
  61. package/dist/theme/components/DangerZone.js +12 -15
  62. package/dist/theme/components/EmptyState.d.ts.map +1 -1
  63. package/dist/theme/components/PageForm.d.ts.map +1 -1
  64. package/dist/theme/components/PageForm.js +58 -56
  65. package/dist/theme/components/Pagination.d.ts.map +1 -1
  66. package/dist/theme/components/Pagination.js +22 -25
  67. package/dist/theme/components/PostForm.d.ts +0 -1
  68. package/dist/theme/components/PostForm.d.ts.map +1 -1
  69. package/dist/theme/components/PostForm.js +85 -77
  70. package/dist/theme/components/PostList.d.ts.map +1 -1
  71. package/dist/theme/components/PostList.js +17 -17
  72. package/dist/theme/components/ThreadView.d.ts.map +1 -1
  73. package/dist/theme/components/ThreadView.js +15 -18
  74. package/dist/theme/components/TypeBadge.d.ts.map +1 -1
  75. package/dist/theme/components/TypeBadge.js +20 -20
  76. package/dist/theme/components/VisibilityBadge.d.ts.map +1 -1
  77. package/dist/theme/components/VisibilityBadge.js +14 -14
  78. package/dist/theme/components/index.d.ts +2 -2
  79. package/dist/theme/components/index.d.ts.map +1 -1
  80. package/dist/theme/layouts/BaseLayout.d.ts.map +1 -1
  81. package/dist/theme/layouts/BaseLayout.js +4 -2
  82. package/dist/theme/layouts/DashLayout.d.ts.map +1 -1
  83. package/dist/theme/layouts/DashLayout.js +29 -29
  84. package/dist/types/lingui-react-macro.d.js +9 -0
  85. package/dist/types.d.ts +2 -0
  86. package/dist/types.d.ts.map +1 -1
  87. package/dist/vendor/datastar.js +1606 -0
  88. package/package.json +7 -15
  89. package/src/app.tsx +222 -59
  90. package/src/auth.ts +5 -1
  91. package/src/client.ts +1 -1
  92. package/src/db/migrations/meta/0000_snapshot.json +16 -47
  93. package/src/db/migrations/meta/_journal.json +1 -1
  94. package/src/db/schema.ts +22 -7
  95. package/src/i18n/EXAMPLES.md +45 -23
  96. package/src/i18n/README.md +39 -25
  97. package/src/i18n/context.tsx +1 -4
  98. package/src/i18n/detect.ts +1 -67
  99. package/src/i18n/i18n.ts +15 -19
  100. package/src/i18n/index.ts +0 -3
  101. package/src/i18n/middleware.ts +12 -24
  102. package/src/lib/constants.ts +2 -1
  103. package/src/lib/image-processor.ts +14 -6
  104. package/src/lib/image.ts +2 -2
  105. package/src/lib/schemas.ts +7 -3
  106. package/src/lib/sse.ts +133 -51
  107. package/src/middleware/auth.ts +6 -2
  108. package/src/routes/api/posts.ts +9 -9
  109. package/src/routes/api/upload.ts +39 -10
  110. package/src/routes/dash/collections.tsx +249 -81
  111. package/src/routes/dash/index.tsx +22 -7
  112. package/src/routes/dash/media.tsx +94 -24
  113. package/src/routes/dash/pages.tsx +132 -54
  114. package/src/routes/dash/posts.tsx +99 -57
  115. package/src/routes/dash/redirects.tsx +117 -36
  116. package/src/routes/dash/settings.tsx +268 -55
  117. package/src/routes/feed/rss.ts +6 -4
  118. package/src/routes/pages/archive.tsx +78 -24
  119. package/src/routes/pages/collection.tsx +32 -8
  120. package/src/routes/pages/home.tsx +38 -10
  121. package/src/routes/pages/page.tsx +15 -5
  122. package/src/routes/pages/post.tsx +17 -6
  123. package/src/routes/pages/search.tsx +50 -13
  124. package/src/services/collection.ts +29 -8
  125. package/src/services/index.ts +4 -1
  126. package/src/services/media.ts +15 -3
  127. package/src/services/post.ts +37 -10
  128. package/src/services/redirect.ts +4 -1
  129. package/src/services/settings.ts +14 -3
  130. package/src/theme/components/ActionButtons.tsx +31 -15
  131. package/src/theme/components/CrudPageHeader.tsx +3 -4
  132. package/src/theme/components/DangerZone.tsx +19 -13
  133. package/src/theme/components/EmptyState.tsx +1 -5
  134. package/src/theme/components/PageForm.tsx +80 -25
  135. package/src/theme/components/Pagination.tsx +34 -31
  136. package/src/theme/components/PostForm.tsx +91 -27
  137. package/src/theme/components/PostList.tsx +23 -6
  138. package/src/theme/components/ThreadView.tsx +25 -10
  139. package/src/theme/components/TypeBadge.tsx +13 -4
  140. package/src/theme/components/VisibilityBadge.tsx +17 -5
  141. package/src/theme/components/index.ts +12 -2
  142. package/src/theme/layouts/BaseLayout.tsx +6 -5
  143. package/src/theme/layouts/DashLayout.tsx +71 -18
  144. package/src/types/lingui-react-macro.d.ts +34 -0
  145. package/src/types.ts +16 -4
  146. package/src/vendor/datastar.js +9 -0
  147. package/src/vendor/datastar.js.map +7 -0
  148. package/dist/plugin.d.ts +0 -3
  149. package/dist/plugin.d.ts.map +0 -1
  150. package/dist/plugin.js +0 -20
  151. package/dist/tailwind.d.ts +0 -12
  152. package/dist/tailwind.d.ts.map +0 -1
  153. 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 "../../i18n/index.js";
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 { t } = useLingui();
77
- const processingText = t({
78
- message: "Processing...",
79
- comment: "@context: Upload status - processing"
77
+ const { i18n: $__i18n, _: $__ } = $_useLingui();
78
+ const processingText = $__i18n._({
79
+ id: "k1ifdL",
80
+ message: "Processing..."
80
81
  });
81
- const uploadingText = t({
82
- message: "Uploading...",
83
- comment: "@context: Upload status - uploading"
82
+ const uploadingText = $__i18n._({
83
+ id: "GxkJXS",
84
+ message: "Uploading..."
84
85
  });
85
- const uploadText = t({
86
- message: "Upload",
87
- comment: "@context: Button to upload media file"
86
+ const uploadText = $__i18n._({
87
+ id: "ONWvwQ",
88
+ message: "Upload"
88
89
  });
89
- const errorText = t({
90
- message: "Upload failed. Please try again.",
91
- comment: "@context: Upload error message"
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: t({
258
- message: "Media",
259
- comment: "@context: Media main heading"
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: t({
288
- message: "Images are automatically optimized: resized to max 1920px, converted to WebP, and metadata stripped.",
289
- comment: "@context: Media upload instructions - auto optimization"
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: t({
300
- message: "No media uploaded yet.",
301
- comment: "@context: Empty state message when no media exists"
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 { t } = useLingui();
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: t({
366
- message: "Back",
367
- comment: "@context: Button to go back to media list"
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: t({
381
- message: "Preview",
382
- comment: "@context: Media detail section - preview"
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: t({
402
- message: "Click image to view full size",
403
- comment: "@context: Hint to click image for lightbox"
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: t({
425
- message: "URL",
426
- comment: "@context: Media detail section - URL"
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: t({
446
- message: "Copy",
447
- comment: "@context: Button to copy URL to clipboard"
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: t({
455
- message: "Use this URL to embed the media in your posts.",
456
- comment: "@context: Media URL helper text"
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: t({
469
- message: "Markdown",
470
- comment: "@context: Media detail section - Markdown snippet"
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('![${media.alt || media.originalName}](${url})')`,
488
- children: t({
489
- message: "Copy",
490
- comment: "@context: Button to copy Markdown to clipboard"
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: t({
500
- message: "Delete Media",
501
- comment: "@context: Button to delete media"
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: t({
506
- message: "Deleting this media will remove it permanently from storage.",
507
- comment: "@context: Warning message before deleting media"
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.redirect("/dash/media");
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;AAOjD,KAAK,GAAG,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;AAE3D,eAAO,MAAM,WAAW,kDAAkB,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 "../../i18n/index.js";
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 { VisibilitySchema, parseFormData } from "../../lib/schemas.js";
12
+ import { sse } from "../../lib/sse.js";
13
13
  export const pagesRoutes = new Hono();
14
14
  function PagesListContent({ pages }) {
15
- const { t } = useLingui();
15
+ const { i18n: $__i18n, _: $__ } = $_useLingui();
16
16
  return /*#__PURE__*/ _jsxs(_Fragment, {
17
17
  children: [
18
18
  /*#__PURE__*/ _jsx(CrudPageHeader, {
19
- title: t({
20
- message: "Pages",
21
- comment: "@context: Pages main heading"
19
+ title: $__i18n._({
20
+ id: "wRR604",
21
+ message: "Pages"
22
22
  }),
23
- ctaLabel: t({
24
- message: "New Page",
25
- comment: "@context: Button to create new page"
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: t({
31
- message: "No pages yet.",
32
- comment: "@context: Empty state message when no pages exist"
30
+ message: $__i18n._({
31
+ id: "LkvLQe",
32
+ message: "No pages yet."
33
33
  }),
34
- ctaText: t({
35
- message: "Create your first page",
36
- comment: "@context: Button in empty state to create first page"
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: t({
45
- message: "Edit",
46
- comment: "@context: Button to edit page"
44
+ editLabel: $__i18n._({
45
+ id: "ePK91l",
46
+ message: "Edit"
47
47
  }),
48
48
  viewHref: page.visibility !== "draft" && page.path ? `/${page.path}` : undefined,
49
- viewLabel: t({
50
- message: "View",
51
- comment: "@context: Button to view page on public site"
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 || t({
71
- message: "Untitled",
72
- comment: "@context: Default title for untitled page"
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 { t } = useLingui();
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: t({
95
- message: "New Page",
96
- comment: "@context: New page main heading"
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 { t } = useLingui();
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 || t({
117
- message: "Page",
118
- comment: "@context: Default page heading when untitled"
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: t({
133
- message: "Edit",
134
- comment: "@context: Button to edit page"
132
+ editLabel: $__i18n._({
133
+ id: "ePK91l",
134
+ message: "Edit"
135
135
  }),
136
136
  viewHref: page.visibility !== "draft" && page.path ? `/${page.path}` : undefined,
137
- viewLabel: t({
138
- message: "View",
139
- comment: "@context: Button to view page on public site"
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: t({
157
- message: "Delete Page",
158
- comment: "@context: Button to delete page"
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 { t } = useLingui();
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: t({
173
- message: "Edit Page",
174
- comment: "@context: Edit page main heading"
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 formData = await c.req.formData();
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 formData = await c.req.formData();
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.redirect("/dash/pages");
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;AAG5B,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"}
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"}