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

This reverts commit db7724b237.
This commit is contained in:
Bkk1234 committed 2026-11-20 14:33:15 +07:00
1 parent db7724b237
commit 64d4a9e703
9 files changed
+5 -417

No files matched your search

-16
View File
@@ -189,22 +189,6 @@ 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`], {
-58
View File
@@ -2,16 +2,6 @@
import { escapeHtml, hostOf, icon, normalizeUrl } from "../ui.js";
import { initReveal, splitWordsHtml } from "../motion.js";
import { fetchLocalProjects } from "../data.js";
const TH_DATE = new Intl.DateTimeFormat("th-TH", { day: "numeric", month: "short", year: "numeric" });
function formatDate(iso) {
try {
return TH_DATE.format(new Date(iso));
} catch {
return "";
}
}
/** สุ่มลำดับด้วย Fisher–Yates แล้วหยิบมา count ใบ (ไม่ซ้ำ) */
function sampleRandom(list, count) {
@@ -96,40 +86,6 @@ export function homeView(ctx) {
initReveal(gridEl);
}
function localRowHtml(item) {
const folder = escapeHtml(item.folder);
const entry = escapeHtml(item.entry || "index.html");
const title = escapeHtml(item.title || item.folder);
const date = formatDate(item.updated_at);
return `
<li class="local-row">
<a class="local-row__link" href="${escapeHtml(item.url || "#")}" target="_blank" rel="noopener noreferrer">
<span class="local-row__icon" aria-hidden="true">${icon("folder")}</span>
<span class="local-row__body">
<span class="local-row__title">${title}</span>
<span class="local-row__meta"><code>${folder}</code> · ${entry}${
date ? ` · แก้ล่าสุด ${date}` : ""
}</span>
</span>
<span class="local-row__go"><span class="local-row__go-text">เปิดหน้าแรก</span>${icon("arrowRight")}</span>
</a>
</li>`;
}
/** โปรเจคในเครื่อง — มีเฉพาะเมื่อเปิดผ่านเซิร์ฟเวอร์หลังบ้าน (ไม่ขึ้นบนเว็บจริง) */
async function loadLocalProjects() {
const box = root?.querySelector("[data-local]");
const list = root?.querySelector("[data-local-list]");
const countEl = root?.querySelector("[data-local-count]");
if (!box || !list) return;
const result = await fetchLocalProjects();
if (!root || !result.projects.length) return;
if (countEl) countEl.textContent = `${result.projects.length} โฟลเดอร์`;
list.innerHTML = result.projects.map(localRowHtml).join("");
box.hidden = false;
initReveal(box);
}
return {
mount(container) {
root = container;
@@ -194,19 +150,6 @@ export function homeView(ctx) {
</div>
<div data-grid aria-labelledby="projects-title"></div>
<section class="local-section" data-local hidden aria-labelledby="local-title">
<div class="section-head" data-reveal="fade">
<div>
<h2 class="section-head__title" id="local-title">โปรเจคในเครื่อง</h2>
<p class="section-head__sub">
เปิดหน้าแรกของแต่ละโฟลเดอร์ในเครื่องนี้โดยตรง — เห็นเฉพาะเครื่องที่รันเซิร์ฟเวอร์ ไม่ขึ้นบนเว็บจริง
</p>
</div>
<p class="section-head__count" data-local-count></p>
</div>
<ul class="local-list" data-local-list></ul>
</section>
</div>`;
gridEl = root.querySelector("[data-grid]");
@@ -233,7 +176,6 @@ export function homeView(ctx) {
});
renderGrid();
loadLocalProjects();
},
destroy() {
root = null;