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

@@ -210,12 +210,20 @@ function readJsonFile<T>(filePath: string, fallback: T): T {
}
}
export function loadWaasConfigs(userAgent: string = '') {
export function loadWaasConfigs(userAgent: string = '', isDraft: boolean = false) {
const dataDir = process.env.DATA_DIR || path.join(process.cwd(), 'app', 'data');
const device = detectDeviceType(userAgent);
const draftSitePath = path.join(dataDir, 'site.config.draft.json');
const deviceSitePath = path.join(dataDir, `site.${device}.config.json`);
const genericSitePath = path.join(dataDir, 'site.config.json');
const sitePath = fs.existsSync(deviceSitePath) ? deviceSitePath : genericSitePath;
let sitePath = genericSitePath;
if (isDraft && fs.existsSync(draftSitePath)) {
sitePath = draftSitePath;
} else if (fs.existsSync(deviceSitePath)) {
sitePath = deviceSitePath;
}
const deviceThemePath = path.join(dataDir, `theme.${device}.config.json`);
const genericThemePath = path.join(dataDir, 'theme.config.json');
@@ -239,3 +247,8 @@ export function loadWaasConfigs(userAgent: string = '') {
return { siteConfig, themeConfig, smtpConfig };
}
export function getSiteConfig(isDraft: boolean = false) {
return loadWaasConfigs('', isDraft).siteConfig;
}