@jant/core 0.2.17 → 0.2.19
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 +1 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +307 -137
- package/dist/client.js +1 -0
- package/dist/i18n/context.d.ts +2 -2
- package/dist/i18n/context.js +1 -1
- package/dist/i18n/i18n.d.ts +1 -1
- package/dist/i18n/i18n.js +1 -1
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +1 -1
- package/dist/i18n/locales/zh-Hans.d.ts.map +1 -1
- package/dist/i18n/locales/zh-Hans.js +1 -1
- package/dist/i18n/locales/zh-Hant.d.ts.map +1 -1
- package/dist/i18n/locales/zh-Hant.js +1 -1
- package/dist/lib/config.d.ts +44 -10
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +69 -44
- package/dist/lib/constants.d.ts +2 -1
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +5 -2
- package/dist/lib/image-processor.js +0 -4
- package/dist/lib/media-upload.js +104 -0
- package/dist/lib/sse.d.ts +82 -13
- package/dist/lib/sse.d.ts.map +1 -1
- package/dist/lib/sse.js +115 -17
- package/dist/lib/theme.d.ts +44 -0
- package/dist/lib/theme.d.ts.map +1 -0
- package/dist/lib/theme.js +65 -0
- package/dist/routes/api/upload.js +16 -18
- package/dist/routes/dash/appearance.d.ts +13 -0
- package/dist/routes/dash/appearance.d.ts.map +1 -0
- package/dist/routes/dash/appearance.js +160 -0
- package/dist/routes/dash/collections.js +5 -13
- package/dist/routes/dash/media.js +17 -167
- package/dist/routes/dash/pages.js +4 -10
- package/dist/routes/dash/posts.js +4 -10
- package/dist/routes/dash/redirects.js +3 -7
- package/dist/routes/dash/settings.d.ts.map +1 -1
- package/dist/routes/dash/settings.js +52 -42
- package/dist/services/settings.d.ts +1 -0
- package/dist/services/settings.d.ts.map +1 -1
- package/dist/services/settings.js +3 -0
- package/dist/theme/color-themes.d.ts +30 -0
- package/dist/theme/color-themes.d.ts.map +1 -0
- package/dist/theme/color-themes.js +268 -0
- package/dist/theme/layouts/BaseLayout.d.ts +5 -0
- package/dist/theme/layouts/BaseLayout.d.ts.map +1 -1
- package/dist/theme/layouts/BaseLayout.js +70 -3
- package/dist/theme/layouts/DashLayout.d.ts +2 -0
- package/dist/theme/layouts/DashLayout.d.ts.map +1 -1
- package/dist/theme/layouts/DashLayout.js +11 -1
- package/dist/theme/layouts/index.d.ts +1 -1
- package/dist/theme/layouts/index.d.ts.map +1 -1
- package/dist/types.d.ts +53 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +52 -0
- package/package.json +1 -1
- package/src/app.tsx +260 -81
- package/src/client.ts +1 -0
- package/src/db/migrations/{0000_solid_moon_knight.sql → 0000_square_wallflower.sql} +3 -3
- package/src/db/migrations/meta/0000_snapshot.json +9 -9
- package/src/db/migrations/meta/_journal.json +2 -30
- package/src/i18n/context.tsx +2 -2
- package/src/i18n/i18n.ts +1 -1
- package/src/i18n/index.ts +1 -1
- package/src/i18n/locales/en.po +328 -252
- package/src/i18n/locales/en.ts +1 -1
- package/src/i18n/locales/zh-Hans.po +315 -278
- package/src/i18n/locales/zh-Hans.ts +1 -1
- package/src/i18n/locales/zh-Hant.po +315 -278
- package/src/i18n/locales/zh-Hant.ts +1 -1
- package/src/lib/config.ts +73 -47
- package/src/lib/constants.ts +3 -0
- package/src/lib/image-processor.ts +0 -7
- package/src/lib/media-upload.ts +148 -0
- package/src/lib/sse.ts +156 -16
- package/src/lib/theme.ts +86 -0
- package/src/preset.css +9 -0
- package/src/routes/api/upload.ts +12 -18
- package/src/routes/dash/appearance.tsx +176 -0
- package/src/routes/dash/collections.tsx +5 -13
- package/src/routes/dash/media.tsx +16 -165
- package/src/routes/dash/pages.tsx +4 -10
- package/src/routes/dash/posts.tsx +4 -10
- package/src/routes/dash/redirects.tsx +3 -7
- package/src/routes/dash/settings.tsx +71 -55
- package/src/services/settings.ts +5 -0
- package/src/styles/components.css +93 -0
- package/src/theme/color-themes.ts +321 -0
- package/src/theme/layouts/BaseLayout.tsx +61 -1
- package/src/theme/layouts/DashLayout.tsx +14 -3
- package/src/theme/layouts/index.ts +5 -1
- package/src/types.ts +62 -1
- package/src/db/migrations/0001_add_search_fts.sql +0 -40
- package/src/db/migrations/0002_collection_path.sql +0 -2
- package/src/db/migrations/0003_collection_path_nullable.sql +0 -21
- package/src/db/migrations/0004_media_uuid.sql +0 -35
package/dist/i18n/index.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Usage:
|
|
11
11
|
* ```tsx
|
|
12
|
-
* import { useLingui, Trans, I18nProvider } from "
|
|
12
|
+
* import { useLingui, Trans, I18nProvider } from "../i18n/index.js";
|
|
13
13
|
*
|
|
14
14
|
* // Wrap your app in I18nProvider (automatically done by BaseLayout when c is provided)
|
|
15
15
|
* c.html(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/en.ts"],"names":[],"mappings":"AAAkB,OAAO,KAAI,EAAC,QAAQ,EAAC,MAAI,cAAc,CAAC;AAAA,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/en.ts"],"names":[],"mappings":"AAAkB,OAAO,KAAI,EAAC,QAAQ,EAAC,MAAI,cAAc,CAAC;AAAA,eAAO,MAAM,QAAQ,EAAs1K,QAAQ,CAAC"}
|
package/dist/i18n/locales/en.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/*eslint-disable*/ export const messages = JSON.parse("{\"+7Wr2a\":[\"Edit: \",[\"title\"]],\"+MACwa\":[\"No collections yet.\"],\"+owNNn\":[\"Posts\"],\"+zy2Nq\":[\"Type\"],\"/0D1Xp\":[\"Edit Collection\"],\"/Rj5P4\":[\"Your Name\"],\"0JkyS7\":[\"Create your first page\"],\"0a6MpL\":[\"New Redirect\"],\"1CU1Td\":[\"URL-safe identifier (lowercase, numbers, hyphens)\"],\"1DBGsz\":[\"Notes\"],\"2N0qpv\":[\"Post title...\"],\"2q/Q7x\":[\"Visibility\"],\"2rJGtU\":[\"Page title...\"],\"3Yvsaz\":[\"302 (Temporary)\"],\"4/SFQS\":[\"View Site\"],\"40TVQj\":[\"Custom Path (optional)\"],\"4KzVT6\":[\"Delete Page\"],\"4b3oEV\":[\"Content\"],\"4mDPGp\":[\"The URL path for this page. Use lowercase letters, numbers, and hyphens.\"],\"6WdDG7\":[\"Page\"],\"7G4SBz\":[\"Page content (Markdown supported)...\"],\"7Mk+/h\":[\"Update Collection\"],\"7Q1KKN\":[\"From Path\"],\"7nGhhM\":[\"What's on your mind?\"],\"7p5kLi\":[\"Dashboard\"],\"8ZsakT\":[\"Password\"],\"90Luob\":[[\"count\"],\" replies\"],\"A1taO8\":[\"Search\"],\"AyHO4m\":[\"What's this collection about?\"],\"B373X+\":[\"Edit Post\"],\"B495Gs\":[\"Archive\"],\"BjF0Jv\":[\"Lowercase letters, numbers, and hyphens only\"],\"D9Oea+\":[\"Permalink\"],\"DHhJ7s\":[\"Previous\"],\"DoJzLz\":[\"Collections\"],\"E80cJw\":[\"Deleting this media will remove it permanently from storage.\"],\"EEYbdt\":[\"Publish\"],\"EGwzOK\":[\"Complete Setup\"],\"EkH9pt\":[\"Update\"],\"FGrimz\":[\"New Post\"],\"FkMol5\":[\"Featured\"],\"Fxf4jq\":[\"Description (optional)\"],\"GA5A5H\":[\"Delete Collection\"],\"GorKul\":[\"Welcome to Jant\"],\"GrZ6fH\":[\"New Page\"],\"HfyyXl\":[\"My Blog\"],\"HiETwV\":[\"Quiet (normal)\"],\"Hzi9AA\":[\"No posts found.\"],\"I6gXOa\":[\"Path\"],\"IagCbF\":[\"URL\"],\"J4FNfC\":[\"No posts in this collection.\"],\"JIBC/T\":[\"Supported formats: JPEG, PNG, GIF, WebP, SVG. Max size: 10MB.\"],\"JiP4aa\":[\"Published pages are accessible via their path. Drafts are not visible.\"],\"K9NcLu\":[\"Use this URL to embed the media in your posts.\"],\"KiJn9B\":[\"Note\"],\"L85WcV\":[\"Slug\"],\"LkvLQe\":[\"No pages yet.\"],\"M8kJqa\":[\"Drafts\"],\"M9xgHy\":[\"Redirects\"],\"MHrjPM\":[\"Title\"],\"MZbQHL\":[\"No results found.\"],\"Mhf/H/\":[\"Create Redirect\"],\"MqghUt\":[\"Search posts...\"],\"N40H+G\":[\"All\"],\"O3oNi5\":[\"Email\"],\"OCNZaU\":[\"The path to redirect from\"],\"ODiSoW\":[\"No posts yet.\"],\"ONWvwQ\":[\"Upload\"],\"Pbm2/N\":[\"Create Collection\"],\"RDjuBN\":[\"Setup\"],\"Rj01Fz\":[\"Links\"],\"RwGhWy\":[\"Thread with \",[\"count\"],\" posts\"],\"SJmfuf\":[\"Site Name\"],\"ST+lN2\":[\"No media uploaded yet.\"],\"Tt5T6+\":[\"Articles\"],\"TxE+Mj\":[\"1 reply\"],\"Tz0i8g\":[\"Settings\"],\"U5v6Gh\":[\"Edit Page\"],\"UDMjsP\":[\"Quick Actions\"],\"UGT5vp\":[\"Save Settings\"],\"VUSy8D\":[\"Search failed. Please try again.\"],\"WDcQq9\":[\"Unlisted\"],\"Weq9zb\":[\"General\"],\"WmZ/rP\":[\"To Path\"],\"Y+7JGK\":[\"Create Page\"],\"ZQKLI1\":[\"Danger Zone\"],\"ZhhOwV\":[\"Quote\"],\"an5hVd\":[\"Images\"],\"b+/jO6\":[\"301 (Permanent)\"],\"bHYIks\":[\"Sign Out\"],\"biOepV\":[\"← Back to home\"],\"cnGeoo\":[\"Delete\"],\"dEgA5A\":[\"Cancel\"],\"e6Jr7Q\":[\"← Back to Collections\"],\"ePK91l\":[\"Edit\"],\"eWLklq\":[\"Quotes\"],\"eneWvv\":[\"Draft\"],\"f6e0Ry\":[\"Article\"],\"fG7BxZ\":[\"Upload images via the API: POST /api/upload with a file form field.\"],\"fttd2R\":[\"My Collection\"],\"hG89Ed\":[\"Image\"],\"hXzOVo\":[\"Next\"],\"he3ygx\":[\"Copy\"],\"iH8pgl\":[\"Back\"],\"ig4hg2\":[\"Let's set up your site.\"],\"jpctdh\":[\"View\"],\"mTOYla\":[\"View all posts →\"],\"n1ekoW\":[\"Sign In\"],\"oYPBa0\":[\"Update Page\"],\"pRhYH2\":[\"Posts in Collection (\",[\"count\"],\")\"],\"qMyM2u\":[\"Source URL (optional)\"],\"r1MpXi\":[\"Quiet\"],\"rdUucN\":[\"Preview\"],\"rzNUSl\":[\"Thread with 1 post\"],\"sGajR7\":[\"Thread start\"],\"t/YqKh\":[\"Remove\"],\"tfrt7B\":[\"No redirects configured.\"],\"tiq7kl\":[\"Page \",[\"page\"]],\"u2f7vd\":[\"Site Description\"],\"u3wRF+\":[\"Published\"],\"u6Hp4N\":[\"Markdown\"],\"uAQUqI\":[\"Status\"],\"vXIe7J\":[\"Language\"],\"vzU4k9\":[\"New Collection\"],\"wEF6Ix\":[\"The destination path or URL\"],\"wK4OTM\":[\"Title (optional)\"],\"wM5UXj\":[\"Delete Media\"],\"wRR604\":[\"Pages\"],\"wja8aL\":[\"Untitled\"],\"x0mzE0\":[\"Create your first post\"],\"x4RuFo\":[\"Back to home\"],\"xYilR2\":[\"Media\"],\"y28hnO\":[\"Post\"],\"yQ2kGp\":[\"Load more\"],\"yzF66j\":[\"Link\"],\"z8ajIE\":[\"Found 1 result\"],\"zH6KqE\":[\"Found \",[\"count\"],\" results\"]}");
|
|
1
|
+
/*eslint-disable*/ export const messages = JSON.parse("{\"+7Wr2a\":[\"Edit: \",[\"title\"]],\"+MACwa\":[\"No collections yet.\"],\"+owNNn\":[\"Posts\"],\"+zy2Nq\":[\"Type\"],\"/0D1Xp\":[\"Edit Collection\"],\"/Rj5P4\":[\"Your Name\"],\"07Epll\":[\"This will theme both your site and your dashboard. All color themes support dark mode.\"],\"0JkyS7\":[\"Create your first page\"],\"0a6MpL\":[\"New Redirect\"],\"1CU1Td\":[\"URL-safe identifier (lowercase, numbers, hyphens)\"],\"1DBGsz\":[\"Notes\"],\"2N0qpv\":[\"Post title...\"],\"2q/Q7x\":[\"Visibility\"],\"2rJGtU\":[\"Page title...\"],\"3Yvsaz\":[\"302 (Temporary)\"],\"4/SFQS\":[\"View Site\"],\"40TVQj\":[\"Custom Path (optional)\"],\"4KzVT6\":[\"Delete Page\"],\"4b3oEV\":[\"Content\"],\"4mDPGp\":[\"The URL path for this page. Use lowercase letters, numbers, and hyphens.\"],\"6WdDG7\":[\"Page\"],\"7G4SBz\":[\"Page content (Markdown supported)...\"],\"7Mk+/h\":[\"Update Collection\"],\"7Q1KKN\":[\"From Path\"],\"7aECQB\":[\"Invalid or Expired Link\"],\"7nGhhM\":[\"What's on your mind?\"],\"7p5kLi\":[\"Dashboard\"],\"7vhWI8\":[\"New Password\"],\"8ZsakT\":[\"Password\"],\"90Luob\":[[\"count\"],\" replies\"],\"A1taO8\":[\"Search\"],\"AyHO4m\":[\"What's this collection about?\"],\"B373X+\":[\"Edit Post\"],\"B495Gs\":[\"Archive\"],\"BjF0Jv\":[\"Lowercase letters, numbers, and hyphens only\"],\"D9Oea+\":[\"Permalink\"],\"DCKkhU\":[\"Current Password\"],\"DHhJ7s\":[\"Previous\"],\"DoJzLz\":[\"Collections\"],\"E80cJw\":[\"Deleting this media will remove it permanently from storage.\"],\"EEYbdt\":[\"Publish\"],\"EGwzOK\":[\"Complete Setup\"],\"EkH9pt\":[\"Update\"],\"FGrimz\":[\"New Post\"],\"FkMol5\":[\"Featured\"],\"Fxf4jq\":[\"Description (optional)\"],\"GA5A5H\":[\"Delete Collection\"],\"GX2VMa\":[\"Create your admin account.\"],\"GbVAnd\":[\"This password reset link is invalid or has expired. Please generate a new one.\"],\"GorKul\":[\"Welcome to Jant\"],\"GrZ6fH\":[\"New Page\"],\"GxkJXS\":[\"Uploading...\"],\"HfyyXl\":[\"My Blog\"],\"HiETwV\":[\"Quiet (normal)\"],\"Hzi9AA\":[\"No posts found.\"],\"I6gXOa\":[\"Path\"],\"IagCbF\":[\"URL\"],\"J4FNfC\":[\"No posts in this collection.\"],\"JIBC/T\":[\"Supported formats: JPEG, PNG, GIF, WebP, SVG. Max size: 10MB.\"],\"Jed1wB\":[\"Need help? Visit the <0>documentation</0>\"],\"JiP4aa\":[\"Published pages are accessible via their path. Drafts are not visible.\"],\"K9NcLu\":[\"Use this URL to embed the media in your posts.\"],\"KbS2K9\":[\"Reset Password\"],\"KiJn9B\":[\"Note\"],\"L85WcV\":[\"Slug\"],\"LkvLQe\":[\"No pages yet.\"],\"M1RvTd\":[\"Click image to view full size\"],\"M8kJqa\":[\"Drafts\"],\"M9xgHy\":[\"Redirects\"],\"MHrjPM\":[\"Title\"],\"MZbQHL\":[\"No results found.\"],\"Mhf/H/\":[\"Create Redirect\"],\"MqghUt\":[\"Search posts...\"],\"N40H+G\":[\"All\"],\"O3oNi5\":[\"Email\"],\"OCNZaU\":[\"The path to redirect from\"],\"ODiSoW\":[\"No posts yet.\"],\"ONWvwQ\":[\"Upload\"],\"Pbm2/N\":[\"Create Collection\"],\"RDjuBN\":[\"Setup\"],\"Rj01Fz\":[\"Links\"],\"RwGhWy\":[\"Thread with \",[\"count\"],\" posts\"],\"SJmfuf\":[\"Site Name\"],\"ST+lN2\":[\"No media uploaded yet.\"],\"Tt5T6+\":[\"Articles\"],\"TxE+Mj\":[\"1 reply\"],\"Tz0i8g\":[\"Settings\"],\"U5v6Gh\":[\"Edit Page\"],\"UDMjsP\":[\"Quick Actions\"],\"UGT5vp\":[\"Save Settings\"],\"VUSy8D\":[\"Search failed. Please try again.\"],\"VhMDMg\":[\"Change Password\"],\"WDcQq9\":[\"Unlisted\"],\"Weq9zb\":[\"General\"],\"WmZ/rP\":[\"To Path\"],\"Y+7JGK\":[\"Create Page\"],\"ZQKLI1\":[\"Danger Zone\"],\"ZhhOwV\":[\"Quote\"],\"aAIQg2\":[\"Appearance\"],\"an5hVd\":[\"Images\"],\"b+/jO6\":[\"301 (Permanent)\"],\"bHYIks\":[\"Sign Out\"],\"biOepV\":[\"← Back to home\"],\"cnGeoo\":[\"Delete\"],\"dEgA5A\":[\"Cancel\"],\"e6Jr7Q\":[\"← Back to Collections\"],\"ePK91l\":[\"Edit\"],\"eWLklq\":[\"Quotes\"],\"eneWvv\":[\"Draft\"],\"er8+x7\":[\"Demo account pre-filled. Just click Sign In.\"],\"f6e0Ry\":[\"Article\"],\"fG7BxZ\":[\"Upload images via the API: POST /api/upload with a file form field.\"],\"fttd2R\":[\"My Collection\"],\"hG89Ed\":[\"Image\"],\"hWOZIv\":[\"Enter your new password.\"],\"hXzOVo\":[\"Next\"],\"he3ygx\":[\"Copy\"],\"iH8pgl\":[\"Back\"],\"ig4hg2\":[\"Let's set up your site.\"],\"jpctdh\":[\"View\"],\"k1ifdL\":[\"Processing...\"],\"mTOYla\":[\"View all posts →\"],\"n1ekoW\":[\"Sign In\"],\"oYPBa0\":[\"Update Page\"],\"p2/GCq\":[\"Confirm Password\"],\"pRhYH2\":[\"Posts in Collection (\",[\"count\"],\")\"],\"pZq3aX\":[\"Upload failed. Please try again.\"],\"qMyM2u\":[\"Source URL (optional)\"],\"r1MpXi\":[\"Quiet\"],\"rFmBG3\":[\"Color theme\"],\"rdUucN\":[\"Preview\"],\"rzNUSl\":[\"Thread with 1 post\"],\"sGajR7\":[\"Thread start\"],\"t/YqKh\":[\"Remove\"],\"tfrt7B\":[\"No redirects configured.\"],\"tiq7kl\":[\"Page \",[\"page\"]],\"u2f7vd\":[\"Site Description\"],\"u3wRF+\":[\"Published\"],\"u6Hp4N\":[\"Markdown\"],\"uAQUqI\":[\"Status\"],\"vXIe7J\":[\"Language\"],\"vzU4k9\":[\"New Collection\"],\"wEF6Ix\":[\"The destination path or URL\"],\"wK4OTM\":[\"Title (optional)\"],\"wM5UXj\":[\"Delete Media\"],\"wRR604\":[\"Pages\"],\"wja8aL\":[\"Untitled\"],\"x+doid\":[\"Images are automatically optimized: resized to max 1920px, converted to WebP, and metadata stripped.\"],\"x0mzE0\":[\"Create your first post\"],\"x4RuFo\":[\"Back to home\"],\"xYilR2\":[\"Media\"],\"y28hnO\":[\"Post\"],\"yQ2kGp\":[\"Load more\"],\"yjkELF\":[\"Confirm New Password\"],\"yzF66j\":[\"Link\"],\"z8ajIE\":[\"Found 1 result\"],\"zH6KqE\":[\"Found \",[\"count\"],\" results\"]}");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zh-Hans.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/zh-Hans.ts"],"names":[],"mappings":"AAAkB,OAAO,KAAI,EAAC,QAAQ,EAAC,MAAI,cAAc,CAAC;AAAA,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"zh-Hans.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/zh-Hans.ts"],"names":[],"mappings":"AAAkB,OAAO,KAAI,EAAC,QAAQ,EAAC,MAAI,cAAc,CAAC;AAAA,eAAO,MAAM,QAAQ,EAA45H,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*eslint-disable*/ export const messages = JSON.parse("{\"+7Wr2a\":[\"
|
|
1
|
+
/*eslint-disable*/ export const messages = JSON.parse("{\"+7Wr2a\":[\"Edit: \",[\"title\"]],\"+MACwa\":[\"尚未有任何收藏。\"],\"+owNNn\":[\"帖子\"],\"+zy2Nq\":[\"类型\"],\"/0D1Xp\":[\"编辑集合\"],\"/Rj5P4\":[\"您的姓名\"],\"07Epll\":[\"这将为您的网站和仪表板设置主题。所有颜色主题都支持暗黑模式。\"],\"0JkyS7\":[\"创建您的第一页\"],\"0a6MpL\":[\"新重定向\"],\"1CU1Td\":[\"URL安全标识符(小写字母、数字、连字符)\"],\"1DBGsz\":[\"笔记\"],\"2N0qpv\":[\"帖子标题...\"],\"2q/Q7x\":[\"可见性\"],\"2rJGtU\":[\"页面标题...\"],\"3Yvsaz\":[\"302(临时)\"],\"4/SFQS\":[\"查看网站\"],\"40TVQj\":[\"自定义路径(可选)\"],\"4KzVT6\":[\"删除页面\"],\"4b3oEV\":[\"内容\"],\"4mDPGp\":[\"此页面的 URL 路径。使用小写字母、数字和连字符。\"],\"6WdDG7\":[\"页面\"],\"7G4SBz\":[\"页面内容(支持Markdown)...\"],\"7Mk+/h\":[\"更新收藏夹\"],\"7Q1KKN\":[\"来源路径\"],\"7aECQB\":[\"无效或过期的链接\"],\"7nGhhM\":[\"你在想什么?\"],\"7p5kLi\":[\"仪表板\"],\"7vhWI8\":[\"新密码\"],\"8ZsakT\":[\"密码\"],\"90Luob\":[[\"count\"],\" 条回复\"],\"A1taO8\":[\"搜索\"],\"AyHO4m\":[\"这个系列是关于什么的?\"],\"B373X+\":[\"编辑帖子\"],\"B495Gs\":[\"档案馆\"],\"BjF0Jv\":[\"仅允许小写字母、数字和连字符\"],\"D9Oea+\":[\"永久链接\"],\"DCKkhU\":[\"当前密码\"],\"DHhJ7s\":[\"上一页\"],\"DoJzLz\":[\"收藏夹\"],\"E80cJw\":[\"删除此媒体将永久从存储中移除。\"],\"EEYbdt\":[\"发布\"],\"EGwzOK\":[\"完成设置\"],\"EkH9pt\":[\"更新\"],\"FGrimz\":[\"新帖子\"],\"FkMol5\":[\"精选\"],\"Fxf4jq\":[\"描述(可选)\"],\"GA5A5H\":[\"删除收藏夹\"],\"GX2VMa\":[\"创建您的管理员账户。\"],\"GbVAnd\":[\"此密码重置链接无效或已过期。请生成一个新的链接。\"],\"GorKul\":[\"欢迎来到Jant\"],\"GrZ6fH\":[\"新页面\"],\"GxkJXS\":[\"上传中...\"],\"HfyyXl\":[\"My Blog\"],\"HiETwV\":[\"安静(正常)\"],\"Hzi9AA\":[\"未找到帖子。\"],\"I6gXOa\":[\"路径\"],\"IagCbF\":[\"网址\"],\"J4FNfC\":[\"此集合中没有帖子。\"],\"JIBC/T\":[\"Supported formats: JPEG, PNG, GIF, WebP, SVG. Max size: 10MB.\"],\"Jed1wB\":[\"需要帮助吗?访问<0>文档</0>。\"],\"JiP4aa\":[\"已发布的页面可以通过其路径访问。草稿不可见。\"],\"K9NcLu\":[\"使用此 URL 将媒体嵌入到您的帖子中。\"],\"KbS2K9\":[\"重置密码\"],\"KiJn9B\":[\"注意\"],\"L85WcV\":[\"缩略名\"],\"LkvLQe\":[\"还没有页面。\"],\"M1RvTd\":[\"点击图片查看完整尺寸\"],\"M8kJqa\":[\"草稿\"],\"M9xgHy\":[\"重定向\"],\"MHrjPM\":[\"标题\"],\"MZbQHL\":[\"未找到结果。\"],\"Mhf/H/\":[\"创建重定向\"],\"MqghUt\":[\"搜索帖子...\"],\"N40H+G\":[\"所有\"],\"O3oNi5\":[\"电子邮件\"],\"OCNZaU\":[\"重定向的路径\"],\"ODiSoW\":[\"还没有帖子。\"],\"ONWvwQ\":[\"上传\"],\"Pbm2/N\":[\"创建集合\"],\"RDjuBN\":[\"Setup\"],\"Rj01Fz\":[\"链接\"],\"RwGhWy\":[\"包含 \",[\"count\"],\" 条帖子的话题\"],\"SJmfuf\":[\"网站名称\"],\"ST+lN2\":[\"尚未上传任何媒体。\"],\"Tt5T6+\":[\"文章\"],\"TxE+Mj\":[\"1 条回复\"],\"Tz0i8g\":[\"设置\"],\"U5v6Gh\":[\"编辑页面\"],\"UDMjsP\":[\"快速操作\"],\"UGT5vp\":[\"保存设置\"],\"VUSy8D\":[\"Search failed. Please try again.\"],\"VhMDMg\":[\"更改密码\"],\"WDcQq9\":[\"未列出\"],\"Weq9zb\":[\"常规\"],\"WmZ/rP\":[\"到路径\"],\"Y+7JGK\":[\"创建页面\"],\"ZQKLI1\":[\"危险区域\"],\"ZhhOwV\":[\"引用\"],\"aAIQg2\":[\"外观\"],\"an5hVd\":[\"图片\"],\"b+/jO6\":[\"301(永久)\"],\"bHYIks\":[\"登出\"],\"biOepV\":[\"← 返回首页\"],\"cnGeoo\":[\"删除\"],\"dEgA5A\":[\"取消\"],\"e6Jr7Q\":[\"← 返回收藏夹\"],\"ePK91l\":[\"编辑\"],\"eWLklq\":[\"引用\"],\"eneWvv\":[\"草稿\"],\"er8+x7\":[\"演示账户已预填。只需点击登录。\"],\"f6e0Ry\":[\"文章\"],\"fG7BxZ\":[\"Upload images via the API: POST /api/upload with a file form field.\"],\"fttd2R\":[\"我的收藏\"],\"hG89Ed\":[\"图像\"],\"hWOZIv\":[\"输入您的新密码。\"],\"hXzOVo\":[\"下一页\"],\"he3ygx\":[\"复制\"],\"iH8pgl\":[\"返回\"],\"ig4hg2\":[\"Let's set up your site.\"],\"jpctdh\":[\"查看\"],\"k1ifdL\":[\"处理中...\"],\"mTOYla\":[\"查看所有帖子 →\"],\"n1ekoW\":[\"登录\"],\"oYPBa0\":[\"更新页面\"],\"p2/GCq\":[\"确认密码\"],\"pRhYH2\":[\"集合中的帖子 (\",[\"count\"],\")\"],\"pZq3aX\":[\"上传失败。请再试一次。\"],\"qMyM2u\":[\"源网址(可选)\"],\"r1MpXi\":[\"安静\"],\"rFmBG3\":[\"颜色主题\"],\"rdUucN\":[\"预览\"],\"rzNUSl\":[\"包含 1 条帖子的话题\"],\"sGajR7\":[\"线程开始\"],\"t/YqKh\":[\"移除\"],\"tfrt7B\":[\"未配置重定向。\"],\"tiq7kl\":[\"页面 \",[\"page\"]],\"u2f7vd\":[\"网站描述\"],\"u3wRF+\":[\"已发布\"],\"u6Hp4N\":[\"Markdown\"],\"uAQUqI\":[\"状态\"],\"vXIe7J\":[\"语言\"],\"vzU4k9\":[\"新收藏\"],\"wEF6Ix\":[\"目标路径或 URL\"],\"wK4OTM\":[\"标题(可选)\"],\"wM5UXj\":[\"删除媒体\"],\"wRR604\":[\"页面\"],\"wja8aL\":[\"无标题\"],\"x+doid\":[\"图像会自动优化:调整大小至最大 1920px,转换为 WebP,并去除元数据。\"],\"x0mzE0\":[\"创建你的第一篇帖子\"],\"x4RuFo\":[\"返回首页\"],\"xYilR2\":[\"媒体\"],\"y28hnO\":[\"帖子\"],\"yQ2kGp\":[\"加载更多\"],\"yjkELF\":[\"确认新密码\"],\"yzF66j\":[\"链接\"],\"z8ajIE\":[\"找到 1 个结果\"],\"zH6KqE\":[\"找到 \",[\"count\"],\" 个结果\"]}");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zh-Hant.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/zh-Hant.ts"],"names":[],"mappings":"AAAkB,OAAO,KAAI,EAAC,QAAQ,EAAC,MAAI,cAAc,CAAC;AAAA,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"zh-Hant.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/zh-Hant.ts"],"names":[],"mappings":"AAAkB,OAAO,KAAI,EAAC,QAAQ,EAAC,MAAI,cAAc,CAAC;AAAA,eAAO,MAAM,QAAQ,EAAg7H,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*eslint-disable*/ export const messages = JSON.parse("{\"+7Wr2a\":[\"
|
|
1
|
+
/*eslint-disable*/ export const messages = JSON.parse("{\"+7Wr2a\":[\"Edit: \",[\"title\"]],\"+MACwa\":[\"尚未有任何收藏。\"],\"+owNNn\":[\"文章\"],\"+zy2Nq\":[\"類型\"],\"/0D1Xp\":[\"編輯收藏集\"],\"/Rj5P4\":[\"您的姓名\"],\"07Epll\":[\"這將為您的網站和儀表板設置主題。所有顏色主題都支持深色模式。\"],\"0JkyS7\":[\"建立您的第一個頁面\"],\"0a6MpL\":[\"新重定向\"],\"1CU1Td\":[\"網址安全識別碼(小寫、數字、連字符)\"],\"1DBGsz\":[\"筆記\"],\"2N0qpv\":[\"文章標題...\"],\"2q/Q7x\":[\"可見性\"],\"2rJGtU\":[\"頁面標題...\"],\"3Yvsaz\":[\"302(臨時)\"],\"4/SFQS\":[\"查看網站\"],\"40TVQj\":[\"自訂路徑(選填)\"],\"4KzVT6\":[\"刪除頁面\"],\"4b3oEV\":[\"內容\"],\"4mDPGp\":[\"此頁面的 URL 路徑。使用小寫字母、數字和連字符。\"],\"6WdDG7\":[\"頁面\"],\"7G4SBz\":[\"頁面內容(支持Markdown)...\"],\"7Mk+/h\":[\"更新收藏集\"],\"7Q1KKN\":[\"來源路徑\"],\"7aECQB\":[\"無效或已過期的連結\"],\"7nGhhM\":[\"你在想什麼?\"],\"7p5kLi\":[\"儀表板\"],\"7vhWI8\":[\"新密碼\"],\"8ZsakT\":[\"密碼\"],\"90Luob\":[[\"count\"],\" 條回覆\"],\"A1taO8\":[\"搜尋\"],\"AyHO4m\":[\"這個收藏是關於什麼的?\"],\"B373X+\":[\"編輯文章\"],\"B495Gs\":[\"檔案館\"],\"BjF0Jv\":[\"僅限小寫字母、數字和連字符\"],\"D9Oea+\":[\"永久鏈接\"],\"DCKkhU\":[\"當前密碼\"],\"DHhJ7s\":[\"上一頁\"],\"DoJzLz\":[\"收藏夾\"],\"E80cJw\":[\"刪除此媒體將永久從存儲中移除它。\"],\"EEYbdt\":[\"發佈\"],\"EGwzOK\":[\"完成設置\"],\"EkH9pt\":[\"更新\"],\"FGrimz\":[\"新帖子\"],\"FkMol5\":[\"精選\"],\"Fxf4jq\":[\"描述(可選)\"],\"GA5A5H\":[\"刪除收藏夾\"],\"GX2VMa\":[\"建立您的管理員帳戶。\"],\"GbVAnd\":[\"此密碼重設連結無效或已過期。請生成一個新的連結。\"],\"GorKul\":[\"歡迎來到 Jant\"],\"GrZ6fH\":[\"新頁面\"],\"GxkJXS\":[\"上傳中...\"],\"HfyyXl\":[\"My Blog\"],\"HiETwV\":[\"安靜(正常)\"],\"Hzi9AA\":[\"未找到任何帖子。\"],\"I6gXOa\":[\"路徑\"],\"IagCbF\":[\"網址\"],\"J4FNfC\":[\"此集合中沒有帖子。\"],\"JIBC/T\":[\"Supported formats: JPEG, PNG, GIF, WebP, SVG. Max size: 10MB.\"],\"Jed1wB\":[\"需要幫助嗎?請訪問<0>文檔</0>。\"],\"JiP4aa\":[\"已發佈的頁面可以通過其路徑訪問。草稿不可見。\"],\"K9NcLu\":[\"使用此 URL 將媒體嵌入到您的帖子中。\"],\"KbS2K9\":[\"重設密碼\"],\"KiJn9B\":[\"備註\"],\"L85WcV\":[\"縮略名\"],\"LkvLQe\":[\"尚未有頁面。\"],\"M1RvTd\":[\"點擊圖片以查看完整大小\"],\"M8kJqa\":[\"草稿\"],\"M9xgHy\":[\"重定向\"],\"MHrjPM\":[\"標題\"],\"MZbQHL\":[\"未找到結果。\"],\"Mhf/H/\":[\"建立重定向\"],\"MqghUt\":[\"搜尋帖子...\"],\"N40H+G\":[\"所有\"],\"O3oNi5\":[\"電子郵件\"],\"OCNZaU\":[\"重定向來源的路徑\"],\"ODiSoW\":[\"尚未有帖子。\"],\"ONWvwQ\":[\"上傳\"],\"Pbm2/N\":[\"創建收藏夾\"],\"RDjuBN\":[\"Setup\"],\"Rj01Fz\":[\"連結\"],\"RwGhWy\":[\"包含 \",[\"count\"],\" 則帖子的主題\"],\"SJmfuf\":[\"網站名稱\"],\"ST+lN2\":[\"尚未上傳任何媒體。\"],\"Tt5T6+\":[\"文章\"],\"TxE+Mj\":[\"1 條回覆\"],\"Tz0i8g\":[\"設定\"],\"U5v6Gh\":[\"編輯頁面\"],\"UDMjsP\":[\"快速操作\"],\"UGT5vp\":[\"保存設定\"],\"VUSy8D\":[\"Search failed. Please try again.\"],\"VhMDMg\":[\"更改密碼\"],\"WDcQq9\":[\"不公開\"],\"Weq9zb\":[\"一般設定\"],\"WmZ/rP\":[\"到路徑\"],\"Y+7JGK\":[\"創建頁面\"],\"ZQKLI1\":[\"危險區域\"],\"ZhhOwV\":[\"引用\"],\"aAIQg2\":[\"外觀\"],\"an5hVd\":[\"圖片\"],\"b+/jO6\":[\"301(永久)\"],\"bHYIks\":[\"登出\"],\"biOepV\":[\"← 返回首頁\"],\"cnGeoo\":[\"刪除\"],\"dEgA5A\":[\"取消\"],\"e6Jr7Q\":[\"← 返回收藏夾\"],\"ePK91l\":[\"編輯\"],\"eWLklq\":[\"引用\"],\"eneWvv\":[\"草稿\"],\"er8+x7\":[\"示範帳戶已預填。只需點擊登入。\"],\"f6e0Ry\":[\"文章\"],\"fG7BxZ\":[\"Upload images via the API: POST /api/upload with a file form field.\"],\"fttd2R\":[\"我的收藏\"],\"hG89Ed\":[\"圖片\"],\"hWOZIv\":[\"請輸入您的新密碼。\"],\"hXzOVo\":[\"下一頁\"],\"he3ygx\":[\"複製\"],\"iH8pgl\":[\"返回\"],\"ig4hg2\":[\"Let's set up your site.\"],\"jpctdh\":[\"查看\"],\"k1ifdL\":[\"處理中...\"],\"mTOYla\":[\"查看所有文章 →\"],\"n1ekoW\":[\"登入\"],\"oYPBa0\":[\"更新頁面\"],\"p2/GCq\":[\"確認密碼\"],\"pRhYH2\":[\"收藏中的帖子 (\",[\"count\"],\")\"],\"pZq3aX\":[\"上傳失敗。請再試一次。\"],\"qMyM2u\":[\"來源網址(選填)\"],\"r1MpXi\":[\"安靜\"],\"rFmBG3\":[\"顏色主題\"],\"rdUucN\":[\"預覽\"],\"rzNUSl\":[\"包含 1 則貼文的主題\"],\"sGajR7\":[\"線程開始\"],\"t/YqKh\":[\"移除\"],\"tfrt7B\":[\"未配置任何重定向。\"],\"tiq7kl\":[\"頁面 \",[\"page\"]],\"u2f7vd\":[\"網站描述\"],\"u3wRF+\":[\"已發佈\"],\"u6Hp4N\":[\"Markdown\"],\"uAQUqI\":[\"狀態\"],\"vXIe7J\":[\"語言\"],\"vzU4k9\":[\"新收藏集\"],\"wEF6Ix\":[\"目的地路徑或 URL\"],\"wK4OTM\":[\"標題(選填)\"],\"wM5UXj\":[\"刪除媒體\"],\"wRR604\":[\"頁面\"],\"wja8aL\":[\"無標題\"],\"x+doid\":[\"圖片會自動優化:調整大小至最大 1920 像素,轉換為 WebP 格式,並去除元數據。\"],\"x0mzE0\":[\"創建你的第一篇帖子\"],\"x4RuFo\":[\"回到首頁\"],\"xYilR2\":[\"媒體\"],\"y28hnO\":[\"文章\"],\"yQ2kGp\":[\"載入更多\"],\"yjkELF\":[\"確認新密碼\"],\"yzF66j\":[\"連結\"],\"z8ajIE\":[\"找到 1 個結果\"],\"zH6KqE\":[\"找到 \",[\"count\"],\" 個結果\"]}");
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -1,14 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Unified Configuration
|
|
2
|
+
* Unified Configuration System
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Provides a flexible configuration system with two priority modes:
|
|
5
|
+
* - User-configurable (envOnly: false): Database > Environment > Default
|
|
6
|
+
* - Environment-only (envOnly: true): Environment > Default
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
* in environment variables, while allowing runtime overrides via database.
|
|
8
|
+
* All configuration fields are defined in CONFIG_FIELDS (types.ts).
|
|
8
9
|
*/
|
|
9
10
|
import type { Context } from "hono";
|
|
11
|
+
import { type ConfigKey } from "../types.js";
|
|
10
12
|
/**
|
|
11
|
-
* Get
|
|
13
|
+
* Get the fallback value for a config key (ENV > Default), skipping the database.
|
|
14
|
+
* Used for placeholder values in forms where the DB value is shown separately.
|
|
15
|
+
*
|
|
16
|
+
* @param c - Hono context
|
|
17
|
+
* @param key - Configuration key from CONFIG_FIELDS
|
|
18
|
+
* @returns Fallback value from environment or default
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const placeholder = getConfigFallback(c, "SITE_NAME");
|
|
23
|
+
* // Returns: c.env.SITE_NAME ?? "Jant"
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function getConfigFallback(c: Context, key: ConfigKey): string;
|
|
27
|
+
/**
|
|
28
|
+
* Generic configuration getter that respects priority settings
|
|
29
|
+
*
|
|
30
|
+
* @param c - Hono context
|
|
31
|
+
* @param key - Configuration key from CONFIG_FIELDS
|
|
32
|
+
* @returns Configuration value following the defined priority
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // For user-configurable configs (SITE_NAME):
|
|
37
|
+
* // Returns: (DB: SITE_NAME) ?? c.env.SITE_NAME ?? "Jant"
|
|
38
|
+
*
|
|
39
|
+
* // For environment-only configs (SITE_URL):
|
|
40
|
+
* // Returns: c.env.SITE_URL ?? ""
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function getConfig(c: Context, key: ConfigKey): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Get site name with fallback chain: DB > ENV > Default
|
|
12
46
|
*
|
|
13
47
|
* @param c - Hono context
|
|
14
48
|
* @returns Site name
|
|
@@ -16,12 +50,12 @@ import type { Context } from "hono";
|
|
|
16
50
|
* @example
|
|
17
51
|
* ```typescript
|
|
18
52
|
* const siteName = await getSiteName(c);
|
|
19
|
-
* // Returns:
|
|
53
|
+
* // Returns: (DB: SITE_NAME) ?? c.env.SITE_NAME ?? "Jant"
|
|
20
54
|
* ```
|
|
21
55
|
*/
|
|
22
56
|
export declare function getSiteName(c: Context): Promise<string>;
|
|
23
57
|
/**
|
|
24
|
-
* Get site description with fallback chain:
|
|
58
|
+
* Get site description with fallback chain: DB > ENV > Default
|
|
25
59
|
*
|
|
26
60
|
* @param c - Hono context
|
|
27
61
|
* @returns Site description
|
|
@@ -29,12 +63,12 @@ export declare function getSiteName(c: Context): Promise<string>;
|
|
|
29
63
|
* @example
|
|
30
64
|
* ```typescript
|
|
31
65
|
* const description = await getSiteDescription(c);
|
|
32
|
-
* // Returns:
|
|
66
|
+
* // Returns: (DB: SITE_DESCRIPTION) ?? c.env.SITE_DESCRIPTION ?? "A microblog powered by Jant"
|
|
33
67
|
* ```
|
|
34
68
|
*/
|
|
35
69
|
export declare function getSiteDescription(c: Context): Promise<string>;
|
|
36
70
|
/**
|
|
37
|
-
* Get site language with fallback chain:
|
|
71
|
+
* Get site language with fallback chain: DB > ENV > Default
|
|
38
72
|
*
|
|
39
73
|
* @param c - Hono context
|
|
40
74
|
* @returns Site language code
|
|
@@ -42,7 +76,7 @@ export declare function getSiteDescription(c: Context): Promise<string>;
|
|
|
42
76
|
* @example
|
|
43
77
|
* ```typescript
|
|
44
78
|
* const lang = await getSiteLanguage(c);
|
|
45
|
-
* // Returns:
|
|
79
|
+
* // Returns: (DB: SITE_LANGUAGE) ?? c.env.SITE_LANGUAGE ?? "en"
|
|
46
80
|
* ```
|
|
47
81
|
*/
|
|
48
82
|
export declare function getSiteLanguage(c: Context): Promise<string>;
|
package/dist/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,GAAG,MAAM,CAKpE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAqB3E;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7D;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAEpE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAEjE"}
|
package/dist/lib/config.js
CHANGED
|
@@ -1,36 +1,81 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Unified Configuration
|
|
2
|
+
* Unified Configuration System
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Provides a flexible configuration system with two priority modes:
|
|
5
|
+
* - User-configurable (envOnly: false): Database > Environment > Default
|
|
6
|
+
* - Environment-only (envOnly: true): Environment > Default
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Get
|
|
8
|
+
* All configuration fields are defined in CONFIG_FIELDS (types.ts).
|
|
9
|
+
*/ import { CONFIG_FIELDS } from "../types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Get the fallback value for a config key (ENV > Default), skipping the database.
|
|
12
|
+
* Used for placeholder values in forms where the DB value is shown separately.
|
|
10
13
|
*
|
|
11
14
|
* @param c - Hono context
|
|
12
|
-
* @
|
|
15
|
+
* @param key - Configuration key from CONFIG_FIELDS
|
|
16
|
+
* @returns Fallback value from environment or default
|
|
13
17
|
*
|
|
14
18
|
* @example
|
|
15
19
|
* ```typescript
|
|
16
|
-
* const
|
|
17
|
-
* // Returns: c.env.SITE_NAME ??
|
|
20
|
+
* const placeholder = getConfigFallback(c, "SITE_NAME");
|
|
21
|
+
* // Returns: c.env.SITE_NAME ?? "Jant"
|
|
18
22
|
* ```
|
|
19
|
-
*/ export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
*/ export function getConfigFallback(c, key) {
|
|
24
|
+
const field = CONFIG_FIELDS[key];
|
|
25
|
+
const envValue = c.env[key];
|
|
26
|
+
if (envValue && typeof envValue === "string") return envValue;
|
|
27
|
+
return field.defaultValue;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generic configuration getter that respects priority settings
|
|
31
|
+
*
|
|
32
|
+
* @param c - Hono context
|
|
33
|
+
* @param key - Configuration key from CONFIG_FIELDS
|
|
34
|
+
* @returns Configuration value following the defined priority
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // For user-configurable configs (SITE_NAME):
|
|
39
|
+
* // Returns: (DB: SITE_NAME) ?? c.env.SITE_NAME ?? "Jant"
|
|
40
|
+
*
|
|
41
|
+
* // For environment-only configs (SITE_URL):
|
|
42
|
+
* // Returns: c.env.SITE_URL ?? ""
|
|
43
|
+
* ```
|
|
44
|
+
*/ export async function getConfig(c, key) {
|
|
45
|
+
const field = CONFIG_FIELDS[key];
|
|
46
|
+
if (!field.envOnly) {
|
|
47
|
+
// User-configurable: DB > ENV > Default
|
|
48
|
+
// 1. Check database setting first
|
|
49
|
+
const dbValue = await c.var.services.settings.get(key);
|
|
50
|
+
if (dbValue) {
|
|
51
|
+
return dbValue;
|
|
52
|
+
}
|
|
23
53
|
}
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
54
|
+
// ENV > Default
|
|
55
|
+
// 2. Check environment variable
|
|
56
|
+
const envValue = c.env[key];
|
|
57
|
+
if (envValue && typeof envValue === "string") {
|
|
58
|
+
return envValue;
|
|
28
59
|
}
|
|
29
60
|
// 3. Default value
|
|
30
|
-
return
|
|
61
|
+
return field.defaultValue;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get site name with fallback chain: DB > ENV > Default
|
|
65
|
+
*
|
|
66
|
+
* @param c - Hono context
|
|
67
|
+
* @returns Site name
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const siteName = await getSiteName(c);
|
|
72
|
+
* // Returns: (DB: SITE_NAME) ?? c.env.SITE_NAME ?? "Jant"
|
|
73
|
+
* ```
|
|
74
|
+
*/ export async function getSiteName(c) {
|
|
75
|
+
return getConfig(c, "SITE_NAME");
|
|
31
76
|
}
|
|
32
77
|
/**
|
|
33
|
-
* Get site description with fallback chain:
|
|
78
|
+
* Get site description with fallback chain: DB > ENV > Default
|
|
34
79
|
*
|
|
35
80
|
* @param c - Hono context
|
|
36
81
|
* @returns Site description
|
|
@@ -38,23 +83,13 @@
|
|
|
38
83
|
* @example
|
|
39
84
|
* ```typescript
|
|
40
85
|
* const description = await getSiteDescription(c);
|
|
41
|
-
* // Returns:
|
|
86
|
+
* // Returns: (DB: SITE_DESCRIPTION) ?? c.env.SITE_DESCRIPTION ?? "A microblog powered by Jant"
|
|
42
87
|
* ```
|
|
43
88
|
*/ export async function getSiteDescription(c) {
|
|
44
|
-
|
|
45
|
-
if (c.env.SITE_DESCRIPTION) {
|
|
46
|
-
return c.env.SITE_DESCRIPTION;
|
|
47
|
-
}
|
|
48
|
-
// 2. Check database setting
|
|
49
|
-
const dbValue = await c.var.services.settings.get("SITE_DESCRIPTION");
|
|
50
|
-
if (dbValue) {
|
|
51
|
-
return dbValue;
|
|
52
|
-
}
|
|
53
|
-
// 3. Default value
|
|
54
|
-
return "A microblog powered by Jant";
|
|
89
|
+
return getConfig(c, "SITE_DESCRIPTION");
|
|
55
90
|
}
|
|
56
91
|
/**
|
|
57
|
-
* Get site language with fallback chain:
|
|
92
|
+
* Get site language with fallback chain: DB > ENV > Default
|
|
58
93
|
*
|
|
59
94
|
* @param c - Hono context
|
|
60
95
|
* @returns Site language code
|
|
@@ -62,18 +97,8 @@
|
|
|
62
97
|
* @example
|
|
63
98
|
* ```typescript
|
|
64
99
|
* const lang = await getSiteLanguage(c);
|
|
65
|
-
* // Returns:
|
|
100
|
+
* // Returns: (DB: SITE_LANGUAGE) ?? c.env.SITE_LANGUAGE ?? "en"
|
|
66
101
|
* ```
|
|
67
102
|
*/ export async function getSiteLanguage(c) {
|
|
68
|
-
|
|
69
|
-
if (c.env.SITE_LANGUAGE) {
|
|
70
|
-
return c.env.SITE_LANGUAGE;
|
|
71
|
-
}
|
|
72
|
-
// 2. Check database setting
|
|
73
|
-
const dbValue = await c.var.services.settings.get("SITE_LANGUAGE");
|
|
74
|
-
if (dbValue) {
|
|
75
|
-
return dbValue;
|
|
76
|
-
}
|
|
77
|
-
// 3. Default value
|
|
78
|
-
return "en";
|
|
103
|
+
return getConfig(c, "SITE_LANGUAGE");
|
|
79
104
|
}
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Reserved URL paths that cannot be used for pages
|
|
6
6
|
*/
|
|
7
|
-
export declare const RESERVED_PATHS: readonly ["featured", "signin", "signout", "setup", "dash", "api", "feed", "search", "archive", "notes", "articles", "links", "quotes", "media", "pages", "p", "c", "static", "assets", "health"];
|
|
7
|
+
export declare const RESERVED_PATHS: readonly ["featured", "signin", "signout", "setup", "dash", "api", "feed", "search", "archive", "notes", "articles", "links", "quotes", "media", "pages", "reset", "p", "c", "static", "assets", "health", "appearance"];
|
|
8
8
|
export type ReservedPath = (typeof RESERVED_PATHS)[number];
|
|
9
9
|
/**
|
|
10
10
|
* Check if a path is reserved
|
|
@@ -23,6 +23,7 @@ export declare const SETTINGS_KEYS: {
|
|
|
23
23
|
readonly SITE_DESCRIPTION: "SITE_DESCRIPTION";
|
|
24
24
|
readonly SITE_LANGUAGE: "SITE_LANGUAGE";
|
|
25
25
|
readonly THEME: "THEME";
|
|
26
|
+
readonly PASSWORD_RESET_TOKEN: "PASSWORD_RESET_TOKEN";
|
|
26
27
|
};
|
|
27
28
|
export type SettingsKey = (typeof SETTINGS_KEYS)[keyof typeof SETTINGS_KEYS];
|
|
28
29
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,0NAuBjB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpD;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;CAOhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;CAGpB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAC1B,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC"}
|
package/dist/lib/constants.js
CHANGED
|
@@ -18,11 +18,13 @@
|
|
|
18
18
|
"quotes",
|
|
19
19
|
"media",
|
|
20
20
|
"pages",
|
|
21
|
+
"reset",
|
|
21
22
|
"p",
|
|
22
23
|
"c",
|
|
23
24
|
"static",
|
|
24
25
|
"assets",
|
|
25
|
-
"health"
|
|
26
|
+
"health",
|
|
27
|
+
"appearance"
|
|
26
28
|
];
|
|
27
29
|
/**
|
|
28
30
|
* Check if a path is reserved
|
|
@@ -40,7 +42,8 @@
|
|
|
40
42
|
SITE_NAME: "SITE_NAME",
|
|
41
43
|
SITE_DESCRIPTION: "SITE_DESCRIPTION",
|
|
42
44
|
SITE_LANGUAGE: "SITE_LANGUAGE",
|
|
43
|
-
THEME: "THEME"
|
|
45
|
+
THEME: "THEME",
|
|
46
|
+
PASSWORD_RESET_TOKEN: "PASSWORD_RESET_TOKEN"
|
|
44
47
|
};
|
|
45
48
|
/**
|
|
46
49
|
* Onboarding status values
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side Media Upload Handler
|
|
3
|
+
*
|
|
4
|
+
* Handles file upload flow:
|
|
5
|
+
* 1. User selects file via [data-media-upload] input
|
|
6
|
+
* 2. Creates placeholder in grid with spinner
|
|
7
|
+
* 3. Processes image via ImageProcessor (resize/convert to WebP)
|
|
8
|
+
* 4. Sets processed file on hidden Datastar form via DataTransfer API
|
|
9
|
+
* 5. Triggers form.requestSubmit() — Datastar handles upload + SSE response
|
|
10
|
+
*/ import { ImageProcessor } from "./image-processor.js";
|
|
11
|
+
/**
|
|
12
|
+
* Format file size for display
|
|
13
|
+
*/ function formatFileSize(bytes) {
|
|
14
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
15
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
16
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Ensure the media grid exists, removing empty state if needed
|
|
20
|
+
*/ function ensureGridExists() {
|
|
21
|
+
let grid = document.getElementById("media-grid");
|
|
22
|
+
if (grid) return grid;
|
|
23
|
+
document.getElementById("empty-state")?.remove();
|
|
24
|
+
grid = document.createElement("div");
|
|
25
|
+
grid.id = "media-grid";
|
|
26
|
+
grid.className = "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4";
|
|
27
|
+
document.getElementById("media-content")?.appendChild(grid);
|
|
28
|
+
return grid;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create a placeholder card with spinner in the media grid
|
|
32
|
+
*/ function createPlaceholder(fileName, fileSize, statusText) {
|
|
33
|
+
const placeholder = document.createElement("div");
|
|
34
|
+
placeholder.id = "upload-placeholder";
|
|
35
|
+
placeholder.className = "group relative";
|
|
36
|
+
placeholder.innerHTML = `
|
|
37
|
+
<div class="aspect-square bg-muted rounded-lg overflow-hidden border flex items-center justify-center">
|
|
38
|
+
<div class="text-center px-2">
|
|
39
|
+
<svg class="animate-spin h-6 w-6 text-muted-foreground mx-auto mb-2" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
40
|
+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
41
|
+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
42
|
+
</svg>
|
|
43
|
+
<span id="upload-status" class="text-xs text-muted-foreground">${statusText}</span>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
<div class="mt-2 text-xs truncate" title="${fileName}">${fileName}</div>
|
|
47
|
+
<div class="text-xs text-muted-foreground">${formatFileSize(fileSize)}</div>
|
|
48
|
+
`;
|
|
49
|
+
return placeholder;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Replace placeholder content with an error message
|
|
53
|
+
*/ function showPlaceholderError(placeholder, fileName, errorMessage) {
|
|
54
|
+
placeholder.innerHTML = `
|
|
55
|
+
<div class="aspect-square bg-destructive/10 rounded-lg overflow-hidden border border-destructive flex items-center justify-center">
|
|
56
|
+
<div class="text-center px-2">
|
|
57
|
+
<span class="text-xs text-destructive">${errorMessage}</span>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="mt-2 text-xs truncate text-destructive">${fileName}</div>
|
|
61
|
+
<button type="button" class="text-xs text-muted-foreground hover:underline" onclick="this.closest('.group').remove()">Remove</button>
|
|
62
|
+
`;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Handle the upload flow for a selected file
|
|
66
|
+
*/ async function handleUpload(input, file) {
|
|
67
|
+
const processingText = input.dataset.textProcessing || "Processing...";
|
|
68
|
+
const uploadingText = input.dataset.textUploading || "Uploading...";
|
|
69
|
+
const errorText = input.dataset.textError || "Upload failed. Please try again.";
|
|
70
|
+
const grid = ensureGridExists();
|
|
71
|
+
const placeholder = createPlaceholder(file.name, file.size, processingText);
|
|
72
|
+
grid.prepend(placeholder);
|
|
73
|
+
try {
|
|
74
|
+
// Process image client-side (resize, convert to WebP)
|
|
75
|
+
const processed = await ImageProcessor.processToFile(file);
|
|
76
|
+
// Update status
|
|
77
|
+
const statusEl = document.getElementById("upload-status");
|
|
78
|
+
if (statusEl) statusEl.textContent = uploadingText;
|
|
79
|
+
// Set processed file on hidden form input via DataTransfer API
|
|
80
|
+
const formInput = document.getElementById("upload-file-input");
|
|
81
|
+
const form = document.getElementById("upload-form");
|
|
82
|
+
if (!formInput || !form) throw new Error("Upload form not found");
|
|
83
|
+
const dt = new DataTransfer();
|
|
84
|
+
dt.items.add(processed);
|
|
85
|
+
formInput.files = dt.files;
|
|
86
|
+
// Trigger Datastar-intercepted form submission
|
|
87
|
+
form.requestSubmit();
|
|
88
|
+
} catch (err) {
|
|
89
|
+
const message = err instanceof Error ? err.message : errorText;
|
|
90
|
+
showPlaceholderError(placeholder, file.name, message);
|
|
91
|
+
}
|
|
92
|
+
// Reset file input so the same file can be re-selected
|
|
93
|
+
input.value = "";
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Initialize media upload via event delegation
|
|
97
|
+
*/ function initMediaUpload() {
|
|
98
|
+
document.addEventListener("change", (e)=>{
|
|
99
|
+
const input = e.target.closest("[data-media-upload]");
|
|
100
|
+
if (!input?.files?.[0]) return;
|
|
101
|
+
handleUpload(input, input.files[0]);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
initMediaUpload();
|