Skip to content

Commit 8a7ee6c

Browse files
committed
feat($core): site config as plugin
1 parent e60a86f commit 8a7ee6c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/@vuepress/core/lib/prepare/AppContext.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const path = require('path')
22
const createMarkdown = require('../markdown/index')
33
const loadConfig = require('./loadConfig')
44
const loadTheme = require('./loadTheme')
5-
const { fs, logger, chalk, globby, sort } = require('@vuepress/shared-utils')
5+
const { fs, logger, chalk, globby, sort, datatypes: { isFunction }} = require('@vuepress/shared-utils')
66

77
const Page = require('./Page')
88
const I18n = require('./I18n')
@@ -30,6 +30,10 @@ module.exports = class AppContext {
3030

3131
this.vuepressDir = path.resolve(sourceDir, '.vuepress')
3232
this.siteConfig = loadConfig(this.vuepressDir)
33+
if (isFunction(this.siteConfig)) {
34+
this.siteConfig = this.siteConfig(this)
35+
}
36+
3337
this.base = this.siteConfig.base || '/'
3438
this.themeConfig = this.siteConfig.themeConfig || {}
3539
this.outDir = this.siteConfig.dest
@@ -81,6 +85,7 @@ module.exports = class AppContext {
8185

8286
this.pluginAPI
8387
// internl core plugins
88+
.use(Object.assign({}, siteConfig, { name: '@vuepress/internal-site-config' }))
8489
.use(require('../internal-plugins/siteData'))
8590
.use(require('../internal-plugins/routes'))
8691
.use(require('../internal-plugins/rootMixins'))

0 commit comments

Comments
 (0)