From 10d803b7b3ab6db025745a54480cd754eaf70336 Mon Sep 17 00:00:00 2001 From: karim Date: Sun, 31 May 2026 12:33:55 +0200 Subject: [PATCH] cms: Publizieren nimmt Beitrag automatisch aus Entwurf (draft:false) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bisher blieb ein Beitrag mit gesetztem Entwurf-Haken beim Publizieren aus dem Live-Build ausgeschlossen → ging nie live. Jetzt setzt Publizieren draft:false, speichert (Haken verschwindet, Status → Veröffentlicht), dann baut es live. Co-Authored-By: Claude Opus 4.8 --- cms/admin/src/App.jsx | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/cms/admin/src/App.jsx b/cms/admin/src/App.jsx index 62e1922..17aed88 100644 --- a/cms/admin/src/App.jsx +++ b/cms/admin/src/App.jsx @@ -170,23 +170,24 @@ function Editor({ initial, onSaved, onMsg }) { }, []); function startDrag(e) { dragging.current = true; document.body.style.cursor = 'col-resize'; document.body.style.userSelect = 'none'; e.preventDefault(); } - function currentPath() { - if (!f.isNew) return f.path; - const slug = (f.slug || '').trim(); + function currentPath(data = f) { + if (!data.isNew) return data.path; + const slug = (data.slug || '').trim(); if (!slug) return ''; - return f.type === 'beitrag' ? `library/${f.section}/${slug}.md` : `${slug}.md`; + return data.type === 'beitrag' ? `library/${data.section}/${slug}.md` : `${slug}.md`; } - async function save() { - const path = currentPath(); + // overrides erlauben z.B. { draft: false } beim Publizieren. + async function save(overrides = {}) { + const data = { ...f, ...overrides }; + const path = currentPath(data); if (!path) { onMsg({ type: 'err', text: 'Bitte einen Slug angeben.' }); return null; } - if (!f.title.trim()) { onMsg({ type: 'err', text: 'Titel fehlt.' }); return null; } + if (!data.title.trim()) { onMsg({ type: 'err', text: 'Titel fehlt.' }); return null; } setBusy(true); try { - await api.save(path, buildFrontmatter(f), f.body); + await api.save(path, buildFrontmatter(data), data.body); const loaded = fromRead(await api.read(path)); onSaved(loaded); setF(loaded); - onMsg({ type: 'ok', text: 'Gespeichert.' }); return path; } catch (e) { onMsg({ type: 'err', text: e.message }); return null; } finally { setBusy(false); } @@ -199,8 +200,9 @@ function Editor({ initial, onSaved, onMsg }) { finally { setBusy(false); } } async function publish() { - const path = await save(); if (!path) return; - if (!confirm('Diesen Eintrag live publizieren?')) return; + if (!confirm('Live publizieren? Der Beitrag wird aus „Entwurf“ genommen.')) return; + const path = await save({ draft: false }); // Publizieren = nicht mehr Entwurf + if (!path) return; setBusy(true); try { const res = await api.publish(path); onMsg({ type: 'ok', text: `Live: ${res.url}` }); } catch (e) { onMsg({ type: 'err', text: e.message }); } @@ -217,7 +219,7 @@ function Editor({ initial, onSaved, onMsg }) { - +