Skip to content

Commit 08e29e9

Browse files
committed
docs($cn): theme translation
1 parent b40a790 commit 08e29e9

9 files changed

+115
-132
lines changed

packages/docs/docs/.vuepress/config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ function getPluginSidebar (gruopA, introductionA) {
110110
collapsable: false,
111111
children: [
112112
['', introductionA],
113-
'writing-a-plugin',
114113
'using-a-plugin',
114+
'writing-a-plugin',
115115
'life-cycle',
116116
'option-api',
117117
'context-api',
@@ -128,8 +128,8 @@ function getThemeSidebar (gruopA, introductionA) {
128128
collapsable: false,
129129
children: [
130130
['', introductionA],
131-
'writing-a-theme',
132131
'using-a-theme',
132+
'writing-a-theme',
133133
'option-api',
134134
'default-theme-config'
135135
]

packages/docs/docs/theme/default-theme-config.md

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
---
2-
sidebar: auto
3-
---
4-
51
# Default Theme Config
62

73
<Bit/>

packages/docs/docs/theme/option-api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
seoTitle: Option API | Theme
33
---
44

5-
# Options
5+
# Option API
66

77
## plugins
88

packages/docs/docs/theme/using-a-theme.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
Using a theme is almost same as using a plugin.
44

5-
## Use plugins from a dependency
5+
## Using a theme from a dependency
66

77
Themes can be published on npm in raw Vue SFC format as `vuepress-theme-xxx`.
88

99
``` js
1010
module.exports = {
11-
plugins: [ 'vuepress-theme-xx' ]
11+
theme: 'vuepress-theme-xx'
1212
}
1313
```
1414

@@ -18,31 +18,31 @@ If you prefix the plugin with `vuepress-theme-`, you can use a shorthand to leav
1818

1919
``` js
2020
module.exports = {
21-
plugins: [ 'xxx' ]
21+
theme: 'xxx'
2222
}
2323
```
2424

2525
Same with:
2626

2727
``` js
2828
module.exports = {
29-
plugins: [ 'vuepress-theme-xxx' ]
29+
theme: 'vuepress-theme-xxx'
3030
}
3131
```
3232

3333
This also works with [Scoped Packages](https://docs.npmjs.com/misc/scope):
3434

3535
``` js
3636
module.exports = {
37-
plugins: [ '@org/vuepress-theme-xxx', '@vuepress/theme-xxx' ]
37+
theme: '@org/vuepress-theme-xxx', // or an official theme: '@vuepress/theme-xxx'
3838
}
3939
```
4040

4141
Shorthand:
4242

4343
``` js
4444
module.exports = {
45-
plugins: [ '@org/xxx', '@vuepress/xxx' ]
45+
theme: '@org/xxx', // or an official theme: '@vuepress/xxx'
4646
}
4747
```
4848

packages/docs/docs/theme/writing-a-theme.md

+17-24
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ To write a theme, create a `.vuepress/theme` directory in your docs root, and th
1111

1212
From there it's the same as developing a normal Vue application. It is entirely up to you how to organize your theme.
1313

14+
## Content Outlet
15+
16+
The compiled content of the current `.md` file being rendered will be available as a special `<Content/>` global component. You will need to render it somewhere in your layout in order to display the content of the page. The simplest theme can be just a single `Layout.vue` component with the following content:
17+
18+
``` html
19+
<template>
20+
<div class="theme-container">
21+
<Content/>
22+
</div>
23+
</template>
24+
```
25+
26+
**Also see:**
27+
28+
- [Markdown Slot](../guide/markdown-slot.md)
29+
1430
## Directory Structure
1531

1632
Just one `Layout.vue` might not be enough, and you might also want to define more layout components in the theme for using on different pages. You may also want to customize the [palette](../config/README.md#palette), and even apply some plugins.
@@ -46,8 +62,7 @@ themePath
4662
- `theme/enhanceApp.js`: Theme level enhancements.
4763

4864
::: warning Note
49-
1. Considering backward compatibility, Vue components located at [themePath](../miscellaneous/glossary.md#theme-side) will also be automatically registered as layout components. But the recommended is placing them under `themePath/layouts` directory, which looks more clearer.
50-
2. When you want to publish your theme as an npm package, make sure the package has `index.js`, and set `"main"` field at `package.json` to `index.js` so that VuePress can resolve and get the correct [themePath](../miscellaneous/glossary.md#theme-side).
65+
When you want to publish your theme as an npm package, make sure the package has `index.js`, and set `"main"` field at `package.json` to `index.js` so that VuePress can resolve and get the correct [themePath](../miscellaneous/glossary.md#theme-side).
5166

5267
```json
5368
{
@@ -97,16 +112,6 @@ module.exports = {
97112
}
98113
```
99114

100-
For themes that need to be released to NPM, please do not forget to add it to `dependencies`:
101-
102-
```json
103-
{
104-
"dependencies": {
105-
"@vuepress/plugin-pwa": "^x.x.x",
106-
}
107-
}
108-
```
109-
110115
## Site and Page Metadata
111116

112117
The `Layout` component will be invoked once for every `.md` file in `docs`, and the metadata for the entire site and that specific page will be exposed respectively as `this.$site` and `this.$page` properties which are injected into every component in the app.
@@ -156,18 +161,6 @@ Finally, don't forget that `this.$route` and `this.$router` are also available a
156161

157162
If a markdown file contains a `<!-- more -->` comment, any content above the comment will be extracted and exposed as `$page.excerpt`. If you are building custom theme for blogging, this data can be used to render a post list with excerpts.
158163

159-
## Content Outlet
160-
161-
The compiled content of the current `.md` file being rendered will be available as a special `<Content/>` global component. You will need to render it somewhere in your layout in order to display the content of the page. The simplest theme can be just a single `Layout.vue` component with the following content:
162-
163-
``` html
164-
<template>
165-
<div class="theme-container">
166-
<Content/>
167-
</div>
168-
</template>
169-
```
170-
171164
## App Level Enhancements
172165

173166
Themes can enhance the Vue app that VuePress uses by exposing an `enhanceApp.js` file at the root of the theme. The file should `export default` a hook function which will receive an object containing some app level values. You can use this hook to install additional Vue plugins, register global components, or add additional router hooks:

packages/docs/docs/zh/theme/default-theme-config.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
---
2-
sidebar: auto
3-
---
4-
5-
# 默认主题
1+
# 默认主题配置
62

73
::: tip 提示
84
本页所列的选项仅对默认主题生效。如果你在使用一个自定义主题,选项可能会有不同。

packages/docs/docs/zh/theme/option-api.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
seoTitle: Option API | Theme
33
---
44

5-
# Options
5+
# Option API
66

77
## plugins
88

9-
- Type: `Array|Object`
10-
- Default: undefined
9+
- 类型: `Array|Object`
10+
- 默认值: undefined
1111

12-
See: [Plugin > Using a plugin](../plugin/using-a-plugin.md).
12+
参考: [插件 > 使用插件](../plugin/using-a-plugin.md).
+15-15
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
# 使用主题
22

3-
Using a theme is almost same as using a plugin.
3+
使用一个主题和使用一个插件几乎一致。
44

5-
## Use plugins from a dependency
5+
## 使用 dependency 中的主题
66

7-
Themes can be published on npm in raw Vue SFC format as `vuepress-theme-xxx`.
7+
一个插件可以在以 `vuepress-theme-xxx` 的形式发布到 npm,你可以这样使用它:
88

99
``` js
1010
module.exports = {
11-
plugins: [ 'vuepress-theme-xx' ]
11+
theme: 'vuepress-theme-xx'
1212
}
1313
```
1414

15-
## Theme Shorthand
15+
## 主题的缩写
1616

17-
If you prefix the plugin with `vuepress-theme-`, you can use a shorthand to leave out that prefix:
17+
如果你的插件名以 `vuepress-theme-` 开头,你可以使用缩写来省略这个前缀:
1818

1919
``` js
2020
module.exports = {
21-
plugins: [ 'xxx' ]
21+
theme: 'xxx'
2222
}
2323
```
2424

25-
Same with:
25+
和下面等价:
2626

2727
``` js
2828
module.exports = {
29-
plugins: [ 'vuepress-theme-xxx' ]
29+
theme: 'vuepress-theme-xxx'
3030
}
3131
```
3232

33-
This also works with [Scoped Packages](https://docs.npmjs.com/misc/scope):
33+
这也适用于 [Scoped Packages](https://docs.npmjs.com/misc/scope):
3434

3535
``` js
3636
module.exports = {
37-
plugins: [ '@org/vuepress-theme-xxx', '@vuepress/theme-xxx' ]
37+
theme: '@org/vuepress-theme-xxx', // 或者一个官方主题: '@vuepress/theme-xxx'
3838
}
3939
```
4040

41-
Shorthand:
41+
缩写:
4242

4343
``` js
4444
module.exports = {
45-
plugins: [ '@org/xxx', '@vuepress/xxx' ]
45+
theme: '@org/xxx', // 或者一个官方主题: '@vuepress/xxx'
4646
}
4747
```
4848

49-
::: warning Note
50-
The plugin whose name starts with `@vuepress/theme-` is an officially maintained theme.
49+
::: warning 注意
50+
`@vuepress/plugin-` 开头的插件是官方维护的插件。
5151
:::

0 commit comments

Comments
 (0)