You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/docs/docs/config/README.md
+7-53
Original file line number
Diff line number
Diff line change
@@ -120,64 +120,18 @@ A function to control what files should have `<link rel="preload">` resource hin
120
120
121
121
## Styling
122
122
123
-
### palette
123
+
### palette.styl
124
124
125
-
- Type: `Object|String`
126
-
- Default: `undefined`
127
-
128
-
Set globally available stylus color variables.
129
-
130
-
If it is string, it needs to be a **absolute path** pointing to a stylus file that defines the color constant:
131
-
132
-
```js
133
-
module.exports= {
134
-
palette:path.resolve(__dirname, 'palette.styl'),
135
-
}
136
-
```
137
-
138
-
::: tip
139
-
When `config.palette` is empty, vuepress will detect whether `.vuepress/palette.styl` exists. If it exists, the file will be used as palette.
140
-
:::
141
-
142
-
If it is an object, it needs to be an object with key as the color name and value as the color value.
143
-
144
-
```js
145
-
module.exports= {
146
-
palette: {
147
-
// Internal default color constants can be
148
-
// modified to quickly modify global styles.
149
-
$accentColor:'#3eaf7c',
150
-
$textColor:'#2c3e50',
151
-
$borderColor:'#eaecef',
152
-
$codeBgColor:'#282c34',
153
-
$arrowBgColor:'#ccc',
154
-
155
-
// Your extra colors
156
-
$shadowColor:'#ddd'
157
-
}
158
-
}
159
-
```
125
+
Create a `.vuepress/style/palette.styl` file and it will be registered as global palette.
160
126
161
-
::: tip
162
-
It is worth noting that `modifying global style` via `palette` depends on the strict use of the default palette for your theme (e.g. the `@vuepress/theme-default` you see now).
163
-
:::
164
-
165
-
### style
166
-
167
-
- Type: `string`
168
-
- Default: `undefined`
127
+
### index.styl
169
128
170
-
Extra style file.
129
+
Create a `.vuepress/style/index.styl` file and it will be applied as global styles.
171
130
172
-
```js
173
-
module.exports= {
174
-
style:path.resolve(__dirname, 'style.styl'),
175
-
}
176
-
```
131
+
**Also see:**
177
132
178
-
::: tip
179
-
When `config.style` is empty, vuepress will detect whether `.vuepress/style.styl` exists. If it exists, the file will be applied automatically.
180
-
:::
133
+
-[Why can't `palette.styl` and `index.styl` merge into one API?](faq/#why-can-t-palette-styl-and-index-styl-merge-into-one-api)
134
+
-[Why can't `palette.styl` and `index.styl` merge into one API?](faq/#why-can-t-palette-styl-and-index-styl-merge-into-one-api)
Senior users have found that both theme developers and regular users have the ability to customize global `palettes`, `styles`, `templates` and `plugins`, so how do they work together?
254
-
255
-
### Loading Priority
256
-
257
-
For `templates/*`, follow the certain loading priority. Taking `templates/ssr.html` as an example:
258
-
259
-
@flowstart
260
-
cond1=>condition: User's ssr.html
261
-
exists?
262
-
cond2=>condition: Theme's ssr.html
263
-
exists?
264
-
stage1=>operation: Using user's ssr.html
265
-
stage2=>operation: Using theme's ssr.html
266
-
stage3=>operation: Using default ssr.html
267
-
268
-
cond1(no, right)->cond2(no)->stage3
269
-
cond1(yes, bottom)->stage1
270
-
cond2(yes, bottom)->stage2
271
-
@flowend
272
-
273
-
::: warning Note
274
-
When customizing `templates/ssr.html`, or `templates/dev.html`, it is best to modify it on the basis of the [default template files](https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/core/lib/app/index.dev.html), otherwise it may cause a build failure.
275
-
:::
276
-
277
-
### Overriding
278
-
279
-
For `palette.styl`, `index.styl` and `plugins`, follow the principles of overriding:
280
-
281
-
#### palette.styl
282
-
283
-
User's `styles/palette.styl` has a higher priority than the theme's `styles/palette.styl`, so the theme can define its own palette and the user can tweak it. e.g.
284
-
285
-
```stylus
286
-
// theme/styles/palette.styl
287
-
$accentColor = #0f0
288
-
```
289
-
290
-
```stylus
291
-
// .vuepress/styles/palette.styl
292
-
$accentColor = #f00
293
-
```
294
-
295
-
So the final value of `$accentColor` is `#f00`.
296
-
297
-
#### index.styl
298
-
299
-
Both the user's `styles/index.styl` and the theme's `styles/index.styl` are generated into the final `CSS` file, but the user's style is generated later and therefore has higher priority. e.g.
300
-
301
-
```stylus
302
-
// theme/styles/index.styl
303
-
.content
304
-
font-size 14px
305
-
```
306
-
307
-
```stylus
308
-
// .vuepress/styles/index.styl
309
-
.content
310
-
font-size 15px
311
-
```
312
-
313
-
The final generated CSS is as follows:
314
-
315
-
```css
316
-
/* theme/styles/index.styl */
317
-
.content {
318
-
font-size: 14px;
319
-
}
320
-
321
-
/* theme/styles/index.styl */
322
-
.content {
323
-
font-size: 15px;
324
-
}
325
-
```
326
-
327
-
#### plugins
328
-
329
-
Since all plugins with the same name can be applied ONLY once by default, users can override the default options for plugins in theme. e.g.
0 commit comments