Skip to content

Commit

Permalink
docs(cn): update for import code snippets (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed Jun 2, 2018
1 parent 26ecff7 commit 4e7f3da
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/guide/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ export default {

## Import Code Snippets

You can import code snippets from existing files via following syntax:

**Input**

```
Expand All @@ -236,6 +238,11 @@ export default {

<<< @/test/markdown/fragments/snippet.js{2}

::: tip
Since the import of the code snippets will be executed before webpack compilation, so you can't use the path alias in webpack. the default value of `@` is `process.cwd()`.
:::


## Advanced Configuration

VuePress uses [markdown-it](https://github.com/markdown-it/markdown-it) as the markdown renderer. A lot of the extensions above are implemented via custom plugins. You can further customize the `markdown-it` instance using the `markdown` option in `.vuepress/config.js`:
Expand Down
18 changes: 18 additions & 0 deletions docs/zh/guide/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,24 @@ export default {
}
```

## 导入代码段

你可以通过下述的语法导入已经存在的文件中的代码段:

**Input**

```
<<< @/test/markdown/fragments/snippet.js{2}
```

**Output**

<<< @/test/markdown/fragments/snippet.js{2}

::: tip 注意
由于代码段的导入将在 webpack 编译之前执行,因此你无法使用 webpack 中的路径别名,此处的 `@` 默认值是 `process.cwd()`
:::

## 进阶配置

VuePress 使用 [markdown-it](https://github.com/markdown-it/markdown-it) 来渲染 Markdown,上述大多数的拓展也都是通过自定义的插件实现的。想要进一步的话,你可以通过 `.vuepress/config.js``markdown` 选项,来对当前的 `markdown-it` 实例做一些自定义的配置:
Expand Down

0 comments on commit 4e7f3da

Please sign in to comment.