feat(home): link the homepage of every local project in the workspace

- server: GET /api/local-projects scans sibling folders for index.html
  (title from <title>/<h1>, generic titles fall back to the folder name,
  sorted by newest edit) and GET /projects/<folder>/ serves that folder
- both endpoints are loopback-only; node_modules/.git/.hermes blocked and
  path traversal rejected; WORKSPACE_DIR=none disables the feature
- home: new 'โปรเจคในเครื่อง' list (2 columns >=700px) that hides itself when
  the API is absent, so the live static site never shows fake rows
- SW skips /projects/* so other projects' files are never cached; version 2026.11.19.5
- docs: README/AGENTS/DESIGN cover the endpoints, the loopback rule and the layout
This commit is contained in:
Bkk1234 committed 2026-11-20 14:26:54 +07:00
1 parent b27acd40ee
commit db7724b237
9 files changed
+417 -5

No files matched your search

+19
View File
@@ -45,6 +45,25 @@ server/publish.mjs
ถ้าไม่ได้ตั้ง `ADMIN_TOKEN` เซิร์ฟเวอร์จะอนุญาตเฉพาะเครื่องที่รันมันอยู่ — เปิดให้เครื่องอื่นแก้ต้องตั้งรหัสเสมอ
## โปรเจคในเครื่อง (เห็นเฉพาะ localhost)
หน้าแรกมีส่วน “โปรเจคในเครื่อง” ที่สแกนโฟลเดอร์ข้างเคียง (`D:\Git\workspace`) แล้วลิงก์ไป **หน้า index.html ของแต่ละโปรเจค** โดยไม่ต้องหาโฟลเดอร์เอง
```
GET /api/local-projects → รายการ {folder, entry, url, title, updated_at}
GET /projects/<โฟลเดอร์>/ → เสิร์ฟหน้าแรกของโฟลเดอร์นั้น
```
| ตัวแปร | ค่าเริ่มต้น | ความหมาย |
|---|---|---|
| `WORKSPACE_DIR` | โฟลเดอร์แม่ของ repo นี้ (`D:\Git\workspace`) | ที่สแกนหาโปรเจค |
| `WORKSPACE_DIR=none` | — | ปิดฟีเจอร์นี้ |
- รับเฉพาะ request จาก **เครื่องที่รันเซิร์ฟเวอร์ (loopback)** — เปิดให้เครื่องอื่นดูเว็บได้ แต่ดูไฟล์ในเครื่องไม่ได้
- บล็อก `node_modules`, `.git`, `.hermes` และกัน path traversal
- โฟลเดอร์ที่ไม่มี `index.html` (เช่น โปรเจคที่ต้องรัน `npm run dev`) จะไม่ถูกใส่ในรายการ
- บนเว็บจริง (static host) API นี้ไม่มี → ส่วนนี้ซ่อนตัวเองอัตโนมัติ
## เนื้อหาเริ่มต้น (มาจากตารางรายชื่อโปรเจค)
| ชื่อโปรเจค | ซับโดเมน | อีเมล |