Skip to content

Commit

Permalink
perf: avoid double resolve user config on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 14, 2021
1 parent 55de7ab commit 5733fc6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 5733fc6

Please sign in to comment.