Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,33 @@ if (!Object.assign) Object.assign = require('object-assign')`
fs.existsSync(options.themeEnhanceAppPath)
)

// 7. handle plugins
const pluginFiles = [
path.resolve(options.themeDir),
path.resolve(sourceDir, '.vuepress')
]

for (const pluginFile of pluginFiles) {
await loadPlugin(pluginFile, options)
}

return options
}

async function loadPlugin (pluginPath, options) {
let plugin

try {
plugin = require(pluginPath)
} catch (e) {
return
}

if (plugin) {
await plugin({ options })
}
}

async function resolveOptions (sourceDir) {
const vuepressDir = path.resolve(sourceDir, '.vuepress')
const configPath = path.resolve(vuepressDir, 'config.js')
Expand Down Expand Up @@ -143,6 +167,7 @@ async function resolveOptions (sourceDir) {

if (useDefaultTheme) {
// use default theme
options.themeDir = path.resolve(__dirname, 'default-theme')
options.themePath = path.resolve(__dirname, 'default-theme/Layout.vue')
options.notFoundPath = path.resolve(__dirname, 'default-theme/NotFound.vue')
} else {
Expand Down