Skip to content

Commit 125550c

Browse files
committed
docs: more updates
1 parent 504c21d commit 125550c

File tree

8 files changed

+186
-99
lines changed

8 files changed

+186
-99
lines changed

docs/config/README.md

-18
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,6 @@ The `serviceWorker` option only handles the service worker. To make your site fu
9898
Also, only enable this if you are able to deploy your site with SSL, since service worker can only be registered under HTTPs URLs.
9999
:::
100100

101-
### algolia
102-
103-
- Type: `Object`
104-
- Default: `undefined`
105-
106-
The `algolia` option allows you to use [algolia docsearch](https://github.com/algolia/docsearch) to replace the simple built-in search. To enable it, you need to provide at least `apiKey` and `indexName`:
107-
108-
```js
109-
module.exports = {
110-
algolia: {
111-
apiKey: '<API_KEY>',
112-
indexName: '<INDEX_NAME>'
113-
}
114-
}
115-
```
116-
117-
For more options, refer to [Algolia DocSearch's documentation](https://github.com/algolia/docsearch#docsearch-options).
118-
119101
### locales
120102

121103
- Type: `{ [path: string]: Object }`

docs/default-theme-config/README.md

+34-4
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,6 @@ Make sure to define the fallback configuration last.
199199
VuePress checks each sidebar config from top to bottom. If the fallback configuration was first, VuePress would incorrectly match `/foo/` or `/bar/four.html` because they both start with `/`.
200200
:::
201201

202-
203-
204202
### Auto Sidebar for Single Pages
205203

206204
If you wish to automatically generate a sidebar that contains only the header links for the current page, you can use `YAML front matter` on that page:
@@ -221,6 +219,38 @@ sidebar: false
221219
---
222220
```
223221

222+
## Search Box
223+
224+
### Built-in Search
225+
226+
You can disable the built-in search box with `themeConfig.search: false`, and customize how many suggestions to be shown with `themeConfig.searchMaxSuggestions`:
227+
228+
``` js
229+
module.exports = {
230+
themeConfig: {
231+
search: false,
232+
searchMaxSuggestions: 10
233+
}
234+
}
235+
```
236+
237+
### Algolia Search
238+
239+
The `themeConfig.algolia` option allows you to use [Algolia DocSearch](https://community.algolia.com/docsearch/) to replace the simple built-in search. To enable it, you need to provide at least `apiKey` and `indexName`:
240+
241+
```js
242+
module.exports = {
243+
themeConfig: {
244+
algolia: {
245+
apiKey: '<API_KEY>',
246+
indexName: '<INDEX_NAME>'
247+
}
248+
}
249+
}
250+
```
251+
252+
For more options, refer to [Algolia DocSearch's documentation](https://github.com/algolia/docsearch#docsearch-options).
253+
224254
## Prev / Next Links
225255

226256
Prev and next links are automatically inferred based on the sidebar order of the active page. You can also explicitly overwrite or disable them using `YAML front matter`:
@@ -245,9 +275,9 @@ module.exports = {
245275
// Customising the header label
246276
// Defaults to "GitHub"/"GitLab"/"Bitbucket" depending on `themeConfig.repo`
247277
repoLabel: 'Contribute!',
248-
278+
249279
// Optional options for generating "Edit this page" link
250-
280+
251281
// if your docs are in a different repo from your main project:
252282
docsRepo: 'vuejs/vuepress',
253283
// if your docs are not at the root of the repo:

docs/guide/deploy.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ The following guides are based on a few shared assumptions:
2424

2525
2. Inside your project, create `deploy.sh` with the following content (with highlighted lines uncommented appropriately) and run it to deploy:
2626

27-
::: tip
28-
You can also run this script in your CI setup to enable automatic deployment on each push.
29-
:::
30-
3127
``` bash{13,20,23}
3228
#!/usr/bin/env sh
3329
@@ -56,17 +52,21 @@ git commit -m 'deploy'
5652
cd -
5753
```
5854

55+
::: tip
56+
You can also run the above script in your CI setup to enable automatic deployment on each push.
57+
:::
58+
5959
## GitLab Pages and GitLab CI
6060

61-
1. Set correct `base` in `docs/.vuepress/config.js`.
61+
1. Set correct `base` in `docs/.vuepress/config.js`.
6262

6363
If you are deploying to `https://<USERNAME or GROUP>.gitlab.io/`, you can omit `base` as it defaults to `"/"`.
6464

6565
If your are deploying to `https://<USERNAME or GROUP>.gitlab.io/<REPO>/`, (i.e. your repository is at `https://gitlab.com/<USERNAME>/REPO>`), set `base` to `"/<REPO>/"`.
66-
66+
6767
2. Set `dest` in `.vuepress/config.js` to `public`.
6868

69-
3. Create a file called `.gitlab-ci.yml` in the root of your project with the content below. This will build and deploy your site whenever you make changes to your content.
69+
3. Create a file called `.gitlab-ci.yml` in the root of your project with the content below. This will build and deploy your site whenever you make changes to your content.
7070

7171
```
7272
image: node:9.11.1
@@ -85,7 +85,7 @@ pages:
8585
only:
8686
- master
8787
```
88-
88+
8989

9090
## Netlify
9191

docs/guide/markdown.md

+4-12
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,7 @@ Inbound links ending in `.md` or `.html` are converted to `<router-link>` for SP
1313
Each sub-directory in your static site should contain a `README.md`. It will automatically be converted to `index.html`.
1414

1515
::: tip
16-
When writing the relative path to a directory's `index.html`, don't forget to close it off with a `/`, otherwise you will get a 404.
17-
18-
```md
19-
<!-- You'll get a 404 -->
20-
[About Page](/about)
21-
22-
<!-- This is correct -->
23-
[About Page](/about/)
24-
```
16+
When writing the relative path to a directory's `index.html`, don't forget to close it off with a `/`, otherwise you will get a 404. For example, use `/config/` instead of `/config`.
2517
:::
2618

2719
If you want to link to another markdown file within a directory, remember to:
@@ -56,10 +48,10 @@ Given the following directory structure:
5648

5749
### External Links
5850

59-
- Outbound links automatically gets `target="_blank"`:
51+
Outbound links automatically gets `target="_blank"`:
6052

61-
- [vuejs.org](https://vuejs.org)
62-
- [VuePress on GitHub](https://github.com/vuejs/vuepress)
53+
- [vuejs.org](https://vuejs.org)
54+
- [VuePress on GitHub](https://github.com/vuejs/vuepress)
6355

6456
## Front Matter
6557

docs/zh/config/README.md

-18
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,6 @@ module.exports = {
9797
当然,仅仅只在你的网站部署后能用 SSL 的时候开启它,因为 service worker 只能在 HTTPs 的链接下注册。
9898
:::
9999

100-
### algolia
101-
102-
- 类型: `Object`
103-
- 默认值: `undefined`
104-
105-
使用 `algolia` 选项可以让你用 [algolia docsearch](https://github.com/algolia/docsearch) 取代默认的基于 headers 的搜索 。为了使其生效,你必须提供至少 `apiKey``indexName` 这两个选项:
106-
107-
```js
108-
module.exports = {
109-
algolia: {
110-
apiKey: '<API_KEY>',
111-
indexName: '<INDEX_NAME>'
112-
}
113-
}
114-
```
115-
116-
其他可用的选项请参考 [docsearch options](https://github.com/algolia/docsearch#docsearch-options)
117-
118100
### locales
119101

120102
- 类型: `{ [path: string]: Object }`

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

+55-11
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,13 @@ module.exports = {
149149
```
150150
.
151151
├─ README.md
152-
├─ foo
152+
├─ contact.md
153+
├─ about.md
154+
├─ foo/
153155
│  ├─ README.md
154156
│ ├─ one.md
155157
│ └─ two.md
156-
└─ bar
158+
└─ bar/
157159
├─ README.md
158160
├─ three.md
159161
└─ four.md
@@ -166,23 +168,33 @@ module.exports = {
166168
module.exports = {
167169
themeConfig: {
168170
sidebar: {
169-
// sidebar for pages under /foo/
170171
'/foo/': [
171-
'',
172-
'one',
173-
'two'
172+
'', /* /foo/ */
173+
'one', /* /foo/one.html */
174+
'two' /* /foo/two.html */
174175
],
175-
// sidebar for pages under /bar/
176+
176177
'/bar/': [
177-
'',
178-
'three',
179-
'four'
178+
'', /* /bar/ */
179+
'three', /* /bar/three.html */
180+
'four' /* /bar/four.html */
181+
],
182+
183+
// fallback
184+
'/': [
185+
'', /* / */
186+
'contact', /* /contact.html */
187+
'about' /* /about.html */
180188
]
181189
}
182190
}
183191
}
184192
```
185193

194+
::: warning
195+
确保 fallback 侧边栏被最后定义。VuePress 会按顺序遍历侧边栏配置来寻找匹配的配置。
196+
:::
197+
186198
### 自动生成侧栏
187199

188200
如果你希望自动生成一个仅仅包含了当前页面标题(headers)链接的侧边栏,你可以通过 `YAML front matter` 来实现:
@@ -203,6 +215,38 @@ sidebar: false
203215
---
204216
```
205217

218+
## 搜索框
219+
220+
### 内置搜索
221+
222+
你可以通过设置 `themeConfig.search: false` 来禁用默认的搜索框,或是通过 `themeConfig.searchMaxSuggestions` 来调整默认搜索框显示的搜索结果数量:
223+
224+
``` js
225+
module.exports = {
226+
themeConfig: {
227+
search: false,
228+
searchMaxSuggestions: 10
229+
}
230+
}
231+
```
232+
233+
### Algolia 搜索
234+
235+
你可以通过 `themeConfig.algolia` 选项来用 [Algolia DocSearch](https://community.algolia.com/docsearch/) 替换内置的搜索框。要启用 Algolia 搜索,你需要至少提供 `apiKey``indexName`
236+
237+
```js
238+
module.exports = {
239+
themeConfig: {
240+
algolia: {
241+
apiKey: '<API_KEY>',
242+
indexName: '<INDEX_NAME>'
243+
}
244+
}
245+
}
246+
```
247+
248+
更多选项请参考 [Algolia DocSearch 的文档](https://github.com/algolia/docsearch#docsearch-options)
249+
206250
## 上 / 下一篇链接
207251

208252
上一篇和下一篇文章的链接将会自动地根据当前页面的侧边栏的顺序来获取。你也可以使用 `YAML front matter` 来明确地重写或者禁用它:
@@ -227,7 +271,7 @@ module.exports = {
227271
   // 自定义仓库链接文字。默认从 `themeConfig.repo` 中自动推断为
228272
   // "GitHub"/"GitLab"/"Bitbucket" 其中之一,或是 "Source"。
229273
   repoLabel: '查看源码',
230-
274+
231275
   // 以下为可选的编辑链接选项
232276

233277
   // 假如你的文档仓库和项目本身不在一个仓库:

docs/zh/guide/deploy.md

+42-22
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,66 @@
11
# 部署
22

3-
下述的指南,将假定你将文档放置在项目的 `docs` 目录中,并使用默认的构建输出位置。
3+
下述的指南基于以下条件:
4+
5+
- 文档放置在项目的 `docs` 目录中;
6+
- 使用的是默认的构建输出位置;
7+
- VuePress 以本地依赖的形式被安装到你的项目中,并且配置了如下的 npm scripts:
8+
9+
``` json
10+
{
11+
"scripts": {
12+
"docs:build": "vuepress build docs"
13+
}
14+
}
15+
```
416

517
## GitHub Pages
618

7-
1.`.vuepress/config.js``base` 设置成你仓库的名字,举个例子,如果你的仓库是 `https://github.com/foo/bar`, 部署的页面将会通过 `https://foo.github.io/bar` 来访问,此时,你应该将 `base` 设置为 `"/bar/"`
19+
1.`docs/.vuepress/config.js` 中设置正确的 `base`
20+
21+
如果你打算发布到 `https://<USERNAME>.github.io/`,则可以省略这一步,因为 `base` 默认即是 `"/"`
22+
23+
如果你打算发布到 `https://<USERNAME>.github.io/<REPO>/`(也就是说你的仓库在 `https://github.com/<USERNAME>/REPO>`),则将 `base` 设置为 `"/<REPO>/"`
24+
25+
2. 在你的项目中,创建一个如下的 `deploy.sh` 文件(请自行判断去掉高亮行的注释):
26+
27+
``` bash{13,20,23}
28+
#!/usr/bin/env sh
829
9-
2. 在你的项目中运行:
30+
# 确保脚本抛出遇到的错误
31+
set -e
1032
11-
``` bash
12-
# 构建静态文件
13-
vuepress build docs
33+
# 生成静态文件
34+
npm run docs:build
1435
15-
# 切换到你的输出目录
36+
# 进入生成的文件夹
1637
cd docs/.vuepress/dist
1738
39+
# 如果是发布到自定义域名
40+
# echo 'www.example.com' > CNAME
41+
1842
git init
1943
git add -A
2044
git commit -m 'deploy'
2145
22-
# push 到你仓库的 gh-pages 分支
23-
# 将 <USERNAME>/<REPO> 替换成你的信息
24-
git push -f [email protected]:<USERNAME>/<REPO>.git master:gh-pages
46+
# 如果发布到 https://<USERNAME>.github.io
47+
# git push -f [email protected]:<USERNAME>/<USERNAME>.github.io.git master
48+
49+
# 如果发布到 https://<USERNAME>.github.io/<REPO>
50+
# git push -f [email protected]:<USERNAME>/<REPO>.git master:gh-pages
51+
52+
cd -
2553
```
2654

55+
::: tip
2756
你可以在你的持续集成的设置中,设置在每次 push 代码时自动运行上述脚本。
57+
:::
2858

2959
## Netlify
3060

31-
1. 确保你已经有了构建你的文档的的 npm scripts:
32-
33-
``` json
34-
{
35-
"scripts": {
36-
"build-docs": "vuepress build docs"
37-
}
38-
}
39-
```
40-
41-
2. 在 Netlify 中, 创建一个新的 Github 项目,并做一下设置:
61+
1. 在 Netlify 中, 创建一个新的 Github 项目,使用以下设置:
4262

4363
- **Build Command:** `npm run build-docs` 或者 `yarn build-docs`
4464
- **Publish directory:** `docs/.vuepress/dist`
4565

46-
3. 点击 deploy 按钮!
66+
2. 点击 deploy 按钮!

0 commit comments

Comments
 (0)