--- name: website-creator description: สร้างเว็บไซต์เต็มรูปแบบด้วย Astro + Tina CMS พร้อม Workflow สำหรับเว็บใหม่และ Migration ครอบคลุม Design System, Content Collections, Auth, SEO, PDPA Compliance และ Deploy tags: [astro, website, website-development, website-creation, migration, tailwindcss, thai, pdpa, seo, tina-cms, image-generation, picture-it] category: software-development related_skills: - spec-driven-development - frontend-ui-engineering - api-and-interface-design - code-review-and-quality - performance-optimization - browser-testing-with-devtools - shipping-and-launch --- # Website Creator Skill สร้างเว็บไซต์เต็มรูปแบบด้วย Astro + Tina CMS ## Architecture **Astro + Tina CMS Stack:** - **Astro 6.x** — Static site generator ที่เร็วมาก รองรับ React/Vue/Svelte components - **Tina CMS** — Self-hosted Git-based CMS สำหรับ visual content editing - **Tailwind CSS 4.x** — ใช้ `@tailwindcss/vite` plugin - **External Consent System** — Consent script จาก `consent.moreminimore.com` **Pattern อ้างอิง:** ใช้ template ที่มีอยู่แล้ว: `templates/astro-tina-starter/` ### Astro Project Structure ``` src/ ├── components/ # Astro/React components ├── content/ # Tina CMS content (MDX) │ ├── posts/ # Blog posts │ ├── pages/ # Static pages │ └── settings/ # Site settings (JSON) ├── layouts/ │ └── Layout.astro # Main layout ├── pages/ │ ├── index.astro # Home page │ └── [...slug].astro # Dynamic pages ├── styles/ │ └── global.css # Tailwind v4 + @theme └── env.d.ts .tina/ # Tina CMS configuration ├── config.ts # Tina config └── schema.ts # Content schema astro.config.mjs # Astro + Tailwind v4 + Tina package.json ``` ### Static vs SSR - **Static (default):** Pre-built HTML + รันบน CDN - **SSR/Hybrid:** ใช้เมื่อต้องการ API routes หรือ dynamic content - **Hybrid:** บางหน้า static บางหน้า dynamic **สำหรับ Easypanel:** ใช้ `output: 'static'` หรือ `output: 'hybrid'` (ถ้าต้องการ API routes) ## Critical Configuration Rules ### 1. astro.config.mjs (Tailwind v4 + Tina) ```javascript import { defineConfig } from 'astro/config' import tailwindcss from '@tailwindcss/vite' import tina from 'tinacms' export default defineConfig({ integrations: [ tina({ enabled: !!process.env.TINA_TOKEN, sidebar: { partials: [] }, }), ], vite: { plugins: [tailwindcss()], // Tailwind v4 ใช้ @tailwindcss/vite }, output: 'static', // หรือ 'hybrid' ถ้าต้องการ API routes }) ``` ### 2. Required Dependencies ```json { "dependencies": { "astro": "^6.1.7", "@tinacms/cli": "^2.1.0", "tinacms": "^2.2.0" }, "devDependencies": { "@tailwindcss/vite": "^4.0.0", "tailwindcss": "^4.0.0", "@astrojs/mdx": "^4.0.0", "typescript": "^5.6.0" } } ``` **CRITICAL: Tailwind v4 ใช้ `@tailwindcss/vite` plugin ไม่ใช่ `@astrojs/tailwind`** ### 3. Tailwind v4 Configuration Tailwind v4 ไม่มี `tailwind.config.js` — ใช้ CSS `@theme` block แทน: ```css /* src/styles/global.css */ @import "tailwindcss"; @theme { /* Fonts */ --font-sans: "Inter", "Noto Sans Thai", system-ui, sans-serif; /* Colors */ --color-primary-50: #f8fafc; --color-primary-900: #0f172a; --color-accent-500: #3b82f6; /* Border Radius */ --radius-sm: 0.25rem; --radius-lg: 0.75rem; --radius-xl: 1rem; } ``` ### 4. Tina CMS Schema ```typescript // .tina/schema.ts import { defineSchema } from 'tinacms' export const schema = defineSchema({ collections: [ { name: 'post', label: 'Posts', path: 'src/content/posts', format: 'mdx', fields: [ { type: 'string', name: 'title', label: 'Title', required: true }, { type: 'string', name: 'slug', label: 'Slug', required: true }, { type: 'datetime', name: 'publishedAt', label: 'Published At' }, { type: 'rich-text', name: 'body', label: 'Body', isBody: true }, ], }, { name: 'page', label: 'Pages', path: 'src/content/pages', format: 'mdx', fields: [ { type: 'string', name: 'title', label: 'Title', required: true }, { type: 'string', name: 'slug', label: 'Slug', required: true }, { type: 'rich-text', name: 'body', label: 'Body', isBody: true }, ], }, ], }) ``` --- ## Workflow A: สร้างเว็บใหม่ > ⚠️ **สำคัญ: ต้องวางแผนก่อน + รอ approve ก่อนทำงานเสมอ** > > ขั้นตอน: Context → Design → Plan → Approve → Execute --- ### Phase 1: Context Gathering (ถามให้ครบ) **ใช้ `references/questions.md` เป็นแนวทาง แต่ต้องถามให้ลึกกว่า surface level:** #### 1.1 ข้อมูลพื้นฐาน ``` 1. ชื่อเว็บไซต์/บริษัท? 2. ทำอะไร? (ขายอะไร/ให้บริการอะไร) 3. กลุ่มเป้าหมายคือใคร? 4. มีเว็บอยู่แล้วหรือยัง? ``` #### 1.2 Brand Context (ทำให้ต่างจากคนอื่น) ``` 5. ทำไมลูกค้าควรเลือกคุณ ไม่ใช่คู่แข่ง? 6. มี brand story หรือ positioning อะไรที่ต้องสื่อสาร? 7. มี tone of voice หรือ personality อย่างไร? (เช่น: friendly, professional, bold, playful) ``` #### 1.3 Design Context ``` 8. มี brand guidelines/logo file ไหม? 9. มี reference sites ที่ชอบ/ไม่ชอบบ้างไหม? (ส่งลิงก์มาได้) 10. มีสีที่ต้องใช้/ห้ามใช้บ้างไหม? ``` #### 1.4 Technical Context ``` 11. ต้องการหน้าอะไรบ้าง? (sitemap) 12. มี SMTP/email สำหรับส่งเมลไหม? 13. มี tracking tools ต้องติดตั้งไหม? (GA4, Facebook Pixel, etc.) 14. มี DPO หรือยัง? (สำหรับ PDPA) ``` --- ### Phase 2: Creative Design (บังคับต้องทำ) **เรียก skills: `ckm:design` + `ui-ux-pro-max` + `frontend-ui-engineering`** #### 2.1 สร้าง Creative Brief ก่อนสร้าง design ต้องมี creative brief ที่ชัดเจน: ``` # Creative Brief ## Brand Essence - ชื่อ/บริษัท: [ชื่อ] - สิ่งที่ทำ: [บริการ/สินค้า] - ทำไมต่าง: [unique selling point] ## Target Emotion - ต้องการให้คนเข้าเว็บแล้วรู้สึก: [เช่น มั่นใจ, สบายใจ, ตื่นเต้น, ไว้วางใจ] ## Design Direction - ห้ามใช้: [สี/รูปแบบที่ไม่ชอบ] - อาจใช้: [สี/รูปแบบที่ชอบ] - References: [ลิงก์ที่ชอบ/ไม่ชอบ] ``` #### 2.2 สร้าง 2-3 Creative Directions ที่ต่างกันจริงๆ **ใช้ `ckm:design` + `ui-ux-pro-max` สร้าง options ที่แตกต่างกัน:** ``` Direction A: "[Name]" - Concept: [แนวคิดหลัก] - Visual Style: [ลักษณะ visuals] - Color Palette: [โทนสี] - Typography: [แบบอักษร] - Layout Character: [โครงสร้าง layout ที่เป็นเอกลักษณ์] Direction B: "[Name]" - Concept: [แนวคิดหลัก - ต่างจาก A] - Visual Style: [ลักษณะ visuals - ต่างจาก A] - Color Palette: [โทนสี - ต่างจาก A] - Typography: [แบบอักษร - ต่างจาก A] - Layout Character: [โครงสร้าง layout - ต่างจาก A] ``` #### 2.3 Present + Wait for Selection **นำเสนอ directions ทั้งหมด แล้วรอ user เลือก** --- ### Phase 3: Master Plan (วางแผนทั้งหมด) **เรียก skill: `spec-driven-development`** สร้าง master plan ที่รวมทุกอย่าง: ``` # Master Plan: [ชื่อเว็บ] ## Selected Design Direction [Direction ที่ user เลือกพร้อม rationale] ## Sitemap / ├── home ├── about ├── services ├── contact └── ... ## Design System - Colors: [hex codes] - Typography: [fonts + weights] - Components: [list] - Layout Patterns: [descriptions] ## Content Structure (Tina CMS) - Collections: [posts, pages, etc.] - Fields: [schema] ## Technical Stack - Framework: Astro 6 - CMS: Tina CMS - Styling: Tailwind CSS v4 - Consent: ConsentOS ## Tracking Scripts - Analytics: [tools] - Marketing: [tools] ## PDPA Compliance - Privacy Policy - Terms of Service - ConsentOS Integration ## Development Phases 1. [Phase 1: Setup + Design Foundation] 2. [Phase 2: Build Pages] 3. [Phase 3: Content + QA] 4. [Phase 4: Deploy] ## Timeline - Phase 1: X days - Phase 2: X days - Phase 3: X days ``` --- ### ⏸️ APPROVAL GATE **หยุดที่นี่ - รอ APPROVE ก่อนทำงาน** แสดง: 1. Design direction ที่เลือก (screenshot/mockup) 2. Sitemap ที่จะสร้าง 3. Tech stack summary 4. Timeline estimate **รอ user พิมพ์ "approve" หรือ "เริ่มได้" ก่อนไปต่อ** --- ### Phase 4: Execution (เริ่มทำหลัง APPROVE) **หลังได้รับ approve แล้ว ทำตามแผนที่ approve โดยไม่ต้องถามต่อ** #### Phase 4.1: Setup + Design Foundation ```bash bash skills/website-creator/scripts/new-project.sh my-website ``` จากนั้น implement design system ที่ approve: - Colors ใน Tailwind theme - Typography - Base components - Layout patterns #### Phase 4.2: Build Pages Implement ทุก pages ตาม sitemap ที่ approve แล้ว #### Phase 4.3: Content + Integration - Tina CMS setup + content schema - Legal pages (Privacy Policy, ToS) - ConsentOS integration - Tracking scripts #### Phase 4.4: QA + Deploy ตาม Step 9-10 ด้านล่าง --- ### Step 9: Preview + QA ```bash npm run dev ``` **ก่อน QA — เรียก skills ตามลำดับ:** 1. **`code-review-and-quality`** — Full multi-axis code review ก่อน delivery 2. **`performance-optimization`** — Performance audit + fixes 3. **`browser-testing-with-devtools`** — ทดสอบใน real browser **จากนั้นเรียก `dogfood` สำหรับ exploratory QA:** ```bash /skill dogfood "ทดสอบ user journey: 1. ดู home page → คลิก services 2. ดู about us 3. กรอก contact form 4. ทดสอบ consent popup (ConsentOS) 5. ตรวจ PDPA compliance (privacy policy, terms) 6. ตรวจ mobile responsive 7. ตรวจ SEO meta tags ทุกหน้า" ``` ให้ user ตรวจสอบ → รอ feedback → แก้ไข → รอ approve --- ### Step 10: Deploy **เรียก skill: `easypanel-deploy` เมื่อ user ขอ** ```bash /skill easypanel-deploy "deploy ไปยัง easypanel server server: openclaw-vps project: my-website domain: example.com git repo: https://github.com/user/my-website" ``` --- ### Step 4: Setup Astro + Tina CMS Project **ใช้ script ที่มีอยู่แล้ว:** ```bash # สร้าง project ใหม่จาก template bash skills/website-creator/scripts/new-project.sh my-website # หรือระบุ path bash skills/website-creator/scripts/new-project.sh my-website /path/to/projects/ ``` **Script ทำอะไร:** 1. Copy template `templates/astro-tina-starter/` 2. เพิ่ม PDPA consent system 3. Copy legal templates (privacy policy, terms) 4. ติดตั้ง dependencies 5. สร้าง .env file 6. Initialize git **เปิด browser:** - Frontend: http://localhost:4321 หรือ http://0.0.0.0:4321 - Tina Admin: http://localhost:4321/admin หรือ http://0.0.0.0:4321/admin (dev mode) --- ### Step 5: พัฒนา Components + Pages **เรียก skills: `spec-driven-development` + `api-and-interface-design` + `ckm:design` + `ckm:ui-styling` + `frontend-ui-engineering`** สร้างตาม sitemap ที่วางแผนไว้: - FrontendLayout, Navigation, Footer - Pages (Home, About, Services, Contact) - Blog listing + detail pages - Forms (Contact form ส่ง email จริง) **สำคัญ — แยก Design Layer กับ Content Layer:** Design skill (ui-ux-pro-max) ออกแบบ **หน้าตา + layout + animation** — ไม่ใช่ content structure Tina CMS เก็บ **เนื้อหา (ข้อความ, format, links, images)** — ไม่ใช่ layout ทั้งสองอยู่คนละ layer กัน → ต้องแยกทำ แล้วมารวมกันตอน integrate --- ### Step 5b: สร้างภาพประกอบด้วย `picture-it` **เรียก skill: `picture-it`** สำหรับทุก page/section ที่ต้องการ hero image, illustration หรือภาพประกอบ: **วิธีใช้:** ```bash # Load credentials ก่อน set -a && source ~/.config/opencode/.env && set +a export PATH="/home/kunthawat/snap/bun-js/87/.bun/bin:$PATH" # ตรวจสอบ Thai font patch bun ~/.hermes/skills/website-creator/creative/picture-it/scripts/thai-font-patch.ts --force ``` **Workflow สร้างภาพประกอบเว็บ:** | Use Case | Pipeline | ค่าใช้จ่าย | |----------|----------|-----------| | Hero background | `generate flux-schnell` + `text` (Thai) + `grade cinematic` + `vignette` | ~$0.003 | | Service illustration | `generate flux-schnell` + `remove-bg` (ถ้ามี product) + `compose` | ~$0.01 | | Blog hero | `generate flux-schnell` + `edit seedream` (place logo) + `grade` | ~$0.043 | | Social/OG image | `generate flux-schnell` + `text` + `grade` | ~$0.003 | | Team/About photo | `generate flux-schnell` → realistic headshot style | ~$0.003 | **ขนาดภาพแนะนำ:** | Purpose | Size | |---------|------| | Hero banner | 1200×630 หรือ 1920×1080 | | Blog hero | 1200×630 | | OG Image (social share) | 1200×630 | | Service card | 800×600 | | Team member | 400×400 (circle crop) | | Logo (ในภาพ) | 200×200 หรือเล็กกว่า | **Workflow ตัวอย่าง — Hero Section:** ```bash # 1. Generate background picture-it generate \ --prompt "modern tech workspace, clean minimal, yellow #fed400 accent lighting" \ --size 1200x630 \ --model flux-schnell \ -o hero-bg.png # 2. เพิ่ม Thai text picture-it text \ -i hero-bg.png \ --title "บริการรับทำเว็บไซต์ SEO" \ --font "Kanit" \ --font-size 48 \ -o hero-texted.png # 3. Color grade picture-it grade -i hero-texted.png --name cinematic -o hero-final.png ``` **การบันทึกภาพไว้ใน project:** ``` src/ ├── components/ │ └── Hero.astro # Hero component └── assets/ ├── heroes/ # Hero images ├── services/ # Service illustrations ├── blog/ # Blog heroes └── og/ # Open Graph images ``` --- ### Step 5c: Design + Tina Content Integration **Design layer กับ Content layer แยกกัน — ค่อยรวมตอน build** #### สิ่งที่ต้องเข้าใจ ``` ┌─────────────────────────────────────────────────────────┐ │ ui-ux-pro-max / ckm:design — Design Layer │ │ • Component structure (Hero, Card, Navbar) │ │ • Color tokens, typography, spacing │ │ • Animation specs (150-300ms, ease-out) │ │ • Layout grid, responsive breakpoints │ │ • Interaction states (hover, press, disabled) │ │ Output: Astro + Tailwind code (component skeleton) │ └─────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────┐ │ Tina CMS — Content Layer │ │ • ข้อความ + format (bold, italic, link) │ │ • Headings (H1-H6) │ │ • Lists, blockquotes, code blocks │ │ • Images, links │ │ Output: MDX files (เนื้อหา) │ └─────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────┐ │ Integration — ครอบ Tina content ด้วย Design │ │ • Design component ครอบ MDX output │ │ • Animation class ที่ wrapper element │ │ • Design tokens apply ผ่าน Tailwind prose │ └─────────────────────────────────────────────────────────┘ ``` #### ขั้นตอนที่ถูกต้อง ``` [1] Design Phase ui-ux-pro-max → Component structure, tokens, animations Output: Component skeleton (ไม่มี content) ↓ [2] Tina Phase สร้าง Content Collections + MDX files Output: Content structure ใน Tina (src/content/) ↓ [3] Content Phase พิมพ์ content ใน Tina Admin (/admin) Output: MDX files ↓ [4] Integration Phase ครอบ Tina content ด้วย Design components ``` #### ตัวอย่าง: Page Structure (Design Output) Design skill อาจให้ component แบบนี้: ```astro --- // ❌ สิ่งที่ design skill อาจให้มา — hardcode content ---
Amazing content here...
{post.data.description}
)}