first commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# src/data/AGENTS.md
|
||||
|
||||
## Purpose
|
||||
|
||||
D1 讀取查詢層(`content.ts`)同後台網站設定欄位定義(`settings-fields.ts`)。
|
||||
|
||||
## Ownership
|
||||
|
||||
- 擁有 `src/data/` 兩個檔案。
|
||||
- Drizzle schema 本體喺 `src/db/schema.ts`(見兄弟 `db/AGENTS.md`),呢度只消費其型別。
|
||||
|
||||
## Local Contracts
|
||||
|
||||
- **查詢集中**:所有前台/Blog 的 D1 查詢寫喺 `content.ts`,唔好散落喺頁面或元件。
|
||||
- **只回前台可見**:`getItems` / `getCases` / `getPublishedPosts` 只回 `status = "published"`,並按 `sortOrder` 或 `publishedAt DESC` 排序;`getPostBySlug` 同時要求 published。
|
||||
- **首頁聚合**:`getHomeData(db)` 用 `Promise.all` 一次過攞 settings + services/features/steps/faqs + cases,形狀係 `HomeData`。
|
||||
- **`Db` 型別**:`DrizzleD1Database<typeof schema>`。
|
||||
- **連結 helper**:`whatsappHref` / `telHref` / `mailHref` / `digits` / `formatDate`;電話/WhatsApp 一律經呢啲 helper,唔好散寫。
|
||||
- **設定欄位**:`settings-fields.ts` 的 `SETTINGS_GROUPS` 係 `/admin/settings` 表單的唯一來源;新增一個 setting key 之後,要同步加落 `migrations/seed.sql`。
|
||||
- 顯示用文案繁體中文。
|
||||
|
||||
## Work Guidance
|
||||
|
||||
- 新增可管理欄位:改 `settings-fields.ts` → 加 seed default → 喺前端消費(多數喺 `components/site/*`)。
|
||||
|
||||
## Verification
|
||||
|
||||
- `npm run build`。
|
||||
- `npm run db:seed:local` 後 `/admin` 同前台睇得到種子資料。
|
||||
|
||||
## Child DOX Index
|
||||
|
||||
無。
|
||||
Reference in New Issue
Block a user