refactor: simplify editor actions into single direct save button
This commit is contained in:
@@ -90,12 +90,9 @@ const previewUrl = `${targetPage?.slug || '/'}?preview=draft`;
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-4 border-t border-slate-800 bg-slate-950/50 space-y-2">
|
||||
<button id="btn-save-draft" class="w-full bg-slate-800 hover:bg-slate-700 text-slate-200 font-semibold py-2.5 rounded-lg text-xs transition-colors border border-slate-700">
|
||||
💾 Entwurf speichern
|
||||
</button>
|
||||
<button id="btn-publish" class="w-full bg-sky-500 hover:bg-sky-400 text-slate-950 font-bold py-2.5 rounded-lg text-xs transition-colors shadow-lg shadow-sky-500/20">
|
||||
🚀 Live Veröffentlichen
|
||||
<div class="p-4 border-t border-slate-800 bg-slate-950/50">
|
||||
<button id="btn-save-draft" class="w-full bg-sky-500 hover:bg-sky-400 text-slate-950 font-bold py-2.5 rounded-lg text-xs transition-colors shadow-lg shadow-sky-500/20 flex items-center justify-center gap-2">
|
||||
💾 Speichern
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
@@ -145,7 +142,7 @@ const previewUrl = `${targetPage?.slug || '/'}?preview=draft`;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Draft Speichern
|
||||
// 2. Speichern
|
||||
document.getElementById('btn-save-draft')?.addEventListener('click', async () => {
|
||||
const res = await fetch('/api/editor/save-draft', {
|
||||
method: 'POST',
|
||||
@@ -154,16 +151,7 @@ const previewUrl = `${targetPage?.slug || '/'}?preview=draft`;
|
||||
});
|
||||
|
||||
if (res.ok && statusBadge) {
|
||||
statusBadge.textContent = 'Entwurf gespeichert';
|
||||
statusBadge.className = 'text-sky-400 bg-sky-950/60 border border-sky-800/60 px-2 py-0.5 rounded text-[10px]';
|
||||
}
|
||||
});
|
||||
|
||||
// 3. Veröffentlichen
|
||||
document.getElementById('btn-publish')?.addEventListener('click', async () => {
|
||||
const res = await fetch('/api/editor/publish', { method: 'POST' });
|
||||
if (res.ok && statusBadge) {
|
||||
statusBadge.textContent = 'Live Veröffentlicht!';
|
||||
statusBadge.textContent = 'Gespeichert';
|
||||
statusBadge.className = 'text-emerald-400 bg-emerald-950/60 border border-emerald-800/60 px-2 py-0.5 rounded text-[10px]';
|
||||
sendToIframe('RELOAD_CANVAS', {});
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
const updatedConfig = { ...baseConfig, ...draftBody, updated_at: new Date().toISOString() };
|
||||
|
||||
await fs.mkdir(DATA_DIR, { recursive: true });
|
||||
await fs.writeFile(livePath, JSON.stringify(updatedConfig, null, 2), 'utf-8');
|
||||
await fs.writeFile(draftPath, JSON.stringify(updatedConfig, null, 2), 'utf-8');
|
||||
|
||||
return new Response(JSON.stringify({ success: true, message: 'Entwurf erfolgreich gespeichert' }), { status: 200 });
|
||||
|
||||
Reference in New Issue
Block a user