新增 GA4 / Meta Pixel 追蹤與 Cookie 同意機制
- 追蹤 ID 存 site_settings(空字串即關閉),於 /admin/settings 管理 - Base.astro 僅在用戶同意後載入分析工具,未同意前零請求 - 新增 /privacy 私隱政策頁與「重設 Cookie 偏好」按鈕 - 前台 SSR 頁面(首頁、blog、about、privacy)傳入 gaId / metaPixelId - seed 加入預設空值,Footer 加入私隱政策連結 - 同步更新 AGENTS.md 與 README 說明
This commit is contained in:
@@ -50,21 +50,38 @@ npm run dev
|
||||
|
||||
## 部署到 Cloudflare
|
||||
|
||||
### 首次設定(一鍵)
|
||||
### 1. 先設定網址(部署前一定要做)
|
||||
|
||||
`sitemap` / `canonical` / `OG` 全部靠 `astro.config.mjs` 嘅 `site`,所以**先改佢**:
|
||||
|
||||
```js
|
||||
// astro.config.mjs
|
||||
site: "https://your-domain.com",
|
||||
```
|
||||
|
||||
想用 Cloudflare 自訂網域(例如 `solar.develop-cat.com`)就順手喺 `wrangler.jsonc` 加:
|
||||
|
||||
```jsonc
|
||||
"routes": [
|
||||
{ "pattern": "solar.develop-cat.com", "custom_domain": true }
|
||||
],
|
||||
```
|
||||
|
||||
部署時會自動建立 DNS + TLS,唔使自己開 record。唔加就淨係用 `https://<worker-name>.<account>.workers.dev`;亦可以部署後喺 Dashboard → Worker → Settings → Domains & Routes 手動加。
|
||||
|
||||
### 2. 首次設定(一鍵)
|
||||
|
||||
```bash
|
||||
npm run login # 瀏覽器授權
|
||||
npm run setup # 建立 D1 / KV / R2、寫入 wrangler.jsonc、設 secret、套 migration + seed
|
||||
npm run setup # 建 D1 / KV / R2、寫入 wrangler.jsonc 嘅 id、設 secret、可選 migration + seed + build + deploy
|
||||
```
|
||||
|
||||
`npm run setup` 會逐步問你:要唔要設定後台密碼、要唔要套 migration/seed、要唔要 build + deploy。若 `astro.config.mjs` 嘅 `site` 仍然係 `https://example.com`,會跳過 build + deploy 並提醒你改。
|
||||
`npm run setup` 會逐步問你:設定後台密碼?套 migration/seed?build + deploy?若 `site` 仍係 `https://example.com`,會跳過 build + deploy 並提醒你改(改完再 `npm run deploy`)。
|
||||
|
||||
### 之後更新
|
||||
|
||||
改完 `astro.config.mjs` 嘅 `site` 做真域名後:
|
||||
### 3. 之後更新
|
||||
|
||||
```bash
|
||||
npm run deploy
|
||||
npm run deploy # = npm run build + wrangler deploy
|
||||
```
|
||||
|
||||
### Git push 自動部署(Cloudflare Workers Builds)
|
||||
@@ -76,6 +93,7 @@ npm run deploy
|
||||
|
||||
**Migration 唔會喺 CI 自動執行**:改完 `src/db/schema.ts` 要手動跑
|
||||
`npm run db:generate` → `npm run db:migrate`(雲端)→ `npm run db:seed`(如有新 seed)。
|
||||
`seed.sql` 放喺 `scripts/`(唔可以放喺 `migrations/`,否則 `db:migrate` 會連 seed 一齊種)。
|
||||
|
||||
## AI 生成 Blog
|
||||
|
||||
@@ -110,12 +128,13 @@ src/
|
||||
├─ layouts/AdminLayout.astro 後台外框
|
||||
├─ pages/
|
||||
│ ├─ index.astro SSR 首頁
|
||||
│ ├─ about.astro 關於(靜態)
|
||||
│ ├─ blog/… Blog
|
||||
│ ├─ admin/… 後台(含 admin/ai、admin/upload 上傳 endpoint)
|
||||
│ ├─ media/[...key].ts R2 圖片出圖 endpoint
|
||||
│ └─ sitemap.xml.ts / robots.txt.ts
|
||||
├─ components/admin/ImageField.astro 後台圖片欄(URL + 上傳 + 預覽)
|
||||
├─ lib/{auth,db,env,form,media,ai,markdown}.ts
|
||||
├─ lib/{auth,db,env,form,media,ai,markdown,schema-org}.ts
|
||||
migrations/
|
||||
├─ 0000_init.sql … Drizzle migrations
|
||||
scripts/
|
||||
|
||||
Reference in New Issue
Block a user