Skip to content

Commit 2b2e308

Browse files
committed
feat($core): make palette globally enabled and improve doc
1 parent 19e73d7 commit 2b2e308

File tree

17 files changed

+82
-30
lines changed

17 files changed

+82
-30
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const {
2-
fs, logger,
2+
fs, path, logger,
33
datatypes: {
44
isPlainObject,
55
assertTypes,
@@ -11,15 +11,29 @@ module.exports = (options, ctx) => ({
1111
name: '@vuepress/internal-palette',
1212

1313
async ready () {
14-
const { writeTemp } = ctx
14+
// 1. enable config.styl globally.
15+
const configFile = path.resolve(__dirname, '../../app/style/config.styl')
16+
if (!ctx.siteConfig.stylus) {
17+
ctx.siteConfig.stylus = {
18+
import: [configFile]
19+
}
20+
} else if (isPlainObject(ctx.siteConfig.stylus)) {
21+
ctx.siteConfig.stylus.import = (ctx.siteConfig.stylus.import || []).concat([configFile])
22+
}
23+
24+
// 2. write palette.styl
25+
const { sourceDir, writeTemp } = ctx
1526

1627
const themePalette = ctx.themePalette
1728
const { palette: userPalette } = ctx.siteConfig
29+
const palettePath = path.resolve(sourceDir, '.vuepress/palette.styl')
30+
1831
const themePaletteContent = resolvePaletteContent(themePalette)
1932
const userPaletteContent = resolvePaletteContent(userPalette)
33+
const userPaletteContent2 = resolvePaletteContent(palettePath)
2034

2135
// user's palette can override theme's palette.
22-
const paletteContent = themePaletteContent + userPaletteContent
36+
const paletteContent = themePaletteContent + userPaletteContent + userPaletteContent2
2337
await writeTemp('palette.styl', paletteContent)
2438
}
2539
})
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
// generated from user config
22
import('@temp/style.styl')
3-
4-
window.__VUEPRESS_STYLE_STYLE_LOADED__ = true

packages/@vuepress/plugin-search/SearchBox.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ export default {
153153
</script>
154154

155155
<style lang="stylus">
156-
@import '~@app/style/config'
157-
158156
.search-box
159157
display inline-block
160158
position relative

packages/@vuepress/theme-default/components/AlgoliaSearchBox.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ export default {
5959
</script>
6060

6161
<style lang="stylus">
62-
@import '~@app/style/config'
63-
6462
.algolia-search-wrapper
6563
& > span
6664
vertical-align middle

packages/@vuepress/theme-default/components/Badge.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ export default {
2121
</script>
2222

2323
<style lang="stylus" scoped>
24-
@import '~@app/style/config'
25-
2624
.badge
2725
display inline-block
2826
font-size 14px

packages/@vuepress/theme-default/components/DropdownLink.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ export default {
7777
</script>
7878

7979
<style lang="stylus">
80-
@import '~@app/style/config'
81-
8280
.dropdown-wrapper
8381
cursor pointer
8482
.dropdown-title

packages/@vuepress/theme-default/components/Home.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ export default {
7171
</script>
7272

7373
<style lang="stylus">
74-
@import '~@app/style/config'
75-
7674
.home
7775
padding $navbarHeight 2rem 0
7876
max-width 960px

packages/@vuepress/theme-default/components/NavLinks.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ export default {
116116
</script>
117117

118118
<style lang="stylus">
119-
@import '~@app/style/config'
120-
121119
.nav-links
122120
display inline-block
123121
a

packages/@vuepress/theme-default/components/Navbar.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ function css (el, property) {
8686
</script>
8787

8888
<style lang="stylus">
89-
@import '~@app/style/config'
90-
9189
$navbar-vertical-padding = 0.7rem
9290
$navbar-horizontal-padding = 1.5rem
9391

packages/@vuepress/theme-default/components/Page.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ function find (page, items, offset) {
195195
</script>
196196

197197
<style lang="stylus">
198-
@import '~@app/style/config'
199198
@require '../styles/wrapper.styl'
200199
201200
.page

0 commit comments

Comments
 (0)