Skip to content

Commit 0247b61

Browse files
Sun Haoransergeylarionov-upwork
Sun Haoran
authored andcommitted
docs: refine getting started (close vuejs#2111) (vuejs#2281)
* docs: getting started steps * docs: dir structure and basic config * docs: ready for review * docs: tweaks * docs: fix list-item-content-indent * docs: zh translation
1 parent b0978e6 commit 0247b61

File tree

2 files changed

+83
-97
lines changed

2 files changed

+83
-97
lines changed
+42-47
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,64 @@
11
# Getting Started
22

3-
::: warning COMPATIBILITY NOTE
4-
VuePress requires Node.js >= 8.
3+
::: warning Prerequisite
4+
VuePress requires [Node.js](https://nodejs.org/en/) >= 8.6.
55
:::
66

7-
## Global Installation
7+
This section will help you build a basic VuePress documentation site from ground up. If you already have an existing project and would like to keep documentation inside the project, start from Step 3.
88

9-
If you only want to play around with VuePress, you can install it globally:
9+
1. Create and change into a new directory
1010

11-
``` bash
12-
# install globally
13-
yarn global add vuepress # OR npm install -g vuepress
11+
``` bash
12+
mkdir vuepress-starter && cd vuepress-starter
13+
```
1414

15-
# create the project folder
16-
mkdir vuepress-starter && cd vuepress-starter
15+
2. Initialize with your preferred package manager
1716

18-
# create a markdown file
19-
echo '# Hello VuePress' > README.md
17+
``` bash
18+
yarn init # npm init
19+
```
2020

21-
# start writing
22-
vuepress dev
21+
3. Install VuePress locally
2322

24-
# build
25-
vuepress build
26-
```
23+
Globally installed VuePress is no longer recommended.
2724

28-
## Inside an Existing Project
25+
``` bash
26+
yarn add -D vuepress # npm install -D vuepress
27+
```
2928

30-
If you have an existing project and would like to keep documentation inside the project, you should install VuePress as a local dependency. This setup also allows you to use CI or services like [Netlify](https://netlify.com) for automatic deployment on push.
29+
::: warning
30+
We currently recommend using [Yarn](https://classic.yarnpkg.com/lang/en/) instead of npm when installing VuePress into an existing project that has webpack 3.x as a dependency, because npm fails to generate the correct dependency tree in this case.
31+
:::
3132

32-
``` bash
33-
# install as a local dependency
34-
yarn add -D vuepress # OR npm install -D vuepress
33+
4. Create your first document
3534

36-
# create a docs directory
37-
mkdir docs
38-
# create a markdown file
39-
echo '# Hello VuePress' > docs/README.md
40-
```
35+
``` bash
36+
mkdir docs && echo '# Hello VuePress' > docs/README.md
37+
```
4138

42-
::: warning
43-
We currently recommend using [Yarn](https://yarnpkg.com/en/) instead of npm when installing VuePress into an existing project that has webpack 3.x as a dependency, because npm fails to generate the correct dependency tree in this case.
44-
:::
39+
5. Add some [scripts](https://classic.yarnpkg.com/en/docs/package-json#toc-scripts) to `package.json`
40+
41+
This step is optional but highly recommended, the rest of the documentaion will assume those scripts being added.
4542

46-
Then, add some scripts to `package.json`:
43+
``` json
44+
{
45+
"scripts": {
46+
"docs:dev": "vuepress dev docs",
47+
"docs:build": "vuepress build docs"
48+
}
49+
}
50+
```
4751

48-
``` json
49-
{
50-
"scripts": {
51-
"docs:dev": "vuepress dev docs",
52-
"docs:build": "vuepress build docs"
53-
}
54-
}
55-
```
52+
6. Serve the documentation site in the local server
5653

57-
You can now start writing with:
54+
``` bash
55+
yarn docs:dev # npm run docs:dev
56+
```
5857

59-
``` bash
60-
yarn docs:dev # OR npm run docs:dev
61-
```
58+
VuePress will start a hot-reloading development server at [http://localhost:8080](http://localhost:8080).
6259

63-
To generate static assets, run:
60+
By now, you should have a basic but functional VuePress documentation site. Next, learn about VuePress’ recommended [directory structure](directory-structure.html) and the basics of [configuration](basic-config.html) in VuePress.
6461

65-
``` bash
66-
yarn docs:build # OR npm run docs:build
67-
```
62+
Once you’re familiar with those concepts mentioned above, learn about how to enrich your content with [static assests](assets.html), [Markdown extensions](markdown.html) and [vue components](using-vue.html).
6863

69-
By default, the built files will be in `.vuepress/dist`, which can be configured via the `dest` field in `.vuepress/config.js`. The built files can be deployed to any static file server. See [Deployment Guide](deploy.md) for guides on deploying to popular services.
64+
And when your documentation site start to take shape, check out the [multi-language support](i18n.html) and guides for [deploying](deploy.html) your site to popular services.
+41-50
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,64 @@
11
# 快速上手
22

3-
::: warning 注意
4-
请确保你的 Node.js 版本 >= 8
3+
::: warning 前提条件
4+
VuePress 需要 [Node.js](https://nodejs.org/en/) >= 8.6
55
:::
66

7-
## 全局安装
7+
本文会帮助你从头搭建一个简单的 VuePress 文档。如果你想在一个现有项目中使用 VuePress 管理文档,从步骤 3 开始。
88

9-
如果你只是想尝试一下 VuePress,你可以全局安装它:
9+
1. 创建并进入一个新目录
1010

11-
``` bash
12-
# 安装
13-
yarn global add vuepress # 或者:npm install -g vuepress
11+
``` bash
12+
mkdir vuepress-starter && cd vuepress-starter
13+
```
1414

15-
# 创建项目目录
16-
mkdir vuepress-starter && cd vuepress-starter
15+
2. 使用你喜欢的包管理器进行初始化
1716

18-
# 新建一个 markdown 文件
19-
echo '# Hello VuePress!' > README.md
17+
``` bash
18+
yarn init # npm init
19+
```
2020

21-
# 开始写作
22-
vuepress dev .
21+
3. 将 VuePress 安装为本地依赖
2322

24-
# 构建静态文件
25-
vuepress build .
26-
```
23+
我们已经不再推荐全局安装 VuePress
2724

28-
## 现有项目
25+
``` bash
26+
yarn add -D vuepress # npm install -D vuepress
27+
```
2928

30-
如果你想在一个现有项目中使用 VuePress,同时想要在该项目中管理文档,则应该将 VuePress 安装为本地依赖。作为本地依赖安装让你可以使用持续集成工具,或者一些其他服务(比如 Netlify)来帮助你在每次提交代码时自动部署。
29+
::: warning 注意
30+
如果你的现有项目依赖了 webpack 3.x,我们推荐使用 [Yarn](https://classic.yarnpkg.com/zh-Hans/) 而不是 npm 来安装 VuePress。因为在这种情形下,npm 会生成错误的依赖树。
31+
:::
3132

32-
``` bash
33-
# 将 VuePress 作为一个本地依赖安装
34-
yarn add -D vuepress # 或者:npm install -D vuepress
33+
4. 创建你的第一篇文档
3534

36-
# 新建一个 docs 文件夹
37-
mkdir docs
35+
``` bash
36+
mkdir docs && echo '# Hello VuePress' > docs/README.md
37+
```
3838

39-
# 新建一个 markdown 文件
40-
echo '# Hello VuePress!' > docs/README.md
39+
5.`package.json` 中添加一些 [scripts](https://classic.yarnpkg.com/zh-Hans/docs/package-json#toc-scripts)
4140

42-
# 开始写作
43-
npx vuepress dev docs
44-
```
41+
这一步骤是可选的,但我们推荐你完成它。在下文中,我们会默认这些 scripts 已经被添加。
4542

46-
::: warning
47-
如果你的现有项目依赖了 webpack 3.x,推荐使用 [Yarn](https://yarnpkg.com/en/) 而不是 npm 来安装 VuePress。因为在这种情形下,npm 会生成错误的依赖树。
48-
:::
49-
50-
接着,在 `package.json` 里加一些脚本:
43+
``` json
44+
{
45+
"scripts": {
46+
"docs:dev": "vuepress dev docs",
47+
"docs:build": "vuepress build docs"
48+
}
49+
}
50+
```
5151

52-
``` json
53-
{
54-
"scripts": {
55-
"docs:dev": "vuepress dev docs",
56-
"docs:build": "vuepress build docs"
57-
}
58-
}
59-
```
52+
6. 在本地启动服务器
6053

61-
然后就可以开始写作了:
54+
``` bash
55+
yarn docs:dev # npm run docs:dev
56+
```
6257

63-
``` bash
64-
yarn docs:dev # 或者:npm run docs:dev
65-
```
58+
VuePress 会在 [http://localhost:8080](http://localhost:8080) 启动一个热重载的开发服务器。
6659

67-
要生成静态的 HTML 文件,运行:
60+
现在,你应该已经有了一个简单可用的 VuePress 文档。接下来,了解一下推荐的 [目录结构](directory-structure.html) 和 VuePress 中的 [基本配置](basic-config.html)
6861

69-
``` bash
70-
yarn docs:build # 或者:npm run docs:build
71-
```
62+
等你了解完上文介绍的基础概念,再去学习一下如何使用 [静态资源](assets.html)[Markdown 拓展](markdown.html)[在 Markdown 中使用 Vue](using-vue.html) 来丰富你的文档内容。
7263

73-
默认情况下,文件将会被生成在 `.vuepress/dist`,当然,你也可以通过 `.vuepress/config.js` 中的 `dest` 字段来修改,生成的文件可以部署到任意的静态文件服务器上,参考 [部署](deploy.md) 来了解更多
64+
当你的文档逐渐成型的时候,不要忘记 VuePress 的 [多语言支持](i18n.html) 并了解一下如何将你的文档 [部署](deploy.html) 到任意静态文件服务器上

0 commit comments

Comments
 (0)