docs: update plugin & nav

This commit is contained in:
ULIVZ
2018-10-26 01:07:31 +08:00
parent 77ef9ae9fa
commit fd51d43cd5
4 changed files with 42 additions and 26 deletions
+10 -2
View File
@@ -19,8 +19,16 @@ module.exports = [
link: '/plugin/#using-a-plugin'
},
{
text: 'Options',
link: '/plugin/#options'
text: 'Life Cycle API',
link: '/plugin/#life-cycle-api'
},
{
text: 'Option API',
link: '/plugin/#option-api'
},
{
text: 'Context API',
link: '/plugin/#context-api'
},
{
text: 'Official Plugins',
+12 -4
View File
@@ -11,16 +11,24 @@ module.exports = [
text: '插件',
items: [
{
text: '插件的开发',
text: '开发插件',
link: '/zh/plugin/#writing-a-plugin'
},
{
text: '插件的使用',
text: '使用插件',
link: '/zh/plugin/#using-a-plugin'
},
{
text: '插件的选项',
link: '/zh/plugin/#options'
text: '生命周期',
link: '/zh/plugin/#life-cycle-api'
},
{
text: 'Option API',
link: '/zh/plugin/#option-api'
},
{
text: 'Context API',
link: '/zh/plugin/#context-api'
},
{
text: '官方插件',
+6 -6
View File
@@ -2,7 +2,7 @@
sidebar: auto
---
# Plugins
# Plugin
Plugins usually add global-level functionality to VuePress. There is no strictly defined scope for a plugin - there are typically several types of plugins:
@@ -151,7 +151,7 @@ module.exports = {
:::
## Life Cycle
## Life Cycle API
### ready
@@ -201,7 +201,7 @@ module.exports = {
}
```
## API
## Option API
### name
@@ -653,12 +653,12 @@ Then, VuePress will automatically inject these components behind the layout comp
</div>
```
## ctx
## Context API
Starting with VuePress 1.x.x, VuePress provides an `AppContext` object that stores all the state of the current app and can be accessed through the plugin API.
::: warning Note
Context of each plugin is a isolated context, they just inherit from the same app context.
Context of each plugin is a isolated context inherited from the same app context.
:::
```js
@@ -671,7 +671,7 @@ module.exports = (options, ctx) => {
- Type: `boolean`
Whether vuepress run in production environment mode.
Whether VuePress run in production environment mode.
### ctx.sourceDir
+14 -14
View File
@@ -201,7 +201,7 @@ module.exports = {
}
```
## API
## Option API
### name
@@ -651,12 +651,12 @@ VuePress 将会自动将这些组件注入到布局组件的隔壁:
</div>
```
## ctx
## Context API
Starting with VuePress 1.x.x, VuePress provides an `AppContext` object that stores all the state of the current app and can be accessed through the plugin API.
VuePress 提供了一个存储了当前页面所有状态的 Context API
::: warning Note
Context of each plugin is a isolated context, they just inherit from the same app context.
::: tip 提示
每个函数式插件的上下文对象是一个继承于根上下文的隔离上下文对象。
:::
```js
@@ -667,42 +667,42 @@ module.exports = (options, ctx) => {
### ctx.isProd
- Type: `boolean`
- 类型: `boolean`
Whether vuepress run in production environment mode.
VuePress 是否运行在生产环境模式下。
### ctx.sourceDir
- Type: `string`
- 类型: `string`
Root directory where the documents are located.
文档的根目录路径。
### ctx.tempPath
- Type: `string`
Root directory where the temporary files are located.
临时文件所在的根目录路径。
### ctx.outDir
- Type: `string`
Output path.
输出目录。
### ctx.themePath
- Type: `string`
The path of the currently active theme.
当前应用的主题的根路径。
### ctx.base
- Type: `string`
See: [base](../config/README.md#base).
参考: [base](../config/README.md#base).
### ctx.writeTemp
- Type: `Function`
A utility for writing temporary files to tempPath.
一个用于向 tempPath 写入临时文件的方法。