Skip to content

Extends the support of absolute paths as theme dirs towards plugins #948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
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
11 changes: 9 additions & 2 deletions packages/@vuepress/core/lib/prepare/loadTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ module.exports = async function loadTheme (ctx) {
const theme = siteConfig.theme || cliOptions.theme
const themeResolver = getThemeResolver()

const absoluteThemePath = path.resolve(theme)
const useAbsolutePath =
fs.existsSync(absoluteThemePath) &&
(fs.readdirSync(absoluteThemePath)).length > 0

const localThemePath = path.resolve(vuepressDir, 'theme')
const useLocalTheme =
!fs.existsSync(theme) &&
fs.existsSync(localThemePath) &&
(fs.readdirSync(localThemePath)).length > 0

Expand All @@ -44,7 +48,10 @@ module.exports = async function loadTheme (ctx) {
let themeName
let themeShortcut

if (useLocalTheme) {
if (useAbsolutePath) {
themePath = absoluteThemePath
logger.tip(`\nApply theme located at ${chalk.gray(themePath)}...`)
} else if (useLocalTheme) {
themePath = localThemePath
logger.tip(`\nApply theme located at ${chalk.gray(themePath)}...`)
} else if (isString(theme)) {
Expand Down