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

+16
View File
@@ -189,6 +189,22 @@ export async function probePublishApi() {
}
}
/** รายชื่อโปรเจคในโฟลเดอร์ข้างเคียง (มีเฉพาะเมื่อเปิดผ่านเซิร์ฟเวอร์หลังบ้านในเครื่องนี้) */
export async function fetchLocalProjects() {
try {
const res = await fetch("api/local-projects", { cache: "no-store" });
if (!res.ok) return { available: false, workspace: null, projects: [] };
const body = await res.json();
return {
available: true,
workspace: body.workspace || null,
projects: Array.isArray(body.projects) ? body.projects : [],
};
} catch {
return { available: false, workspace: null, projects: [] };
}
}
export function downloadJson(data) {
const payload = toPublishPayload(data);
const blob = new Blob([`${JSON.stringify(payload, null, 2)}\n`], {