f97999c3c0
- coalesce.js: generisches Serialisieren+Koaleszieren je Key; buildSite() in hugo.js nutzt es → Publish/Preview/Profil starten nie überlappende Hugo- Prozesse, schnelle Folge-Aufrufe lösen nur einen Trailing-Build aus - dialog-store: syncLibrary() gedrosselt (60s-TTL) statt bei jedem Forum-Read Filesystem-Walk + Upsert; Publish forciert Sync (force:true) - test/: node:test-Suite (19 Tests) für safeRel/normAuthors/urlFor/hasAccess, roleOf + lokale JWT-Verifikation, Rate-Limiter, Coalescing; npm test Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
21 lines
683 B
JavaScript
21 lines
683 B
JavaScript
import { Hono } from 'hono';
|
|
import { urlFor, safeRel } from '../files.js';
|
|
import { buildSite } from '../hugo.js';
|
|
|
|
// Echte Hugo-Vorschau: ganze Site mit --buildDrafts nach preview/ bauen und die
|
|
// URL des Eintrags zurückgeben (so erscheinen auch draft:true-Einträge).
|
|
const preview = new Hono();
|
|
|
|
preview.post('/', async (c) => {
|
|
const { path: rel } = await c.req.json();
|
|
try {
|
|
const safe = safeRel(rel);
|
|
const build = await buildSite({ dest: 'preview', drafts: true });
|
|
return c.json({ ok: true, url: `/_preview${urlFor(safe)}`, hugo: build.stdout });
|
|
} catch (e) {
|
|
return c.json({ error: String(e.message || e) }, 500);
|
|
}
|
|
});
|
|
|
|
export default preview;
|