From 831a0d53f0fd689867bb464d99dd4ad9c1179837 Mon Sep 17 00:00:00 2001 From: Daniel S Date: Sun, 9 Aug 2026 23:48:02 +0200 Subject: [PATCH] refactor: simplify editor actions into single direct save button --- app/data/site.config.json | 19 +++++++++++++++++-- src/pages/admin/editor.astro | 22 +++++----------------- src/pages/api/editor/save-draft.ts | 1 + 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/app/data/site.config.json b/app/data/site.config.json index 82b0542..6c9c835 100644 --- a/app/data/site.config.json +++ b/app/data/site.config.json @@ -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", diff --git a/src/pages/admin/editor.astro b/src/pages/admin/editor.astro index f086703..62bcb46 100644 --- a/src/pages/admin/editor.astro +++ b/src/pages/admin/editor.astro @@ -90,12 +90,9 @@ const previewUrl = `${targetPage?.slug || '/'}?preview=draft`; -
- -
@@ -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', {}); } diff --git a/src/pages/api/editor/save-draft.ts b/src/pages/api/editor/save-draft.ts index a1d3097..4dc16ee 100644 --- a/src/pages/api/editor/save-draft.ts +++ b/src/pages/api/editor/save-draft.ts @@ -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 });