提交 6db5e83a 编写于 作者: E Evan You

allow customizing accentColor

上级 41640a2b
...@@ -10,6 +10,8 @@ next: ./getting-started ...@@ -10,6 +10,8 @@ next: ./getting-started
### PWA Support ### PWA Support
### Dropdown Items in Navbar
### Algolia DocSearch Integration ### Algolia DocSearch Integration
## Why Not ...? ## Why Not ...?
......
...@@ -13,7 +13,7 @@ if (module.hot) { ...@@ -13,7 +13,7 @@ if (module.hot) {
if (siteData.base !== prevBase) { if (siteData.base !== prevBase) {
window.alert( window.alert(
`[vuepress] Site base has changed. ` + `[vuepress] Site base has changed. ` +
`Please restart dev server to ensure correct paths.` `Please restart dev server to ensure correct asset paths.`
) )
} }
}) })
......
// colors // colors
@import '../../app/.temp/accent.stylus' // generated from user config
$textColor = #2c3e50 $textColor = #2c3e50
$accentColor = darken(#41b883, 5%)
$borderColor = #eaecef $borderColor = #eaecef
$codeBgColor = #282c34 $codeBgColor = #282c34
......
...@@ -44,6 +44,12 @@ if (!Object.assign) Object.assign = require('object-assign')` ...@@ -44,6 +44,12 @@ if (!Object.assign) Object.assign = require('object-assign')`
} }
writeTemp('polyfill.js', polyfillCode) writeTemp('polyfill.js', polyfillCode)
// 5. handle user accentColor
if (options.useDefaultTheme) {
const accentColor = options.siteData.themeConfig.accentColor || '#3eaf7c'
writeTemp('accent.stylus', `$accentColor = ${accentColor}`)
}
return options return options
} }
...@@ -79,6 +85,12 @@ async function resolveOptions (sourceDir) { ...@@ -79,6 +85,12 @@ async function resolveOptions (sourceDir) {
}) })
} }
// resolve theme
const useDefaultTheme = (
!siteConfig.theme &&
!fs.existsSync(path.resolve(vuepressDir, 'theme'))
)
const options = { const options = {
siteConfig, siteConfig,
sourceDir, sourceDir,
...@@ -89,16 +101,11 @@ async function resolveOptions (sourceDir) { ...@@ -89,16 +101,11 @@ async function resolveOptions (sourceDir) {
pageFiles: sort(await globby(['**/*.md', '!.vuepress'], { cwd: sourceDir })), pageFiles: sort(await globby(['**/*.md', '!.vuepress'], { cwd: sourceDir })),
pagesData: null, pagesData: null,
themePath: null, themePath: null,
notFoundPath: null notFoundPath: null,
useDefaultTheme
} }
// resolve theme if (useDefaultTheme) {
const hasTheme = (
siteConfig.theme ||
fs.existsSync(path.resolve(vuepressDir, 'theme'))
)
if (!hasTheme) {
// use default theme // use default theme
options.themePath = path.resolve(__dirname, 'default-theme/Layout.vue') options.themePath = path.resolve(__dirname, 'default-theme/Layout.vue')
options.notFoundPath = path.resolve(__dirname, 'default-theme/NotFound.vue') options.notFoundPath = path.resolve(__dirname, 'default-theme/NotFound.vue')
......
...@@ -159,7 +159,8 @@ module.exports = function createBaseConfig ({ ...@@ -159,7 +159,8 @@ module.exports = function createBaseConfig ({
}) })
rule.use('postcss-loader').loader('postcss-loader').options(Object.assign({ rule.use('postcss-loader').loader('postcss-loader').options(Object.assign({
plugins: [require('autoprefixer')] plugins: [require('autoprefixer')],
sourceMap: !isProd
}, siteConfig.postcss)) }, siteConfig.postcss))
if (loader) { if (loader) {
...@@ -172,7 +173,9 @@ module.exports = function createBaseConfig ({ ...@@ -172,7 +173,9 @@ module.exports = function createBaseConfig ({
createCSSRule('scss', /\.scss$/, 'sass-loader') createCSSRule('scss', /\.scss$/, 'sass-loader')
createCSSRule('sass', /\.sass$/, 'sass-loader', { indentedSyntax: true }) createCSSRule('sass', /\.sass$/, 'sass-loader', { indentedSyntax: true })
createCSSRule('less', /\.less$/, 'less-loader') createCSSRule('less', /\.less$/, 'less-loader')
createCSSRule('stylus', /\.styl(us)?$/, 'stylus-loader') createCSSRule('stylus', /\.styl(us)?$/, 'stylus-loader', {
preferPathResolver: 'webpack'
})
config config
.plugin('vue-loader') .plugin('vue-loader')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册