fix(api): prevent 500 error in /api/config when siteConfig.hero is omitted
This commit is contained in:
@@ -17,11 +17,13 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
const newSite = {
|
const newSite = {
|
||||||
...currentSite,
|
...currentSite,
|
||||||
...body.siteConfig,
|
...body.siteConfig,
|
||||||
hero: { ...currentSite.hero, ...body.siteConfig.hero }
|
hero: { ...(currentSite.hero || {}), ...(body.siteConfig.hero || {}) },
|
||||||
|
site_info: { ...((currentSite as any).site_info || {}), ...(body.siteConfig.site_info || {}) }
|
||||||
};
|
};
|
||||||
fs.writeFileSync(path.join(dataDir, 'site.config.json'), JSON.stringify(newSite, null, 2), 'utf8');
|
fs.writeFileSync(path.join(dataDir, 'site.config.json'), JSON.stringify(newSite, null, 2), 'utf8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (body.themeConfig) {
|
if (body.themeConfig) {
|
||||||
const newTheme = { ...currentTheme, ...body.themeConfig };
|
const newTheme = { ...currentTheme, ...body.themeConfig };
|
||||||
fs.writeFileSync(path.join(dataDir, 'theme.config.json'), JSON.stringify(newTheme, null, 2), 'utf8');
|
fs.writeFileSync(path.join(dataDir, 'theme.config.json'), JSON.stringify(newTheme, null, 2), 'utf8');
|
||||||
|
|||||||
Reference in New Issue
Block a user