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.
11 lines
364 B
SQL
11 lines
364 B
SQL
CREATE TABLE `blog_keywords` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`keyword` text NOT NULL,
|
|
`status` text DEFAULT 'pending' NOT NULL,
|
|
`created_at` integer NOT NULL,
|
|
`used_at` integer,
|
|
`post_id` text
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `idx_keywords_status` ON `blog_keywords` (`status`);--> statement-breakpoint
|
|
ALTER TABLE `posts` ADD `focus_keyword` text; |