Skip to content

Commit 6e93738

Browse files
committed
docs: improve docs about config and theme (close vuepress#517)
1 parent 3746e66 commit 6e93738

File tree

6 files changed

+51
-17
lines changed

6 files changed

+51
-17
lines changed

docs/guide/configuration.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ The essential file for configuring a VuePress site is `.vuepress/config.js`, whi
2020

2121
```js
2222
module.exports = {
23+
// site config
2324
lang: 'en-US',
2425
title: 'Hello, VuePress!',
2526
description: 'This is my first VuePress site',
2627

28+
// theme and its config
29+
theme: '@vuepress/theme-default',
2730
themeConfig: {
2831
logo: 'https://vuejs.org/images/logo.png',
2932
},
@@ -39,10 +42,13 @@ import { defineUserConfig } from 'vuepress'
3942
import type { DefaultThemeOptions } from 'vuepress'
4043

4144
export default defineUserConfig<DefaultThemeOptions>({
45+
// site config
4246
lang: 'en-US',
4347
title: 'Hello VuePress',
4448
description: 'Just playing around',
4549

50+
// theme and its config
51+
theme: '@vuepress/theme-default',
4652
themeConfig: {
4753
logo: 'https://vuejs.org/images/logo.png',
4854
},
@@ -53,12 +59,12 @@ export default defineUserConfig<DefaultThemeOptions>({
5359
</CodeGroup>
5460

5561
::: tip
56-
We will refer the config object as **VuePress Config**.
62+
Check out the [Config Reference](../reference/config.md) for a full list of VuePress config.
5763
:::
5864

5965
## Config Scopes
6066

61-
You may have noticed that there is a `themeConfig` option in VuePress Config.
67+
You may have noticed that there is a `themeConfig` option in VuePress config.
6268

6369
Options outside `themeConfig` are **Site Config**, while options inside `themeConfig` are **Theme Config**.
6470

@@ -68,15 +74,11 @@ Site config means that, no matter what theme you are using, these configurations
6874

6975
As we know, every site should have its own `lang`, `title`, `description`, etc. Thus, VuePress has built-in support for those options.
7076

71-
::: tip
72-
Check out the [Config Reference](../reference/config.md) for a full list of site config.
73-
:::
74-
7577
### Theme Config
7678

7779
Theme config will be processed by VuePress theme, so it depends on the theme you are using.
7880

79-
If you don't specify the `theme` option of VuePress Config, the default theme will be used.
81+
If you don't specify the `theme` option of VuePress config, the default theme will be used.
8082

8183
::: tip
8284
Check out the [Default Theme > Config Reference](../reference/default-theme/config.md) for theme config of default theme.

docs/guide/theme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ First, create the local theme directory, typically `.vuepress/theme` :
4141
└─ README.md
4242
```
4343

44-
Then, set the absolute path of the theme directory to use it:
44+
Then, set the [theme](../reference/config.md#theme) option to the absolute path of the [theme entry](../advanced/theme.md#theme-entry) to use it:
4545

4646
```js
4747
module.exports = {
48-
theme: path.resolve(__dirname, './path/to/docs/.vuepress/theme'),
48+
theme: path.resolve(__dirname, './path/to/docs/.vuepress/theme/index.js'),
4949
}
5050
```
5151

docs/reference/config.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ module.exports = {
168168
```
169169

170170
- Also see:
171+
- [themeConfig](#themeconfig)
171172
- [Guide > Theme](../guide/theme.md)
172173

173174
### themeConfig
@@ -178,9 +179,23 @@ module.exports = {
178179

179180
- Details:
180181

181-
Provide config options to the used theme. The options will vary depending on the theme you are using.
182+
Provide config to the used theme. The options will vary depending on the theme you are using.
183+
184+
- Example:
185+
186+
```js
187+
module.exports = {
188+
// use default theme
189+
theme: '@vuepress/theme-default',
190+
// configure default theme
191+
themeConfig: {
192+
logo: '/logo.png',
193+
},
194+
}
195+
```
182196

183197
- Also see:
198+
- [theme](#theme)
184199
- [Default Theme > Config](./default-theme/config.md)
185200

186201
## Bundler Config

docs/zh/guide/configuration.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ VuePress 站点必要的配置文件是 `.vuepress/config.js`,它应该导出
2020

2121
```js
2222
module.exports = {
23+
// 站点配置
2324
lang: 'zh-CN',
2425
title: '你好, VuePress !',
2526
description: '这是我的第一个 VuePress 站点',
2627

28+
// 主题和它的配置
29+
theme: '@vuepress/theme-default',
2730
themeConfig: {
2831
logo: 'https://vuejs.org/images/logo.png',
2932
},
@@ -39,10 +42,13 @@ import { defineUserConfig } from 'vuepress'
3942
import type { DefaultThemeOptions } from 'vuepress'
4043

4144
export default defineUserConfig<DefaultThemeOptions>({
45+
// 站点配置
4246
lang: 'en-US',
4347
title: 'Hello VuePress',
4448
description: 'Just playing around',
4549

50+
// 主题和它的配置
51+
theme: '@vuepress/theme-default',
4652
themeConfig: {
4753
logo: 'https://vuejs.org/images/logo.png',
4854
},
@@ -53,7 +59,7 @@ export default defineUserConfig<DefaultThemeOptions>({
5359
</CodeGroup>
5460

5561
::: tip
56-
我们接下来会把这个配置对象称为 **VuePress 配置**.
62+
前往 [配置参考](../reference/config.md) 查看所有 VuePress 配置
5763
:::
5864

5965
## 配置作用域
@@ -68,10 +74,6 @@ export default defineUserConfig<DefaultThemeOptions>({
6874

6975
我们知道,每一个站点都应该有它的 `lang`, `title``description` 等属性,因此 VuePress 内置支持了这些属性的配置。
7076

71-
::: tip
72-
前往 [配置参考](../reference/config.md) 查看所有站点配置。
73-
:::
74-
7577
### 主题配置
7678

7779
主题配置将会被 VuePress 主题来处理,所以它取决于你使用的主题是什么。

docs/zh/guide/theme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ module.exports = {
4141
└─ README.md
4242
```
4343

44-
然后,设置主题目录的绝对路径来使用它
44+
然后,[theme](../reference/config.md#theme) 配置项设置为 [主题入口](../advanced/theme.md#主题入口) 的绝对路径来使用它
4545

4646
```js
4747
module.exports = {
48-
theme: path.resolve(__dirname, './path/to/docs/.vuepress/theme'),
48+
theme: path.resolve(__dirname, './path/to/docs/.vuepress/theme/index.js'),
4949
}
5050
```
5151

docs/zh/reference/config.md

+15
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ module.exports = {
167167
```
168168

169169
- 参考:
170+
- [themeConfig](#themeconfig)
170171
- [指南 > 主题](../guide/theme.md)
171172

172173
### themeConfig
@@ -179,7 +180,21 @@ module.exports = {
179180

180181
为当前使用的主题提供的配置项。具体的配置项取决于你使用的主题。
181182

183+
- 示例:
184+
185+
```js
186+
module.exports = {
187+
// 使用默认主题
188+
theme: '@vuepress/theme-default',
189+
// 配置默认主题
190+
themeConfig: {
191+
logo: '/logo.png',
192+
},
193+
}
194+
```
195+
182196
- 参考:
197+
- [theme](#theme)
183198
- [默认主题 > 配置](./default-theme/config.md)
184199

185200
## 打包工具配置

0 commit comments

Comments
 (0)