- Move all 39 cloned pages + assets into public/ (Astro copies verbatim to dist/) -> dist/ is byte-identical to www.mitsuthailand.com (home 143633 bytes exact) - Add Astro project: astro.config.mjs, package.json, src/layouts/Base.astro, src/pages/example.astro (sample Astro component page, builds to /example/) - Multi-stage Dockerfile: pnpm build -> nginx serve + env-injecting entrypoint - Env-configurable: GA_ID, FORM_EMAIL, GMAP_LAT/LNG/.env.example - Remove Python crawl tooling and old nginx-static site/ layout - Verified: astro build -> 39 pages + example; all routes serve 200 via preview
91 lines
5.2 KiB
Markdown
91 lines
5.2 KiB
Markdown
# มิตซูชัยพร สมุทรสาคร — Astro Website
|
|
|
|
เว็บโคลนของ **www.mitsuthailand.com** (บริษัท มิตซูชัยพร จำกัด ศูนย์มิตซูบิชิ สมุทรสาคร)
|
|
สร้างเป็น **Astro static site** โดย content ต้นฉบับถูก clon ลงมาครบ (หน้า + ภาพ + script)
|
|
และ URL ทั้งหมดเป็น **relative / dynamic** — เปลี่ยนโดเมนได้โดยไม่ต้องแก้ไฟล์
|
|
|
|
---
|
|
|
|
## 📁 โครงสร้าง
|
|
|
|
```
|
|
.
|
|
├── public/ ← หน้า HTML ต้นฉบับ (copy ตรง → dist/)
|
|
│ ├── index.html ← หน้าแรก (เหมือนต้นฉบับเป๊ะ)
|
|
│ ├── catalog/item/… ← หน้ารายการสินค้า (10 รุ่น + request-form)
|
|
│ ├── catalog/keyword/… ← หน้า keyword
|
|
│ ├── catalog/brand/ catalog/category/ catalog/e-catalog/ catalog/search/
|
|
│ ├── about-us/ contactus/ footer/ rfq/
|
|
│ ├── sites/ core/ themes/ ← CSS/JS (mirror โครงสร้างเดิม)
|
|
│ └── assets/external/ ← รูปจาก media.yellowpages.co.th (โหลดมาแล้ว)
|
|
├── src/
|
|
│ ├── layouts/Base.astro ← layout Astro (ใช้ตอน refactor หน้าเป็น component)
|
|
│ └── pages/example.astro ← ตัวอย่างหน้า Astro component (build ได้)
|
|
├── astro.config.mjs ← config Astro
|
|
├── Dockerfile ← multi-stage: pnpm build → nginx serve
|
|
├── nginx.conf ← nginx serve static
|
|
├── entrypoint.sh ← inject env (GA/form/map) ลง HTML ก่อน serve
|
|
├── .env.example ← ตัวแปร env ที่ตั้งได้
|
|
└── gen_astro.py ← (utility) regen หน้าใน public/ จาก static clone
|
|
```
|
|
|
|
## 🚀 Deploy (Docker / EasyPanel)
|
|
|
|
```bash
|
|
docker build -t mitsu-chaiyaporn .
|
|
docker run -d -p 8080:80 mitsu-chaiyaporn
|
|
```
|
|
|
|
EasyPanel: สร้าง Service แบบ Dockerfile → repo นี้ → port **80** → deploy
|
|
|
|
**เปลี่ยนโดเมนได้เลย** — ทุก URL เป็น relative path
|
|
|
|
---
|
|
|
|
## 🧱 ทำไมหน้า content อยู่ใน public/ (ไม่ใช่ src/pages)
|
|
|
|
หน้าที่ clone มาเป็น **HTML ของ Drupal ดิบ** — ถ้าใส่ใน `src/pages/` Astro จะพยายาม
|
|
parse/transform ผ่าน `ultrahtml` และพัง (HTML ที่ไม่สมบูรณ์ของ Drupal)
|
|
|
|
เลยใช้วิธี: **วาง HTML ใน `public/`** → Astro copy ไป `dist/` ตรงๆ → **output เหมือนต้นฉบับ 100%**
|
|
|
|
**อยากแก้หน้าเป็น Astro component (เพื่อ maintain):**
|
|
1. ย้าย HTML หน้าเดิม ออกจาก `public/` (เช่น `public/about-us/`)
|
|
2. สร้าง `src/pages/about-us.astro` ที่ใช้ `Base` layout + components
|
|
3. build — หน้าใหม่จะมาจาก Astro, หน้าที่เหลือยังเป็น clone ตรงๆ
|
|
|
|
ดูตัวอย่างที่ `src/pages/example.astro` + `src/layouts/Base.astro`
|
|
|
|
---
|
|
|
|
## ✉️ ฟอร์ม + Environment (.env)
|
|
|
|
ค่าต่าง ๆ กำหนดผ่าน env (inject ที่ startup โดย `entrypoint.sh` + envsubst):
|
|
|
|
| ตัวแปร | ค่า default | ความหมาย |
|
|
|--------|------------|----------|
|
|
| `GA_ID` | *(ว่าง=ปิด)* | Google Analytics / GTM ID |
|
|
| `FORM_EMAIL` | `mail@mitsuchaiyaporn.com` | อีเมลรับฟอร์ม RFQ/ติดต่อ (FormSubmit) |
|
|
| `GMAP_LAT` / `GMAP_LNG` | `13.557…/100.289…` | พิกัดแผนที่ (แบบฟรี ไม่ต้อง API key) |
|
|
| `GMAP_EMBED` | *(จาก lat/lng)* | URL map เต็ม (override ได้) |
|
|
|
|
EasyPanel: Service → Environment → เพิ่มตัวแปร → Redeploy
|
|
|
|
```bash
|
|
cp .env.example .env
|
|
docker run --env-file .env -p 8080:80 mitsu-chaiyaporn
|
|
```
|
|
|
|
> ⚠️ หลังตั้ง `FORM_EMAIL` ต้องยืนยันอีเมลครั้งแรกที่ formsubmit.co
|
|
|
|
---
|
|
|
|
## 🔄 Update เว็บจากต้นฉบับ
|
|
- `gen_astro.py` (ใช้ static clone ใส่ public/) — แต่หลัก ๆ ให้เอา HTML ล่าสุดจาก
|
|
`www.mitsuthailand.com` วางลง `public/` แล้ว `pnpm build`
|
|
|
|
## 📞 ข้อมูลติดต่อ
|
|
- โทร: 034-836-738 ต่อ 9 / 034-422-230 · Line: @823bhcbq · FB: facebook.com/mitsuchaiyaporn
|
|
- ที่อยู่: 923/249 ถนนเอกชัย ต.มหาชัย อ.เมืองสมุทรสาคร 74000
|
|
- เปิด: ศูนย์บริการ จ-ส 08:00-17:00 / ฝ่ายขาย ทุกวัน 08:00-17:00
|