Skip to content

Commit 0a7e38a

Browse files
committed
fix($core): theme/styles/palette.styl doesn't work
BTW, remove Object usage of palette.
1 parent 0a142ef commit 0a7e38a

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

packages/@vuepress/core/lib/build.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = async function build (sourceDir, cliOptions = {}) {
2626
return console.error(logger.error(chalk.red('Unexpected option: outDir cannot be set to the current working directory.\n'), false))
2727
}
2828
await fs.remove(outDir)
29-
logger.debug('Dist directory: ' + chalk.gray(require('path').resolve(process.cwd(), outDir)))
29+
logger.debug('Dist directory: ' + chalk.gray(path.resolve(process.cwd(), outDir)))
3030

3131
let clientConfig = createClientConfig(options, cliOptions).toConfig()
3232
let serverConfig = createServerConfig(options, cliOptions).toConfig()

packages/@vuepress/core/lib/internal-plugins/palette/index.js

+7-15
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,21 @@ module.exports = (options, ctx) => ({
2424
// 2. write palette.styl
2525
const { sourceDir, writeTemp } = ctx
2626

27-
const themePalette = ctx.themePalette
28-
const { palette: userPalette } = ctx.siteConfig
29-
const palettePath = path.resolve(sourceDir, '.vuepress/styles/palette.styl')
27+
const themePalette = path.resolve(ctx.themePath, 'styles/palette.styl')
28+
const userPalette = path.resolve(sourceDir, '.vuepress/styles/palette.styl')
3029

3130
const themePaletteContent = resolvePaletteContent(themePalette)
3231
const userPaletteContent = resolvePaletteContent(userPalette)
33-
const userPaletteContent2 = resolvePaletteContent(palettePath)
3432

3533
// user's palette can override theme's palette.
36-
const paletteContent = themePaletteContent + userPaletteContent + userPaletteContent2
34+
const paletteContent = themePaletteContent + userPaletteContent
3735
await writeTemp('palette.styl', paletteContent)
3836
}
3937
})
4038

4139
/**
4240
* resolve palette content
43-
* @param {string|object} palette
41+
* @param {string} palette
4442
* @returns {string}
4543
*/
4644

@@ -55,14 +53,8 @@ function resolvePaletteContent (palette) {
5553
return ''
5654
}
5755

58-
if (isString(palette)) {
59-
if (fs.existsSync(palette)) {
60-
return `@import(${JSON.stringify(palette)})\n`
61-
}
62-
return ''
63-
} else if (isPlainObject(palette)) {
64-
return Object.keys(palette).map(variableName => {
65-
return `${variableName} = ${palette[variableName]}`
66-
}).join('\n') + '\n'
56+
if (isString(palette) && fs.existsSync(palette)) {
57+
return `@import(${JSON.stringify(palette)})\n`
6758
}
59+
return ''
6860
}

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

-3
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ module.exports = async function loadTheme (ctx) {
6969
}
7070

7171
// handle theme api
72-
const { palette: themePalette } = themeEntryFile
73-
7472
const layoutDirs = [
7573
path.resolve(themePath, 'layouts'),
7674
path.resolve(themePath, '.')
@@ -135,7 +133,6 @@ module.exports = async function loadTheme (ctx) {
135133
themePath,
136134
layoutComponentMap,
137135
themeEntryFile,
138-
themePalette,
139136
themeName,
140137
themeShortcut
141138
}

0 commit comments

Comments
 (0)