Skip to content

Commit 4e7f3da

Browse files
committed
docs(cn): update for import code snippets (#538)
1 parent 26ecff7 commit 4e7f3da

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

docs/guide/markdown.md

+7
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ export default {
226226

227227
## Import Code Snippets
228228

229+
You can import code snippets from existing files via following syntax:
230+
229231
**Input**
230232

231233
```
@@ -236,6 +238,11 @@ export default {
236238

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

241+
::: tip
242+
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()`.
243+
:::
244+
245+
239246
## Advanced Configuration
240247

241248
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`:

docs/zh/guide/markdown.md

+18
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,24 @@ export default {
222222
}
223223
```
224224

225+
## 导入代码段
226+
227+
你可以通过下述的语法导入已经存在的文件中的代码段:
228+
229+
**Input**
230+
231+
```
232+
<<< @/test/markdown/fragments/snippet.js{2}
233+
```
234+
235+
**Output**
236+
237+
<<< @/test/markdown/fragments/snippet.js{2}
238+
239+
::: tip 注意
240+
由于代码段的导入将在 webpack 编译之前执行,因此你无法使用 webpack 中的路径别名,此处的 `@` 默认值是 `process.cwd()`
241+
:::
242+
225243
## 进阶配置
226244

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

0 commit comments

Comments
 (0)