refactor: simplify editor actions into single direct save button
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"updated_at": "2026-08-09T20:59:44.639Z",
|
||||
"siteName": "N&D IT Solutions",
|
||||
"metaDescription": "High-Performance Webdesign & Digital Solutions - 100% DSGVO-konform.",
|
||||
"is_demo_mode": false,
|
||||
@@ -132,7 +131,23 @@
|
||||
"slug": "/",
|
||||
"title": "Startseite (Hauptseite)",
|
||||
"is_published": true,
|
||||
"sections": []
|
||||
"sections": [
|
||||
{
|
||||
"id": "hero",
|
||||
"type": "HeroSection",
|
||||
"settings": {}
|
||||
},
|
||||
{
|
||||
"id": "bento",
|
||||
"type": "BentoGrid",
|
||||
"settings": {}
|
||||
},
|
||||
{
|
||||
"id": "contact",
|
||||
"type": "ContactSection",
|
||||
"settings": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "page_templates",
|
||||
|
||||
@@ -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