--- import AdminLayout from "../../layouts/AdminLayout.astro"; import { getDb } from "../../lib/db"; import { getEnv } from "../../lib/env"; import { getDashboardData, getSettings } from "../../data/content"; export const prerender = false; const env = getEnv(); const db = getDb(env.DB); const data = await getDashboardData(db); const settings = await getSettings(db); const KIND_LABELS: Record = { service: "服務", feature: "特色", step: "流程", faq: "FAQ", }; const postTotal = data.posts.published + data.posts.draft; const caseTotal = data.cases.published + data.cases.draft; const contentPublished = data.content.reduce((n, c) => n + c.published, 0); const kw = data.keywords; const kwTotal = kw.pending + kw.generated + kw.skipped; const contentDraft = data.content.reduce((n, c) => n + c.draft, 0); const todos: { text: string; href: string }[] = []; if (data.posts.draft) todos.push({ text: `${data.posts.draft} 篇文章仍是草稿`, href: "/admin/posts" }); if (data.postsWithoutCover) todos.push({ text: `${data.postsWithoutCover} 篇文章未有封面圖`, href: "/admin/posts" }); if (kw.pending) todos.push({ text: `${kw.pending} 個關鍵字待生成`, href: "/admin/ai" }); if (data.cases.draft) todos.push({ text: `${data.cases.draft} 個案例仍是草稿`, href: "/admin/cases" }); if (contentDraft) todos.push({ text: `${contentDraft} 個首頁內容項目仍是草稿`, href: "/admin/content/service" }); const secrets = { ai: Boolean(env.AI_API_KEY), tavily: Boolean(env.TAVILY_API_KEY) }; const aiEnabled = settings.ai_enabled !== "0"; ---

總覽

內容同系統狀態一覽。前台會自動更新。

{postTotal}
文章
已發布 {data.posts.published} · 草稿 {data.posts.draft}
{caseTotal}
完成案例
已發布 {data.cases.published} · 草稿 {data.cases.draft}
{contentPublished}
首頁內容
{data.content.map((c, i) => `${KIND_LABELS[c.kind] ?? c.kind} ${c.published}${i < data.content.length - 1 ? " · " : ""}`)}
{kw.pending}
關鍵字待生成
已生成 {kw.generated} · 已略過 {kw.skipped} · 共 {kwTotal}

待辦提示

{ todos.length === 0 ? (

一切妥當,冇待辦事項。

) : ( todos.map((t) => ( {t.text} )) ) }

系統狀態

AI 生成 {aiEnabled ? "啟用" : "停用"}
AI_API_KEY {secrets.ai ? "已設定" : "未設定"}
TAVILY_API_KEY {secrets.tavily ? "已設定" : "未設定"}
模型 {settings.ai_chat_model || "deepseek-flash"}
Base URL {settings.ai_base_url || "https://api.deepseek.com"}

最近更新文章

+ 寫新文
{ data.recentPosts.length === 0 ? (

仲未有任何文章。寫第一篇 →

) : ( {data.recentPosts.map((p) => ( ))}
標題 狀態 更新時間
{p.title}
/{p.slug}
{p.status === "published" ? "已發布" : "草稿"} {new Date(p.updatedAt).toLocaleDateString("zh-Hant-HK")} 編輯
) }