@@ -5,7 +5,7 @@ const yamlParser = require('js-yaml')
5
5
const tomlParser = require ( 'toml' )
6
6
const createMarkdown = require ( './markdown' )
7
7
const tempPath = path . resolve ( __dirname , 'app/.temp' )
8
- const { inferTitle, extractHeaders, parseFrontmatter, loadPlugin } = require ( './util' )
8
+ const { inferTitle, extractHeaders, parseFrontmatter, loadPlugin, cloneOptions } = require ( './util' )
9
9
10
10
fs . ensureDirSync ( tempPath )
11
11
@@ -77,20 +77,20 @@ if (!Object.assign) Object.assign = require('object-assign')`
77
77
// 7. handle user plugins
78
78
if ( options . siteConfig . plugins && Array . isArray ( options . siteConfig . plugins ) ) {
79
79
const { plugins } = options . siteConfig
80
+
80
81
for ( const plugin of plugins ) {
81
82
let pluginRequired
83
+ let pluginOptions
84
+ const vuepressOptions = cloneOptions ( options )
82
85
if ( typeof plugin === 'string' ) {
83
- pluginRequired = loadPlugin ( plugin , options )
84
- }
85
- if ( typeof plugin === 'object' ) {
86
- pluginRequired = loadPlugin ( plugin . resolve , options )
87
- if ( plugin . options ) {
88
- pluginRequired = pluginRequired ( plugin . options )
89
- }
86
+ pluginRequired = loadPlugin ( plugin , sourceDir )
87
+ } else if ( Array . isArray ( plugin ) ) {
88
+ pluginRequired = loadPlugin ( plugin [ 0 ] , sourceDir )
89
+ pluginOptions = plugin [ 1 ]
90
90
}
91
91
if ( pluginRequired ) {
92
92
try {
93
- await pluginRequired ( options )
93
+ await pluginRequired ( { vuepressOptions , pluginOptions } )
94
94
} catch ( e ) {
95
95
throw e
96
96
}
0 commit comments