Skip to content

Commit 8bbc5f3

Browse files
ulivzyyx990803
authored andcommittedApr 18, 2018
feat: Multiple Language Support + Complete Chinese Translation (#48)
1 parent 930d503 commit 8bbc5f3

22 files changed

+1304
-47
lines changed
 

‎docs/.vuepress/config.js

+58-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
const base = process.env.GH ? '/vuepress/' : '/'
22

33
module.exports = {
4-
title: 'VuePress',
5-
description: 'Vue-powered Static Site Generator',
4+
langs: [
5+
{ lang: 'en', label: 'English', path: '/', selectText: 'Languages' },
6+
{ lang: 'zh-CN', label: '简体中文', path: '/zh/', selectText: '选择语言' }
7+
],
8+
title: {
9+
'/': 'VuePress',
10+
'/zh/': 'VuePress'
11+
},
12+
description: {
13+
'/': 'Vue-powered Static Site Generator',
14+
'/zh/': 'Vue 驱动的静态网站生成器'
15+
},
616
dest: 'vuepress',
717
base,
818
head: [
@@ -13,20 +23,36 @@ module.exports = {
1323
repo: 'vuejs/vuepress',
1424
editLinks: true,
1525
docsDir: 'docs',
16-
nav: [
17-
{
18-
text: 'Guide',
19-
link: '/guide/',
20-
},
21-
{
22-
text: 'Config Reference',
23-
link: '/config/'
24-
},
25-
{
26-
text: 'Default Theme Config',
27-
link: '/default-theme-config/'
28-
}
29-
],
26+
nav: {
27+
'/': [
28+
{
29+
text: 'Guide',
30+
link: '/guide/',
31+
},
32+
{
33+
text: 'Config Reference',
34+
link: '/config/'
35+
},
36+
{
37+
text: 'Default Theme Config',
38+
link: '/default-theme-config/'
39+
}
40+
],
41+
'/zh/': [
42+
{
43+
text: '指南',
44+
link: '/zh/guide/',
45+
},
46+
{
47+
text: '配置',
48+
link: '/zh/config/'
49+
},
50+
{
51+
text: '默认主题',
52+
link: '/zh/default-theme-config/'
53+
}
54+
]
55+
},
3056
sidebar: {
3157
'/guide/': [
3258
{
@@ -43,6 +69,22 @@ module.exports = {
4369
'deploy'
4470
]
4571
}
72+
],
73+
'/zh/guide/': [
74+
{
75+
title: '指南',
76+
collapsable: false,
77+
children: [
78+
'',
79+
'getting-started',
80+
'basic-config',
81+
'assets',
82+
'markdown',
83+
'using-vue',
84+
'custom-themes',
85+
'deploy'
86+
]
87+
}
4688
]
4789
}
4890
}

‎docs/guide/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Each markdown file is compiled into HTML with [markdown-it](https://github.com/m
3030

3131
VuePress is still a work in progress. There are a few things that it currently does not support but are planned:
3232

33-
- Multi-Language Support
3433
- Algolia DocSearch Integration
3534
- Blogging support
3635

‎docs/zh/README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
home: true
3+
heroImage: /hero.png
4+
actionText: 快速上手 →
5+
actionLink: /zh/guide/
6+
features:
7+
- title: 简洁至上
8+
details: 以 Markdown 为中心的项目结构,以最少的配置帮助你专注于写作。
9+
- title: Vue驱动
10+
details: 享受 Vue + webpack 的开发体验,可以在 Markdown 中使用 Vue 组件,又可以使用 Vue 来开发自定义主题。
11+
- title: 高性能
12+
details: VuePress 会为每个页面预渲染生成静态的 HTML,同时,每个页面被加载的时候,将作为 SPA 运行。
13+
footer: MIT Licensed | Copyright © 2018-present Evan You
14+
---
15+
16+
### 像数 1, 2, 3 一样容易
17+
18+
``` bash
19+
# 安装
20+
yarn global add vuepress # 或者:npm install -g vuepress
21+
22+
# 新建一个 markdown 文件
23+
echo '# Hello VuePress!' > README.md
24+
25+
# 开始写作
26+
vuepress dev .
27+
28+
# 构建静态文件
29+
vuepress build .
30+
```
31+
32+
::: warning NODE VERSION
33+
请确保你 Node.js 的版本大于 8。
34+
:::

‎docs/zh/config/README.md

+201
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
---
2+
sidebar: auto
3+
---
4+
5+
# 配置
6+
7+
## 基本配置
8+
9+
### base
10+
11+
- 类型: `string`
12+
- 默认值: `/`
13+
14+
部署站点的基础路径,如果你想让你的网站部署到一个子路径下,你将需要设置它。如 Github pages,如果你想将你的网站部署到 `https://foo.github.io/bar/`,那么 `base` 应该被设置成 `"/bar/"`,它的值应当总是以斜杠开始,并以斜杠结束。
15+
16+
`base` 将会自动地作为前缀插入到所有以 `/` 开始的其他选项的链接中,所以你只需要指定一次。
17+
18+
**Also see:**
19+
20+
- [Base URL](../guide/assets.md#base-url)
21+
- [部署指南 > Github Pages](../guide/deploy.md#github-pages)
22+
23+
### title
24+
25+
- 类型: `string`
26+
- 默认值: `undefined`
27+
28+
网站的标题,它将会被用作所有页面标题的前缀,同时,默认主题下,它将显示在导航栏(navbar)上。
29+
30+
### description
31+
32+
- 类型: `string`
33+
- 默认值: `undefined`
34+
35+
网站的描述,它将会以 `<meta>` 标签渲染到当前页面的 HTML 中。
36+
37+
### head
38+
39+
- 类型: `Array`
40+
- 默认值: `[]`
41+
42+
额外的需要被注入到当前页面的 HTML `<head>` 中的标签,每个标签都可以以 `[tagName, { attrName: attrValue }, innerHTML?]` 的格式指定,举个例子,增加一个自定义的 favicon:
43+
44+
``` js
45+
module.exports = {
46+
head: [
47+
['link', { rel: 'icon', href: `/logo.png` }]
48+
]
49+
}
50+
```
51+
52+
### host
53+
54+
- Type: `string`
55+
- Default: `'0.0.0.0'`
56+
57+
指定用于 dev server 的主机名。
58+
59+
### port
60+
61+
- 类型: `number`
62+
- 默认值: `8080`
63+
64+
指定 dev server 的端口。
65+
66+
### dest
67+
68+
- 类型: `string`
69+
- 默认值: `.vuepress/dist`
70+
71+
指定 `vuepress build` 的输出目录。
72+
73+
### ga
74+
75+
- 类型: `string`
76+
- 默认值: `undefined`
77+
78+
提供一个 Google Analytics ID 来使 GA 生效。
79+
80+
### serviceWorker
81+
82+
- 类型: `boolean`
83+
- 默认值: `false`
84+
85+
如果设置成 `true`,VuePress 将会自动生成并且注册一个 service worker,它缓存了那些已访问过的页面的内容,用于离线访问(仅在生产环境生效)。
86+
87+
如果你正在开发一个自定义主题,`Layout.vue` 组件将会自动触发下述的事件:
88+
89+
- `sw-ready`
90+
- `sw-cached`
91+
- `sw-updated`
92+
- `sw-offline`
93+
- `sw-error`
94+
95+
::: tip PWA NOTES
96+
`serviceWorker` 仅仅用来控制 service worker,为了让你的网站完全地兼容 PWA,你需要在 `.vuepress/public` 提供 Manifest 和 icons,更多细节,请参见 [MDN docs about the Web App Manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest).
97+
当然,仅仅只在你的网站部署后能用 SSL 的时候开启它,因为 service worker 只能在 HTTPs 的链接下注册。
98+
:::
99+
100+
## 主题
101+
102+
### theme
103+
104+
- 类型: `string`
105+
- 默认值: `undefined`
106+
107+
当你使用自定义主题的时候,需要指定它。当值为 `"foo"` 时,VuePress 将会尝试去加载位于 `node_modules/vuepress-theme-awesome/Layout.vue` 的主题组件。
108+
109+
### themeConfig
110+
111+
- 类型: `Object`
112+
- 默认值: `{}`
113+
114+
为当前的主题提供一些配置,这些选项依赖于你正在使用的主题。
115+
116+
**也可以参考:**
117+
118+
- [默认主题](../default-theme-config/)
119+
120+
## Markdown
121+
122+
### markdown.anchor
123+
124+
- 类型: `Object`
125+
- 默认值: `{ permalink: true, permalinkBefore: true, permalinkSymbol: '#' }`
126+
127+
[markdown-it-anchor](https://github.com/valeriangalliat/markdown-it-anchor) 的选项。
128+
129+
### markdown.toc
130+
131+
- 类型: `Object`
132+
- 默认值: `{ includeLevel: [2, 3] }`
133+
134+
[markdown-it-table-of-contents](https://github.com/Oktavilla/markdown-it-table-of-contents) 的选项。
135+
136+
### markdown.config
137+
138+
- 类型: `Function`
139+
- 默认值: `undefined`
140+
141+
一个用来对当前的 [markdown-it](https://github.com/markdown-it/markdown-it) 实例应用额外的插件的函数,举例如下:
142+
143+
``` js
144+
module.exports = {
145+
markdown: {
146+
config: md => {
147+
md.use(require('markdown-it-xxx'))
148+
}
149+
}
150+
}
151+
```
152+
153+
## 构建流程
154+
155+
### postcss
156+
157+
- 类型: `Object`
158+
- 默认值: `{ plugins: [require('autoprefixer')] }`
159+
160+
[postcss-loader](https://github.com/postcss/postcss-loader) 的选项,请注意,指定这个值,将会覆盖内置的 autoprefixer,所以你需要自己将它加进去。
161+
162+
### configureWebpack
163+
164+
- 类型: `Object | Function`
165+
- 默认值: `undefined`
166+
167+
用于修改内部的 Webpack 配置。如果给定一个对象,那么它将会被 [webpack-merge](https://github.com/survivejs/webpack-merge) 合并到最终的配置中,如果给定一个函数,它将会接受 `config` 作为第一个参数,以及 `isServer` 作为第二个参数,你可以直接更改 `config`,也可以返回一个待合并的对象。
168+
169+
``` js
170+
module.exports = {
171+
configureWebpack: (config, isServer) => {
172+
if (!isServer) {
173+
// 修改客户端的 webpack 配置
174+
}
175+
}
176+
}
177+
```
178+
179+
### chainWebpack
180+
181+
- 类型: `Function`
182+
- 默认值: `undefined`
183+
184+
通过 [webpack-chain](https://github.com/mozilla-neutrino/webpack-chain) 来修改内部的 Webpack 配置。
185+
186+
``` js
187+
module.exports = {
188+
chainWebpack: (config, isServer) => {
189+
// config 是 ChainableConfig 的一个实例
190+
}
191+
}
192+
```
193+
194+
## 浏览器兼容性
195+
196+
### evergreen
197+
198+
- 类型: `boolean`
199+
- 默认值: `false`
200+
201+
如果你的对象只有那些 “常青树” 浏览器,你可以将其设置成 `true`,这将会禁止 ESNext 到 ES5 的转译以及对 IE 的 polyfills,同时会带来更快的构建速度和更小的文件体积。

0 commit comments

Comments
 (0)