feat(waas): add catch-all route, page manager and draft-publish pipeline
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user