diff --git a/packages/docs/docs/.vuepress/nav/en.js b/packages/docs/docs/.vuepress/nav/en.js index 3b4af750..eedabe0c 100644 --- a/packages/docs/docs/.vuepress/nav/en.js +++ b/packages/docs/docs/.vuepress/nav/en.js @@ -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', diff --git a/packages/docs/docs/.vuepress/nav/zh.js b/packages/docs/docs/.vuepress/nav/zh.js index c937b793..5dd6e7e7 100644 --- a/packages/docs/docs/.vuepress/nav/zh.js +++ b/packages/docs/docs/.vuepress/nav/zh.js @@ -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: '官方插件', diff --git a/packages/docs/docs/plugin/README.md b/packages/docs/docs/plugin/README.md index 5f52f685..fb93ad10 100644 --- a/packages/docs/docs/plugin/README.md +++ b/packages/docs/docs/plugin/README.md @@ -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 ``` -## 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 diff --git a/packages/docs/docs/zh/plugin/README.md b/packages/docs/docs/zh/plugin/README.md index 925da9b5..aec3e9d5 100644 --- a/packages/docs/docs/zh/plugin/README.md +++ b/packages/docs/docs/zh/plugin/README.md @@ -201,7 +201,7 @@ module.exports = { } ``` -## API +## Option API ### name @@ -651,12 +651,12 @@ VuePress 将会自动将这些组件注入到布局组件的隔壁: ``` -## 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 写入临时文件的方法。