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",
|
"siteName": "N&D IT Solutions",
|
||||||
"metaDescription": "High-Performance Webdesign & Digital Solutions - 100% DSGVO-konform.",
|
"metaDescription": "High-Performance Webdesign & Digital Solutions - 100% DSGVO-konform.",
|
||||||
"is_demo_mode": false,
|
"is_demo_mode": false,
|
||||||
@@ -132,7 +131,23 @@
|
|||||||
"slug": "/",
|
"slug": "/",
|
||||||
"title": "Startseite (Hauptseite)",
|
"title": "Startseite (Hauptseite)",
|
||||||
"is_published": true,
|
"is_published": true,
|
||||||
"sections": []
|
"sections": [
|
||||||
|
{
|
||||||
|
"id": "hero",
|
||||||
|
"type": "HeroSection",
|
||||||
|
"settings": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "bento",
|
||||||
|
"type": "BentoGrid",
|
||||||
|
"settings": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "contact",
|
||||||
|
"type": "ContactSection",
|
||||||
|
"settings": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "page_templates",
|
"id": "page_templates",
|
||||||
|
|||||||
@@ -90,12 +90,9 @@ const previewUrl = `${targetPage?.slug || '/'}?preview=draft`;
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="p-4 border-t border-slate-800 bg-slate-950/50 space-y-2">
|
<div class="p-4 border-t border-slate-800 bg-slate-950/50">
|
||||||
<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">
|
<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">
|
||||||
💾 Entwurf speichern
|
💾 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
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
@@ -145,7 +142,7 @@ const previewUrl = `${targetPage?.slug || '/'}?preview=draft`;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Draft Speichern
|
// 2. Speichern
|
||||||
document.getElementById('btn-save-draft')?.addEventListener('click', async () => {
|
document.getElementById('btn-save-draft')?.addEventListener('click', async () => {
|
||||||
const res = await fetch('/api/editor/save-draft', {
|
const res = await fetch('/api/editor/save-draft', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -154,16 +151,7 @@ const previewUrl = `${targetPage?.slug || '/'}?preview=draft`;
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (res.ok && statusBadge) {
|
if (res.ok && statusBadge) {
|
||||||
statusBadge.textContent = 'Entwurf gespeichert';
|
statusBadge.textContent = '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.className = 'text-emerald-400 bg-emerald-950/60 border border-emerald-800/60 px-2 py-0.5 rounded text-[10px]';
|
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', {});
|
sendToIframe('RELOAD_CANVAS', {});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
const updatedConfig = { ...baseConfig, ...draftBody, updated_at: new Date().toISOString() };
|
const updatedConfig = { ...baseConfig, ...draftBody, updated_at: new Date().toISOString() };
|
||||||
|
|
||||||
await fs.mkdir(DATA_DIR, { recursive: true });
|
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');
|
await fs.writeFile(draftPath, JSON.stringify(updatedConfig, null, 2), 'utf-8');
|
||||||
|
|
||||||
return new Response(JSON.stringify({ success: true, message: 'Entwurf erfolgreich gespeichert' }), { status: 200 });
|
return new Response(JSON.stringify({ success: true, message: 'Entwurf erfolgreich gespeichert' }), { status: 200 });
|
||||||
|
|||||||
Reference in New Issue
Block a user