cms: Publizieren nimmt Beitrag automatisch aus Entwurf (draft:false)
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 <noreply@anthropic.com>
This commit is contained in:
+14
-12
@@ -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 }) {
|
||||
<button className="toggle" onClick={() => setShowPreview((v) => !v)} title="Vorschau ein/aus">
|
||||
{showPreview ? 'Vorschau ⤫' : 'Vorschau ⤢'}
|
||||
</button>
|
||||
<button onClick={save} disabled={busy}>Speichern</button>
|
||||
<button onClick={() => save().then((p) => p && onMsg({ type: 'ok', text: 'Gespeichert.' }))} disabled={busy}>Speichern</button>
|
||||
<button onClick={preview} disabled={busy}>Vorschau</button>
|
||||
<button className="primary" onClick={publish} disabled={busy}>Publizieren</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user