Introduce a schema-first validation layer and an AI blog generation feature, plus one-command Cloudflare provisioning. - src/schemas/ holds Zod input schemas for post, content, case, settings, AI, and keywords; parseForm() in src/lib/form.ts validates FormData and returns per-field errors. - Migrate all admin POST handlers to parseForm, showing field-level errors and only redirecting once validation passes. - Add blog_keywords table and posts.focus_keyword (migration 0002); uniqueSlug() centralised in src/data/content.ts. - Add src/lib/ai.ts (OpenAI-compatible chat completions + optional Tavily research) and /admin/ai for AI settings, keyword queue, and draft generation. - Add scripts/setup.mjs (npm run setup) to provision D1/KV, set secrets, and optionally migrate, seed, and deploy. - Document AI secrets, Workers Builds deploy flow, and new schemas across README and AGENTS docs.
97 lines
10 KiB
SQL
97 lines
10 KiB
SQL
-- 盈豐太陽能工程有限公司 — 種子資料
|
|
-- 用法: npm run db:seed:local / npm run db:seed
|
|
-- 全部使用 INSERT OR REPLACE,可重複執行。
|
|
|
|
INSERT OR REPLACE INTO site_settings (key, value, updated_at) VALUES
|
|
('company_name', '盈豐太陽能工程有限公司', strftime('%s','now')*1000),
|
|
('company_short_name', '盈豐太陽能', strftime('%s','now')*1000),
|
|
('license_no', '電業承辦商編號:待填', strftime('%s','now')*1000),
|
|
('phone', '+852 0000 0000', strftime('%s','now')*1000),
|
|
('whatsapp', '85200000000', strftime('%s','now')*1000),
|
|
('email', '[email protected]', strftime('%s','now')*1000),
|
|
('address', '香港新界(地址待填)', strftime('%s','now')*1000),
|
|
('facebook_url', '', strftime('%s','now')*1000),
|
|
('hero_eyebrow', '香港村屋太陽能專家', strftime('%s','now')*1000),
|
|
('hero_title', '善用村屋天台 發電慳電賺回報', strftime('%s','now')*1000),
|
|
('hero_subtitle', '由現場評估、方案建議、安裝施工,到申請同跟進,我哋用清晰易明嘅方式,陪你完成整個村屋太陽能項目。', strftime('%s','now')*1000),
|
|
('hero_primary_cta', '免費預約評估', strftime('%s','now')*1000),
|
|
('hero_secondary_cta', '睇完成案例', strftime('%s','now')*1000),
|
|
('hero_image', 'https://images.unsplash.com/photo-1509391366360-2e959784a276?auto=format&fit=crop&w=1600&q=80', strftime('%s','now')*1000),
|
|
('seo_default_title', '盈豐太陽能工程有限公司 — 香港村屋太陽能一站式服務', strftime('%s','now')*1000),
|
|
('seo_default_description', '專營香港村屋太陽能系統:現場評估、合法支架、代辦申請、專業安裝及驗收認證。透明報價,專人跟進,幫你善用天台賺取發電回報。', strftime('%s','now')*1000),
|
|
('og_image', 'https://images.unsplash.com/photo-1509391366360-2e959784a276?auto=format&fit=crop&w=1200&q=80', strftime('%s','now')*1000);
|
|
|
|
INSERT OR REPLACE INTO site_settings (key, value, updated_at) VALUES
|
|
('ai_enabled', '1', strftime('%s','now')*1000),
|
|
('ai_base_url', 'https://api.deepinfra.com/v1/openai', strftime('%s','now')*1000),
|
|
('ai_chat_model', 'deepseek-ai/DeepSeek-V3-0324', strftime('%s','now')*1000),
|
|
('ai_context_prompt', '用香港繁體中文(廣東話書面語)書寫,語氣專業、親切、務實,避免誇大。', strftime('%s','now')*1000),
|
|
('ai_business_context', '盈豐太陽能工程有限公司專營香港村屋太陽能系統:現場評估、合法鋁合金支架、代辦中電/港燈上網電價(FiT)申請、專業安裝及驗收認證。着重透明報價、專人跟進、安全合規。', strftime('%s','now')*1000),
|
|
('ai_web_search_enabled', '0', strftime('%s','now')*1000),
|
|
('ai_web_search_max_results', '5', strftime('%s','now')*1000);
|
|
|
|
INSERT OR REPLACE INTO content_items (id, kind, title, description, extra, sort_order, status, updated_at) VALUES
|
|
('svc-001', 'service', '村屋天台太陽能系統', '善用村屋天台空間,安裝高效太陽能板,將閒置天台變成穩定收入來源。', 'sun', 1, 'published', strftime('%s','now')*1000),
|
|
('svc-002', 'service', '合法合規支架工程', '按村屋結構同法規設計鋁合金支架,穩固耐用,確保合乎相關要求。', 'shield', 2, 'published', strftime('%s','now')*1000),
|
|
('svc-003', 'service', '代辦申請及文件', '由中電/港燈申請、上網電價計劃(FiT)到相關政府文件,全程代辦。', 'file', 3, 'published', strftime('%s','now')*1000),
|
|
('svc-004', 'service', '專業安裝及驗收', '由認可人士(AP)及註冊電工施工,簽發所需認證文件,安全合法。', 'check', 4, 'published', strftime('%s','now')*1000),
|
|
('svc-005', 'service', '降低頂樓室溫', '太陽能板為天台遮蔭,有效降低頂樓單位溫度,同時慳冷氣電費。', 'snow', 5, 'published', strftime('%s','now')*1000),
|
|
('svc-006', 'service', '收益及回本分析', '按日照、面積同電價,提供清晰嘅發電量同回本估算,一目了然。', 'chart', 6, 'published', strftime('%s','now')*1000),
|
|
|
|
('feat-001', 'feature', '熟悉香港村屋環境', '深耕本地市場,充分掌握村屋結構、法規同地理限制。', 'map', 1, 'published', strftime('%s','now')*1000),
|
|
('feat-002', 'feature', '流程清晰易明', '用最簡單直白嘅方式解說回本期同技術細節,絕無花巧術語。', 'file', 2, 'published', strftime('%s','now')*1000),
|
|
('feat-003', 'feature', '專人快速跟進', '一對一顧問服務,由評估到完工全程透明,隨時解答疑問。', 'user', 3, 'published', strftime('%s','now')*1000),
|
|
('feat-004', 'feature', '美觀與效率兼備', '追求發電效率之餘,極致重視施工整齊度同建築美感。', 'sparkle', 4, 'published', strftime('%s','now')*1000),
|
|
('feat-005', 'feature', '重視施工安全', '嚴選耐用器材、嚴格執行安全程序,確保系統長久穩定。', 'shield', 5, 'published', strftime('%s','now')*1000),
|
|
('feat-006', 'feature', '不硬銷真誠建議', '先幫你了解安裝可行性,未必即刻做,最緊要係問清楚。', 'heart', 6, 'published', strftime('%s','now')*1000),
|
|
|
|
('step-001', 'step', '初步諮詢 / 現場評估', '專人上門視察環境,提供專業技術建議。', '01', 1, 'published', strftime('%s','now')*1000),
|
|
('step-002', 'step', '申請文件處理', '代辦電力公司同政府部門所需嘅申請文件。', '02', 2, 'published', strftime('%s','now')*1000),
|
|
('step-003', 'step', '安裝施工', '專業團隊進場施工,確保工期同施工品質安全。', '03', 3, 'published', strftime('%s','now')*1000),
|
|
('step-004', 'step', '驗收認證', '由認可人士及合資格電工簽發 C/PVS、WR1、GF1 等文件。', '04', 4, 'published', strftime('%s','now')*1000),
|
|
('step-005', 'step', '掛表正式發電', '電力公司掛上電表後,正式開始享受太陽能發電收益。', '05', 5, 'published', strftime('%s','now')*1000),
|
|
|
|
('faq-001', 'faq', '村屋天台可以安裝太陽能嗎?', '大部分村屋天台都可以。我哋會先上門評估結構、日照同遮擋情況,再判斷可行性同建議方案。', NULL, 1, 'published', strftime('%s','now')*1000),
|
|
('faq-002', 'faq', '安裝太陽能大概幾錢?幾時回本?', '造價視乎面積、支架形式同系統容量。一般村屋系統回本期約 6–9 年,之後發電收益基本上係淨賺。我哋會提供清晰報價同回本估算。', NULL, 2, 'published', strftime('%s','now')*1000),
|
|
('faq-003', 'faq', '需要幾大天台面積?', '一般每 1 kW 系統約需 60–80 平方呎,我哋會按實際可用面積設計最合適嘅容量。', NULL, 3, 'published', strftime('%s','now')*1000),
|
|
('faq-004', 'faq', '安裝太陽能合唔合法?會唔會影響樓宇結構?', '合規嘅村屋太陽能系統須符合相關法規同電力條例。我哋由設計到施工都依法處理,並由認可人士簽發所需文件。', NULL, 4, 'published', strftime('%s','now')*1000),
|
|
('faq-005', 'faq', '系統需要保養嗎?', '需要基本保養,例如定期清洗太陽能板同檢查線路。優質器材一般可用 20–25 年,保養得宜發電更穩定。', NULL, 5, 'published', strftime('%s','now')*1000),
|
|
('faq-006', 'faq', '申請上網電價(FiT)麻煩嗎?', '唔麻煩,我哋會代辦中電或港燈嘅上網電價計劃申請,由填表到掛表全程跟進。', NULL, 6, 'published', strftime('%s','now')*1000);
|
|
|
|
INSERT OR REPLACE INTO cases (id, title, location, completed_at, description, image_url, sort_order, status, updated_at) VALUES
|
|
('case-001', '大埔上碗窯 — 雙玻光伏板 航空鋁支架', '大埔半山', '2026年2月', '採用雙玻光伏板配航空級鋁合金支架,兼顧發電效率同天台景觀。', 'https://images.unsplash.com/photo-1613665813446-82a78c468a1d?auto=format&fit=crop&w=1200&q=80', 1, 'published', strftime('%s','now')*1000),
|
|
('case-002', '元朗山下村 — 香檳色鋁合金支架', '元朗屏山', '2025年7月', '香檳色支架配合村屋外牆色調,施工整齊,發電穩定。', 'https://images.unsplash.com/photo-1592833159155-c62df1b65634?auto=format&fit=crop&w=1200&q=80', 2, 'published', strftime('%s','now')*1000),
|
|
('case-003', '西貢西澳村 — 焗白色鋁合金支架', '新界西貢', '2025年5月', '焗白色支架低調美觀,善用天台每一寸可用空間。', 'https://images.unsplash.com/photo-1508514177221-188b1cf16e9d?auto=format&fit=crop&w=1200&q=80', 3, 'published', strftime('%s','now')*1000);
|
|
|
|
INSERT OR REPLACE INTO blog_keywords (id, keyword, status, created_at, used_at, post_id) VALUES
|
|
('kw-001', '村屋太陽能回本期', 'pending', strftime('%s','now')*1000, NULL, NULL),
|
|
('kw-002', '村屋天台安裝太陽能注意事項', 'pending', strftime('%s','now')*1000, NULL, NULL),
|
|
('kw-003', '上網電價 FiT 申請流程', 'pending', strftime('%s','now')*1000, NULL, NULL);
|
|
|
|
INSERT OR REPLACE INTO posts (id, slug, title, excerpt, content, cover_image, tags, meta_description, status, published_at, updated_at) VALUES
|
|
('post-001', 'village-house-solar-guide', '村屋安裝太陽能前,你要知嘅 5 件事', '想喺村屋天台裝太陽能?由天台面積、日照、支架法規到回本期,呢篇幫你一次過搞清楚。',
|
|
'村屋天台係香港少數可以合法大規模安裝太陽能嘅地方。不過落決定之前,以下 5 點你一定要知。
|
|
|
|
## 1. 天台面積有幾大?
|
|
|
|
一般每 1 kW 系統約需 60–80 平方呎可用面積。天台有無水箱、樓梯屋或其他遮擋,都會影響實際可安裝容量。
|
|
|
|
## 2. 日照同遮擋
|
|
|
|
向南、無遮擋嘅天台發電表現最好。我哋會用現場評估同工具分析你屋企嘅日照情況。
|
|
|
|
## 3. 支架要合法合規
|
|
|
|
村屋太陽能支架須符合相關法規。專業設計嘅鋁合金支架唔單止穩固,亦確保合乎要求。
|
|
|
|
## 4. 回本期有幾長?
|
|
|
|
一般村屋系統回本期約 6–9 年,之後嘅發電收益基本上係淨賺。實際數字視乎系統容量同電價。
|
|
|
|
## 5. 邊個幫你申請?
|
|
|
|
由中電/港燈嘅上網電價計劃(FiT)到政府文件,我哋會全程代辦,你唔需要自己四圍撲。
|
|
|
|
想知你屋企啱唔啱裝?歡迎 WhatsApp 我哋預約免費評估。',
|
|
'https://images.unsplash.com/photo-1509391366360-2e959784a276?auto=format&fit=crop&w=1600&q=80', '村屋,太陽能,指南', '村屋安裝太陽能前必知:天台面積、日照、支架法規、回本期同申請流程,一次講清楚。', 'published', strftime('%s','now')*1000, strftime('%s','now')*1000);
|