perf: avoid double resolve user config on startup

pull/317/head
Evan You 4 years ago
parent 55de7ab43c
commit 5733fc625e

@ -47,7 +47,7 @@ export async function resolveConfig(
root: string = process.cwd()
): Promise<SiteConfig> {
const userConfig = await resolveUserConfig(root)
const site = await resolveSiteData(root)
const site = await resolveSiteData(root, userConfig)
// resolve theme path
const userThemeDir = resolve(root, 'theme')
@ -90,9 +90,11 @@ export async function resolveUserConfig(root: string) {
return userConfig
}
export async function resolveSiteData(root: string): Promise<SiteData> {
const userConfig = await resolveUserConfig(root)
export async function resolveSiteData(
root: string,
userConfig?: UserConfig
): Promise<SiteData> {
userConfig = userConfig || (await resolveUserConfig(root))
return {
lang: userConfig.lang || 'en-US',
title: userConfig.title || 'VitePress',

Loading…
Cancel
Save