Skip to content

Commit 0781582

Browse files
committed
docs: replace img
1 parent 8b81448 commit 0781582

File tree

9 files changed

+19
-28
lines changed

9 files changed

+19
-28
lines changed

.DS_Store

0 Bytes
Binary file not shown.
Loading

docs/foreword/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
其实,不是这样的,事实是:从这以后,你要明白,你又要继续学习了,尤大,你尽管更新,我们还学得动。
88

9-
![vue-cli3](https://user-images.githubusercontent.com/20694238/48542845-2893a480-e8fb-11e8-8456-1b7722cfccd1.png)
9+
<img :src="$withBase('/assets/foreword-img01.png')">
1010

1111
### 版本
1212

@@ -15,7 +15,7 @@
1515

1616
[vue-cli npm versions](https://www.npmjs.com/package/@vue/cli)
1717

18-
![foreword-vue-cli-versions](https://user-images.githubusercontent.com/20694238/48545317-98585e00-e900-11e8-867c-c048f23a458b.gif)
18+
<img :src="$withBase('/assets/foreword-img02.gif')">
1919

2020

2121

@@ -25,5 +25,5 @@
2525

2626
仓库默认分支为 `dev`, 这个分支下放着`vue-cli3.0` 以及与之配套的一些插件代码,`master` 分支为 `vue-cli 2.X.X` 的代码。其中 `vue-cli` 的源码在 `/packages/@vue/cli` 中,看这目录的格式,应该是尤大将工具以及`vue-cli` 的一些插件都归在了 `npm` `@vue` 的组织下面,[nmp @vue](https://www.npmjs.com/org/vue)
2727

28-
<img width="1164" alt="foreword-img02" src="https://user-images.githubusercontent.com/20694238/48545006-e3be3c80-e8ff-11e8-93d2-6b5367dbdc3c.png">
28+
<img :src="$withBase('/assets/foreword-img03.png')">
2929

docs/init/generate.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
sidebarDepth: 0
3+
---
4+
15
# generate 函数分析
26

37
首先直接看代码:
@@ -50,7 +54,7 @@ module.exports = function generate (name, src, dest, done) {
5054
```
5155
我们将这段代码分为以下部分来讲:
5256

53-
### getOptions
57+
## getOptions
5458
根据这语以化的函数名就知道这是获取配置的,然后详细看下 `getOptions` 函数的代码:
5559

5660
``` javascript
@@ -75,15 +79,15 @@ module.exports = function options (name, dir) {
7579
<img :src="$withBase('/assets/init-img02.png')">
7680

7781

78-
### Handlebars.registerHelper
82+
## Handlebars.registerHelper
7983

8084
`Handlebars.registerHelper` 用于注册一些 `helper`(或者说成是一些逻辑方法),在模版中来处理一些数据,比如像源码中注册的 `if_eq` `helper`,他的作用就是判断两个字符串是否相等。然后在 `webpack` 的模板中就有以下的用法:
8185

8286
<img :src="$withBase('/assets/init-img03.png')">
8387

8488
就是根据你在构建项目时选择的 `test runner (Jest,Karma and Mocha,none configure it yourself)` 来生成对应的 `npm script`。你也可以在 `meta.js` 中添加自定义的 `helper``vue-cli` 会帮你注册到 `Handlebars` 中。
8589

86-
### opts.metalsmith
90+
## opts.metalsmith
8791
先看一段源码:
8892

8993
``` javascript
@@ -150,7 +154,7 @@ VUE_TEMPL_TEST=full vue init webpack demo
150154

151155
<img :src="$withBase('/assets/init-img04.png')">
152156

153-
### metalsmith.use
157+
## metalsmith.use
154158
`metalsmith.use``metalsmith` 使用插件的写法,前面说过 `metalsmith` 最大的特点就是所有的逻辑都是由插件处理,在 `generate` 函数中一共有使用了三个 `metalsmith` 插件,分别为:`askQuestions` `filterFiles` `renderTemplateFiles`
155159

156160
* askQuestions
@@ -300,7 +304,7 @@ function renderTemplateFiles (skipInterpolation) {
300304
`renderTemplateFiles` 的主要功能就是利用 `consolidate.handlebars.render``~/.vue-templates`下面的 `handlebars` 模板文件渲染成正式的文件。
301305

302306

303-
### metalsmith.build
307+
## metalsmith.build
304308

305309
`metalsmith.build` 就是使用刚才分析的 `askQuestions``filterFiles``renderTemplateFiles` 三个插件将项目的初始化文件生成出来并输出到目标目录,完成后输出相关的信息。
306310

docs/start/env.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
### 从一张图开始源码的分析
1717

18-
![env-img01](https://user-images.githubusercontent.com/20694238/48563233-d4a2b300-e92e-11e8-830e-cf964a8e25cb.png)
18+
<img :src="$withBase('/assets/install-env-img01.png')">
1919

2020
##### 安装 `vue-cli`
2121

docs/start/npm.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ var result = template(data);
8282
```
8383
这是官方的一个 `demo`, 就是通过 `Handlebars``compile` 方法将模板编译成 `html` 。在 `vue-cli``init` 命令中,利用 `Handlebars.registerHelper` 方法注册了一些 `helper`,这样就可以在模板中方便的使用这些 `helper`[详细文档](https://handlebarsjs.com/)
8484

85-
# metalsmith
85+
## metalsmith
86+
8687
`metalsmith` 一个静态网站生成器,可以用在批量处理模板的场景,和 `hexo` 类似。它最大的特点就是所有的逻辑都是由插件处理,你只需要将这些插件用 `metalsmith` 连接起来使用即可,比如官方的一个 `demo`
8788

8889
``` javascript
@@ -127,7 +128,7 @@ function plugin(opts){
127128
```
128129
关于 `metalsmith` 的更多介绍以及语法可查看[详细文档](https://metalsmith.io/)
129130

130-
# chalk
131+
## chalk
131132

132133
`chalk` 是用于修改控制台字符串的样式,包括字体样式(加粗),颜色以及背景颜色等。
133134

@@ -142,7 +143,7 @@ console.log(chalk.blue('Hello world!'));
142143
更多的用法以及 `API` 可查看[详细文档](https://github.com/chalk/chalk)
143144

144145

145-
# download-git-repo
146+
## download-git-repo
146147
`download-git-repo` 是用于 从 `GitHub`, `GitLab`, `Bitbucket` 下载一个 `git` 仓库,`API` 如下:
147148
``` javascript
148149
download(repository, destination, options, callback)
@@ -155,7 +156,7 @@ download(repository, destination, options, callback)
155156

156157
更多例子可查看 [详细文档](https://github.com/flipxfx/download-git-repo)
157158

158-
# consolidate
159+
## consolidate
159160
`consolidate` 是一个模版引擎整合库,它的作用是把一些著名的模板引擎适配成 `Express` 兼容的接口。在 `vue-cli``init` 命令中利用 `consolidate.handlebars.render` 是实现模版的渲染。在 `/example/metalsmith` 目录里有个 `demo`,就是通过 `metalsmith` 以及`consolidate.handlebars.render` 方法将一个 `package.json``handlebars` 的模板引擎来渲染,在项目里运行
160161

161162
``` bash
@@ -166,5 +167,5 @@ npm run metalsmith
166167
希望可以通过这个小 `demo` 可以比较好地理解 `metalsmith``handlebars``consolidate` 以及`inquirer`,关于 `consolidate` 的更多语法请查看[详细文档](https://github.com/tj/consolidate.js)
167168

168169

169-
# 总结
170+
## 总结
170171
这部分主要介绍了在利用 `node` 搭建脚手架工具时一些常见的 `npm` 包,对这些 `npm` 包进行一定的了解后,在后面看源码的时候会比较容易些,下面开始进行源码分析。

test.js

-14
This file was deleted.

0 commit comments

Comments
 (0)