@ampless/admin 0.2.0-alpha.2 → 0.2.0-alpha.21

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 (49) hide show
  1. package/README.ja.md +73 -0
  2. package/README.md +3 -0
  3. package/dist/api/index.d.ts +1 -1
  4. package/dist/chunk-2ITWLRYF.js +38 -0
  5. package/dist/chunk-5JKOPRCO.js +41 -0
  6. package/dist/chunk-5Q6KVRZ2.js +250 -0
  7. package/dist/chunk-7IR4F7GA.js +6 -0
  8. package/dist/chunk-A3SWBQA6.js +71 -0
  9. package/dist/chunk-BC4B6DLO.js +21 -0
  10. package/dist/chunk-BWFCQNPU.js +1264 -0
  11. package/dist/chunk-CQY55RDG.js +48 -0
  12. package/dist/chunk-CVJCMTYB.js +1197 -0
  13. package/dist/chunk-JOASK4AM.js +360 -0
  14. package/dist/{chunk-TJR3ALRJ.js → chunk-OSUTPPAU.js} +171 -68
  15. package/dist/chunk-QXJIIBUQ.js +21 -0
  16. package/dist/chunk-S66L5CDS.js +335 -0
  17. package/dist/chunk-SRNH2IVA.js +149 -0
  18. package/dist/chunk-TZWSXAHD.js +32 -0
  19. package/dist/chunk-VXEVLHGL.js +10 -0
  20. package/dist/chunk-W6BXESPW.js +198 -0
  21. package/dist/chunk-XY4JWSMS.js +33 -0
  22. package/dist/components/admin-dashboard.d.ts +10 -0
  23. package/dist/components/admin-dashboard.js +9 -0
  24. package/dist/components/edit-post-view.d.ts +9 -0
  25. package/dist/components/edit-post-view.js +14 -0
  26. package/dist/components/index.d.ts +40 -21
  27. package/dist/components/index.js +32 -15
  28. package/dist/components/login-view.d.ts +5 -0
  29. package/dist/components/login-view.js +9 -0
  30. package/dist/components/mcp-tokens-view.d.ts +22 -0
  31. package/dist/components/mcp-tokens-view.js +9 -0
  32. package/dist/components/media-view.d.ts +5 -0
  33. package/dist/components/media-view.js +12 -0
  34. package/dist/components/new-post-view.d.ts +5 -0
  35. package/dist/components/new-post-view.js +14 -0
  36. package/dist/components/posts-list-view.d.ts +5 -0
  37. package/dist/components/posts-list-view.js +11 -0
  38. package/dist/components/users-list-view.d.ts +7 -0
  39. package/dist/components/users-list-view.js +9 -0
  40. package/dist/{i18n-ByHM_Bho.d.ts → i18n-MWvAMHzn.d.ts} +253 -2
  41. package/dist/index.d.ts +14 -9
  42. package/dist/index.js +18 -10
  43. package/dist/lib/theme-actions.d.ts +17 -0
  44. package/dist/lib/theme-actions.js +7 -0
  45. package/dist/metafile-esm.json +1 -1
  46. package/dist/pages/index.d.ts +67 -15
  47. package/dist/pages/index.js +147 -659
  48. package/package.json +12 -9
  49. package/dist/chunk-T2RSMFOI.js +0 -2074
package/README.ja.md ADDED
@@ -0,0 +1,73 @@
1
+ > English: [README.md](./README.md)
2
+ >
3
+
4
+ # @ampless/admin
5
+
6
+ [ampless](https://github.com/heavymoons/ampless) 向け管理 UI ライブラリ。投稿エディター(Tiptap + Markdown + HTML)、メディアマネージャー(S3 + 画像処理)、サイト / テーマ設定、ロケール対応 UI 文字列、そしてすべてを結びつける Next.js ページファクトリーを提供します。
7
+
8
+ > **プレリリース / アルファ版。** v1.0 まではマイナーバージョンでも破壊的変更が入る可能性があります。
9
+
10
+ ## なぜライブラリなのか?
11
+
12
+ 以前は管理 UI がテンプレートプロジェクト内に存在していました。バグ修正や機能追加のたびに、テンプレートと各サイト間でファイルをコピーし続ける必要がありました。`@ampless/admin` として切り出すことで、プロジェクトは `npm update @ampless/admin` を実行するだけで改善を取り込めます — 他の依存パッケージと同じアップグレードフローです。
13
+
14
+ ## インストール
15
+
16
+ ```bash
17
+ npm install @ampless/admin@alpha @ampless/runtime@alpha ampless@alpha
18
+ ```
19
+
20
+ ピア依存: `next`、`react`、`react-dom`、`aws-amplify`、`@aws-amplify/adapter-nextjs`。
21
+
22
+ ## 接続方法
23
+
24
+ Next.js プロジェクトに `lib/admin.ts` を作成します:
25
+
26
+ ```ts
27
+ import outputs from '../amplify_outputs.json'
28
+ import cmsConfig from '../cms.config'
29
+ import { createAdmin } from '@ampless/admin'
30
+ import { ampless } from './ampless'
31
+
32
+ export const admin = createAdmin({ outputs, cmsConfig, ampless })
33
+ export const t = admin.t
34
+ ```
35
+
36
+ 各管理ルートを薄いシェルとして公開します:
37
+
38
+ ```tsx
39
+ // app/(admin)/admin/posts/page.tsx
40
+ import { admin } from '@/lib/admin'
41
+ import { createPostsListPage } from '@ampless/admin/pages'
42
+ export default createPostsListPage(admin)
43
+ ```
44
+
45
+ ```ts
46
+ // app/api/media/[...path]/route.ts
47
+ import { admin } from '@/lib/admin'
48
+ import { createMediaProxyRoute } from '@ampless/admin/api'
49
+ export const { GET } = createMediaProxyRoute(admin)
50
+ export const runtime = 'nodejs'
51
+ ```
52
+
53
+ ## サブパス
54
+
55
+ | サブパス | 内容 |
56
+ | ----------------------------- | --------------------------------------------------- |
57
+ | `@ampless/admin` | `createAdmin` ファクトリー + `Admin` インターフェース |
58
+ | `@ampless/admin/pages` | ページファクトリー — 管理ルートごとに 1 つ |
59
+ | `@ampless/admin/api` | API ルートファクトリー(`createMediaProxyRoute` など)|
60
+ | `@ampless/admin/components` | 高度な接続用フォーム / エディターコンポーネント |
61
+
62
+ ## ロケール
63
+
64
+ `createAdmin({ locale: 'ja' })` で管理 UI 文字列を日本語に切り替えます。
65
+ オブジェクトリテラルを渡すと個別の文字列をオーバーライドできます:
66
+
67
+ ```ts
68
+ createAdmin({
69
+ outputs,
70
+ cmsConfig,
71
+ locale: { sidebar: { brand: 'MySite Admin' } },
72
+ })
73
+ ```
package/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ > 日本語版: [README.ja.md](./README.ja.md)
2
+ >
3
+
1
4
  # @ampless/admin
2
5
 
3
6
  Admin UI library for [ampless](https://github.com/heavymoons/ampless): post
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from 'next/server';
2
2
  import { Admin } from '../index.js';
3
3
  import 'ampless';
4
4
  import '@ampless/runtime';
5
- import '../i18n-ByHM_Bho.js';
5
+ import '../i18n-MWvAMHzn.js';
6
6
  import '@aws-amplify/adapter-nextjs';
7
7
 
8
8
  /**
@@ -0,0 +1,38 @@
1
+ // src/lib/media.ts
2
+ var state = { outputs: null, cmsConfig: null };
3
+ function setAdminMediaContext(outputs, cmsConfig) {
4
+ state.outputs = outputs;
5
+ state.cmsConfig = cmsConfig;
6
+ }
7
+ function publicMediaUrl(input) {
8
+ if (/^https?:\/\//.test(input)) return input;
9
+ let path = input.replace(/^\/+/, "");
10
+ if (path.startsWith("public/")) path = path.slice("public/".length);
11
+ const { outputs, cmsConfig } = state;
12
+ const delivery = cmsConfig?.media?.delivery ?? "nextjs";
13
+ if (delivery !== "s3-direct") return `/api/media/${path}`;
14
+ const storage = outputs?.storage;
15
+ if (!storage) return `/api/media/${path}`;
16
+ return `https://${storage.bucket_name}.s3.${storage.aws_region}.amazonaws.com/public/${path}`;
17
+ }
18
+ function createMedia(outputs, cmsConfig) {
19
+ const storage = outputs.storage;
20
+ function s3DirectUrl(path) {
21
+ if (!storage) return `/api/media/${path}`;
22
+ return `https://${storage.bucket_name}.s3.${storage.aws_region}.amazonaws.com/public/${path}`;
23
+ }
24
+ function urlFor(input) {
25
+ if (/^https?:\/\//.test(input)) return input;
26
+ let path = input.replace(/^\/+/, "");
27
+ if (path.startsWith("public/")) path = path.slice("public/".length);
28
+ const delivery = cmsConfig.media?.delivery ?? "nextjs";
29
+ return delivery === "s3-direct" ? s3DirectUrl(path) : `/api/media/${path}`;
30
+ }
31
+ return { publicMediaUrl: urlFor };
32
+ }
33
+
34
+ export {
35
+ setAdminMediaContext,
36
+ publicMediaUrl,
37
+ createMedia
38
+ };
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+ import {
3
+ PostForm
4
+ } from "./chunk-CVJCMTYB.js";
5
+ import {
6
+ readAdminSiteIdFromCookie
7
+ } from "./chunk-TZWSXAHD.js";
8
+ import {
9
+ useT
10
+ } from "./chunk-XY4JWSMS.js";
11
+
12
+ // src/components/edit-post-view.tsx
13
+ import { useEffect, useState, use } from "react";
14
+ import { notFound } from "next/navigation";
15
+ import { getPostById } from "ampless";
16
+ import { jsx, jsxs } from "react/jsx-runtime";
17
+ function EditPostPage({ params }) {
18
+ const t = useT();
19
+ const { postId } = use(params);
20
+ const [post, setPost] = useState(null);
21
+ const [loading, setLoading] = useState(true);
22
+ const [missing, setMissing] = useState(false);
23
+ useEffect(() => {
24
+ const siteId = readAdminSiteIdFromCookie();
25
+ getPostById(postId, { siteId }).then((p) => {
26
+ if (!p) setMissing(true);
27
+ else setPost(p);
28
+ }).finally(() => setLoading(false));
29
+ }, [postId]);
30
+ if (loading)
31
+ return /* @__PURE__ */ jsx("div", { className: "mx-auto max-w-7xl p-4 md:p-8", children: t("common.loading") });
32
+ if (missing) notFound();
33
+ return /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-7xl p-4 md:p-8", children: [
34
+ /* @__PURE__ */ jsx("h1", { className: "mb-6 text-2xl font-bold md:mb-8 md:text-3xl", children: t("posts.form.editTitle") }),
35
+ post && /* @__PURE__ */ jsx(PostForm, { post })
36
+ ] });
37
+ }
38
+
39
+ export {
40
+ EditPostPage
41
+ };
@@ -0,0 +1,250 @@
1
+ 'use client';
2
+ import {
3
+ ImageUploadDialog,
4
+ getMediaProcessingDefaults
5
+ } from "./chunk-S66L5CDS.js";
6
+ import {
7
+ publicMediaUrl
8
+ } from "./chunk-2ITWLRYF.js";
9
+ import {
10
+ useT
11
+ } from "./chunk-XY4JWSMS.js";
12
+
13
+ // src/components/media-uploader.tsx
14
+ import { useState, useEffect, useCallback, useRef } from "react";
15
+ import { uploadData, list, remove, isCancelError } from "aws-amplify/storage";
16
+ import { processImage } from "ampless/media";
17
+ import { Button, Input } from "@ampless/runtime/ui";
18
+ import { Trash2, Copy, Check, FileText, Code2 } from "lucide-react";
19
+ import { jsx, jsxs } from "react/jsx-runtime";
20
+ var IMAGE_EXT_RE = /\.(jpe?g|png|gif|webp|avif|svg|bmp|tiff?)$/i;
21
+ var STYLESHEET_EXT_RE = /\.css$/i;
22
+ var SCRIPT_EXT_RE = /\.m?js$/i;
23
+ function getExtension(path) {
24
+ const dot = path.lastIndexOf(".");
25
+ return dot >= 0 ? path.slice(dot + 1).toUpperCase() : "FILE";
26
+ }
27
+ function snippetFor(url, path) {
28
+ if (IMAGE_EXT_RE.test(path)) {
29
+ return `<img src="${url}" alt="" />`;
30
+ }
31
+ if (STYLESHEET_EXT_RE.test(path)) {
32
+ return `<link rel="stylesheet" href="${url}" />`;
33
+ }
34
+ if (SCRIPT_EXT_RE.test(path)) {
35
+ return `<script src="${url}"></script>`;
36
+ }
37
+ return url;
38
+ }
39
+ function sanitizeName(name) {
40
+ return name.replace(/[ -]/g, "").replace(/[\\/:*?"<>|]/g, "_").replace(/\s+/g, "_").replace(/^\.+/, "_").slice(0, 200) || "upload";
41
+ }
42
+ function MediaUploader() {
43
+ const t = useT();
44
+ const [items, setItems] = useState([]);
45
+ const [queue, setQueue] = useState([]);
46
+ const [uploading, setUploading] = useState(false);
47
+ const [error, setError] = useState(null);
48
+ const [copiedPath, setCopiedPath] = useState(null);
49
+ const uploadTaskRef = useRef(null);
50
+ const cancelTokenRef = useRef({ cancelled: false });
51
+ const refresh = useCallback(async () => {
52
+ try {
53
+ const result = await list({ path: "public/media/" });
54
+ setItems(
55
+ result.items.map((item) => ({
56
+ path: item.path,
57
+ url: publicMediaUrl(item.path)
58
+ }))
59
+ );
60
+ } catch (err) {
61
+ setError(err instanceof Error ? err.message : String(err));
62
+ }
63
+ }, []);
64
+ useEffect(() => {
65
+ refresh();
66
+ }, [refresh]);
67
+ function handleFiles(e) {
68
+ const files = Array.from(e.target.files ?? []);
69
+ e.target.value = "";
70
+ if (files.length === 0) return;
71
+ setError(null);
72
+ setQueue((prev) => [...prev, ...files]);
73
+ }
74
+ async function handleDialogConfirm(file, options) {
75
+ const token = { cancelled: false };
76
+ cancelTokenRef.current = token;
77
+ setUploading(true);
78
+ setError(null);
79
+ let advance = true;
80
+ try {
81
+ const processed = await processImage(file, options);
82
+ if (token.cancelled) {
83
+ advance = false;
84
+ return;
85
+ }
86
+ const safeName = sanitizeName(processed.suggestedName);
87
+ const now = /* @__PURE__ */ new Date();
88
+ const yyyy = now.getFullYear();
89
+ const mm = String(now.getMonth() + 1).padStart(2, "0");
90
+ const path = `public/media/${yyyy}/${mm}/${Date.now()}-${safeName}`;
91
+ const task = uploadData({
92
+ path,
93
+ data: processed.blob,
94
+ options: { contentType: processed.mime }
95
+ });
96
+ uploadTaskRef.current = task;
97
+ await task.result;
98
+ await refresh();
99
+ } catch (err) {
100
+ if (isCancelError(err) || token.cancelled) {
101
+ advance = false;
102
+ } else {
103
+ setError(err instanceof Error ? err.message : String(err));
104
+ }
105
+ } finally {
106
+ uploadTaskRef.current = null;
107
+ setUploading(false);
108
+ if (advance) {
109
+ setQueue((prev) => prev.slice(1));
110
+ }
111
+ }
112
+ }
113
+ function handleDialogSkip() {
114
+ if (uploading) return;
115
+ setQueue((prev) => prev.slice(1));
116
+ }
117
+ function handleDialogCancel() {
118
+ cancelTokenRef.current.cancelled = true;
119
+ uploadTaskRef.current?.cancel();
120
+ setQueue([]);
121
+ }
122
+ async function handleDelete(path) {
123
+ if (!confirm(t("media.deleteConfirm"))) return;
124
+ try {
125
+ await remove({ path });
126
+ await refresh();
127
+ } catch (err) {
128
+ setError(err instanceof Error ? err.message : String(err));
129
+ }
130
+ }
131
+ async function handleCopy(item, mode) {
132
+ const text = mode === "url" ? item.url : snippetFor(item.url, item.path);
133
+ await navigator.clipboard.writeText(text);
134
+ const key = `${item.path}:${mode}`;
135
+ setCopiedPath(key);
136
+ setTimeout(() => setCopiedPath((p) => p === key ? null : p), 1500);
137
+ }
138
+ const currentFile = queue[0] ?? null;
139
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
140
+ /* @__PURE__ */ jsxs("div", { className: "rounded-md border p-4", children: [
141
+ /* @__PURE__ */ jsx(
142
+ Input,
143
+ {
144
+ type: "file",
145
+ multiple: true,
146
+ onChange: handleFiles,
147
+ disabled: uploading
148
+ }
149
+ ),
150
+ uploading && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: t("media.uploading") }),
151
+ !uploading && queue.length > 0 && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: t("media.queued", { count: queue.length }) })
152
+ ] }),
153
+ error && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: error }),
154
+ /* @__PURE__ */ jsx(
155
+ ImageUploadDialog,
156
+ {
157
+ file: currentFile,
158
+ remaining: queue.length,
159
+ busy: uploading,
160
+ defaults: getMediaProcessingDefaults(),
161
+ onConfirm: handleDialogConfirm,
162
+ onSkip: handleDialogSkip,
163
+ onCancel: handleDialogCancel
164
+ }
165
+ ),
166
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4", children: items.map((item) => {
167
+ const isImage = IMAGE_EXT_RE.test(item.path);
168
+ const isStylesheet = STYLESHEET_EXT_RE.test(item.path);
169
+ const isScript = SCRIPT_EXT_RE.test(item.path);
170
+ const filename = item.path.split("/").pop() ?? "";
171
+ const ext = getExtension(item.path);
172
+ const tagSnippet = snippetFor(item.url, item.path);
173
+ const tagDiffersFromUrl = tagSnippet !== item.url;
174
+ const urlCopied = copiedPath === `${item.path}:url`;
175
+ const tagCopied = copiedPath === `${item.path}:tag`;
176
+ return /* @__PURE__ */ jsxs(
177
+ "div",
178
+ {
179
+ className: "group relative overflow-hidden rounded-md border bg-[var(--card)]",
180
+ children: [
181
+ isImage ? (
182
+ // eslint-disable-next-line @next/next/no-img-element
183
+ /* @__PURE__ */ jsx(
184
+ "img",
185
+ {
186
+ src: item.url,
187
+ alt: item.path,
188
+ className: "aspect-square w-full object-cover"
189
+ }
190
+ )
191
+ ) : /* @__PURE__ */ jsxs("div", { className: "flex aspect-square w-full flex-col items-center justify-center gap-2 bg-muted text-muted-foreground", children: [
192
+ isStylesheet || isScript ? /* @__PURE__ */ jsx(Code2, { className: "h-8 w-8" }) : /* @__PURE__ */ jsx(FileText, { className: "h-8 w-8" }),
193
+ /* @__PURE__ */ jsxs("span", { className: "font-mono text-xs font-semibold", children: [
194
+ ".",
195
+ ext.toLowerCase()
196
+ ] })
197
+ ] }),
198
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-t px-2 py-1 text-xs", children: [
199
+ /* @__PURE__ */ jsx("span", { className: "truncate", title: filename, children: filename }),
200
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-0.5", children: [
201
+ /* @__PURE__ */ jsx(
202
+ Button,
203
+ {
204
+ type: "button",
205
+ variant: "ghost",
206
+ size: "icon",
207
+ className: "h-6 w-6",
208
+ onClick: () => handleCopy(item, "url"),
209
+ title: t("media.copyUrl"),
210
+ children: urlCopied ? /* @__PURE__ */ jsx(Check, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(Copy, { className: "h-3 w-3" })
211
+ }
212
+ ),
213
+ tagDiffersFromUrl && /* @__PURE__ */ jsx(
214
+ Button,
215
+ {
216
+ type: "button",
217
+ variant: "ghost",
218
+ size: "icon",
219
+ className: "h-6 w-6",
220
+ onClick: () => handleCopy(item, "tag"),
221
+ title: t("media.copyTag"),
222
+ children: tagCopied ? /* @__PURE__ */ jsx(Check, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(Code2, { className: "h-3 w-3" })
223
+ }
224
+ ),
225
+ /* @__PURE__ */ jsx(
226
+ Button,
227
+ {
228
+ type: "button",
229
+ variant: "ghost",
230
+ size: "icon",
231
+ className: "h-6 w-6",
232
+ onClick: () => handleDelete(item.path),
233
+ title: t("media.delete"),
234
+ children: /* @__PURE__ */ jsx(Trash2, { className: "h-3 w-3" })
235
+ }
236
+ )
237
+ ] })
238
+ ] })
239
+ ]
240
+ },
241
+ item.path
242
+ );
243
+ }) }),
244
+ items.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-muted-foreground", children: t("media.empty") })
245
+ ] });
246
+ }
247
+
248
+ export {
249
+ MediaUploader
250
+ };
@@ -0,0 +1,6 @@
1
+ // src/lib/admin-site-cookie.ts
2
+ var ADMIN_SITE_COOKIE = "admin-site-id";
3
+
4
+ export {
5
+ ADMIN_SITE_COOKIE
6
+ };
@@ -0,0 +1,71 @@
1
+ 'use client';
2
+ import {
3
+ readAdminSiteIdFromCookie
4
+ } from "./chunk-TZWSXAHD.js";
5
+ import {
6
+ useT
7
+ } from "./chunk-XY4JWSMS.js";
8
+
9
+ // src/components/posts-list-view.tsx
10
+ import { useEffect, useState } from "react";
11
+ import Link from "next/link";
12
+ import { listPosts } from "ampless";
13
+ import {
14
+ Button,
15
+ Table,
16
+ TableBody,
17
+ TableCell,
18
+ TableHead,
19
+ TableHeader,
20
+ TableRow
21
+ } from "@ampless/runtime/ui";
22
+ import { jsx, jsxs } from "react/jsx-runtime";
23
+ function PostsList() {
24
+ const t = useT();
25
+ const [posts, setPosts] = useState([]);
26
+ const [loading, setLoading] = useState(true);
27
+ useEffect(() => {
28
+ const siteId = readAdminSiteIdFromCookie();
29
+ listPosts({ status: "all", siteId }).then(setPosts).finally(() => setLoading(false));
30
+ }, []);
31
+ return /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-7xl p-4 md:p-8", children: [
32
+ /* @__PURE__ */ jsxs("div", { className: "mb-6 flex flex-wrap items-center justify-between gap-3 md:mb-8", children: [
33
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold md:text-3xl", children: t("posts.list.title") }),
34
+ /* @__PURE__ */ jsx(Button, { asChild: true, children: /* @__PURE__ */ jsx(Link, { href: "/admin/posts/new", children: t("posts.list.newButton") }) })
35
+ ] }),
36
+ loading ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t("common.loading") }) : posts.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-md border p-12 text-center", children: [
37
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t("posts.list.empty") }),
38
+ /* @__PURE__ */ jsx(Button, { asChild: true, className: "mt-4", children: /* @__PURE__ */ jsx(Link, { href: "/admin/posts/new", children: t("posts.list.createFirst") }) })
39
+ ] }) : /* @__PURE__ */ jsx("div", { className: "overflow-x-auto rounded-md border", children: /* @__PURE__ */ jsxs(Table, { children: [
40
+ /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
41
+ /* @__PURE__ */ jsx(TableHead, { children: t("posts.list.columnTitle") }),
42
+ /* @__PURE__ */ jsx(TableHead, { children: t("posts.list.columnStatus") }),
43
+ /* @__PURE__ */ jsx(TableHead, { children: t("posts.list.columnSlug") }),
44
+ /* @__PURE__ */ jsx(TableHead, { children: t("posts.list.columnUpdated") })
45
+ ] }) }),
46
+ /* @__PURE__ */ jsx(TableBody, { children: posts.map((post) => /* @__PURE__ */ jsxs(TableRow, { children: [
47
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(
48
+ Link,
49
+ {
50
+ href: `/admin/posts/${post.postId}`,
51
+ className: "font-medium hover:underline",
52
+ children: post.title
53
+ }
54
+ ) }),
55
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(
56
+ "span",
57
+ {
58
+ className: post.status === "published" ? "inline-block rounded-full bg-green-100 px-2 py-0.5 text-xs text-green-700" : "inline-block rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-700",
59
+ children: t(`common.${post.status}`)
60
+ }
61
+ ) }),
62
+ /* @__PURE__ */ jsx(TableCell, { className: "font-mono text-xs text-muted-foreground", children: post.slug }),
63
+ /* @__PURE__ */ jsx(TableCell, { className: "text-sm text-muted-foreground", children: post.publishedAt ? new Date(post.publishedAt).toLocaleDateString() : "\u2014" })
64
+ ] }, post.postId)) })
65
+ ] }) })
66
+ ] });
67
+ }
68
+
69
+ export {
70
+ PostsList
71
+ };
@@ -0,0 +1,21 @@
1
+ 'use client';
2
+ import {
3
+ PostForm
4
+ } from "./chunk-CVJCMTYB.js";
5
+ import {
6
+ useT
7
+ } from "./chunk-XY4JWSMS.js";
8
+
9
+ // src/components/new-post-view.tsx
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ function NewPostPage() {
12
+ const t = useT();
13
+ return /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-7xl p-4 md:p-8", children: [
14
+ /* @__PURE__ */ jsx("h1", { className: "mb-6 text-2xl font-bold md:mb-8 md:text-3xl", children: t("posts.form.newTitle") }),
15
+ /* @__PURE__ */ jsx(PostForm, {})
16
+ ] });
17
+ }
18
+
19
+ export {
20
+ NewPostPage
21
+ };