feat(waas): add catch-all route, page manager and draft-publish pipeline

This commit is contained in:
Daniel S
2026-08-09 20:59:02 +02:00
parent 074d314897
commit d03750bc53
11 changed files with 558 additions and 2 deletions

View File

@@ -0,0 +1,56 @@
// public/js/editor-bridge.js
// Bridge between the editor UI (parent) and the live preview iframe.
// Listens for messages from the parent and applies updates to the preview.
(function () {
// Store current config state for quick reference
let siteConfig = {};
let themeConfig = {};
// Helper: apply theme preset CSS variables (assumes theme presets expose a JSON of variables)
function applyTheme(presetKey) {
fetch(`/theme/${presetKey}.json`)
.then((r) => r.json())
.then((vars) => {
const root = document.documentElement;
Object.entries(vars).forEach(([k, v]) => {
root.style.setProperty(`--${k}`, v);
});
})
.catch(() => console.warn('Theme preset not found:', presetKey));
}
// Helper: re-render the preview by injecting the updated HTML (simple approach).
function reloadPreview() {
// For SSR Astro we cannot rerender inside the iframe without a full reload.
// Trigger a reload the parent will send the latest config on load.
window.location.reload();
}
// Message dispatcher
window.addEventListener('message', (event) => {
const { type, payload } = event.data || {};
switch (type) {
case 'load':
siteConfig = payload || {};
// initial load could trigger a render hook if needed
break;
case 'add':
// For simplicity we just reload real implementation would manipulate DOM.
reloadPreview();
break;
case 'preset':
themeConfig.activePreset = payload;
applyTheme(payload);
break;
case 'update':
// payload contains partial siteConfig changes
Object.assign(siteConfig, payload);
reloadPreview();
break;
default:
// ignore unknown messages
break;
}
});
})();