Skip to content

Commit 5c1e7a4

Browse files
Sun Haoranmeteorlxy
Sun Haoran
authored andcommitted
docs: refine plugin documentation (#2053)
1 parent 3935bce commit 5c1e7a4

File tree

5 files changed

+63
-9
lines changed

5 files changed

+63
-9
lines changed

packages/docs/docs/plugin/README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Plugin
22

3-
Plugins generally add global-level functionality to VuePress. There is no strictly defined scope for a plugin - there are typically several types of plugins:
3+
Plugins generally add global-level functionality to VuePress. There is no strictly defined scope for a plugin. You can find out more plugins at [Awesome VuePress](https://github.com/vuepressjs/awesome-vuepress#plugins).
4+
5+
## Examples
6+
7+
There are typically several types of plugins:
48

59
1. Extend the page’s metadata generated at compile time. For example [@vuepress/plugin-last-updated](./official/plugin-last-updated.md);
610
2. Generate extra files before or after compilation. For example [@vuepress/plugin-pwa](./official/plugin-pwa.md);
@@ -9,6 +13,25 @@ Plugins generally add global-level functionality to VuePress. There is no strict
913

1014
Here is also a little slightly complicated plugin example [@vuepress/plugin-blog](https://vuepress-plugin-blog.ulivz.com) that uses compile-time metadata to generate some dynamic modules and initialize them on the client-side by using `enhanceAppFiles`.
1115

16+
## Out of the Box
17+
18+
To keep things at a minimum, not all of the official plugins are shipped with VuePress. Here is the list of plugins that are pre-installed in the VuePress and the default theme, **plugins that are not in the list below need to be installed manually**(e.g. [@vuepress/plugin-back-to-top](./official/plugin-back-to-top.md)).
19+
20+
### Plugins that come with VuePress
21+
22+
- [@vuepress/plugin-last-updated](./official/plugin-last-updated.md)
23+
- [@vuepress/plugin-register-components](./official/plugin-register-components.md)
24+
25+
### Plugins that come with the defualt theme
26+
27+
- [@vuepress/plugin-active-header-links](./official/plugin-active-header-links.md)
28+
- [@vuepress/plugin-nprogress](./official/plugin-nprogress.md)
29+
- [@vuepress/plugin-search](./official/plugin-search.md)
30+
- [vuepress-plugin-container](https://vuepress.github.io/plugins/container/)
31+
- [vuepress-plugin-smooth-scroll](https://vuepress.github.io/plugins/smooth-scroll/)
32+
33+
## Architecture
34+
1235
The architecture of the whole plugin system is as follows:
1336

1437
![Architecture of VuePress](/architecture.png)

packages/docs/docs/plugin/official/plugin-active-header-links.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ module.exports = {
2323
```
2424

2525
### Passing Options
26+
2627
```javascript
2728
module.exports = {
2829
plugins: ['@vuepress/active-header-links', {
2930
sidebarLinkSelector: '.sidebar-link',
30-
headerAnchorSelector: '.header-anchor',
31-
headerTopOffset: 120
31+
headerAnchorSelector: '.header-anchor'
3232
}]
3333
}
3434
```
@@ -44,4 +44,3 @@ module.exports = {
4444

4545
- Type: `string`
4646
- Default: `.header-anchor`
47-

packages/docs/docs/zh/plugin/README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
11
# 插件
22

3-
插件通常会为 VuePress 添加全局功能。插件的范围没有限制——一般有下面几种:
3+
插件通常会为 VuePress 添加全局功能。插件的范围没有限制。你可以在 [Awesome VuePress](https://github.com/vuepressjs/awesome-vuepress#plugins) 中找到更多的插件。
4+
5+
## 样例
6+
7+
以下是几种比较常见的插件:
48

59
1. 拓展在编译期生成的页面元数据,如:[@vuepress/plugin-last-updated](./official/plugin-last-updated.md)
610
2. 在编译前后生成额外的文件,如:[@vuepress/plugin-pwa](./official/plugin-pwa.md)
711
3. 注入全局的 UI, 如:[@vuepress/plugin-back-to-top](./official/plugin-back-to-top.md);
8-
4. 拓展 CLI 的指令,如 [vuepress-plugin-export](https://github.com/ulivz/vuepress-plugin-export)
12+
4. 拓展 CLI 的指令,如:[vuepress-plugin-export](https://github.com/ulivz/vuepress-plugin-export)
13+
14+
这里也有一个略微复杂的插件案例 [@vuepress/plugin-blog](https://vuepress-plugin-blog.ulivz.com),其使用了编译器的元数据来生成了一些动态模块,并在客户端使用 `enhanceAppFiles` 来初始化他们。
15+
16+
## 开箱即用
17+
18+
为了让项目尽可能地简洁,并非所有官方插件都会随着 VuePress 一同安装。以下是一些随着 VuePress 和默认主题一同安装的插件,**没有出现在下表中的插件需要手动安装**(比如:[@vuepress/plugin-back-to-top](./official/plugin-back-to-top.md))。
19+
20+
### VuePress 自带的插件
21+
22+
- [@vuepress/plugin-last-updated](./official/plugin-last-updated.md)
23+
- [@vuepress/plugin-register-components](./official/plugin-register-components.md)
24+
25+
### 默认主题自带的插件
26+
27+
- [@vuepress/plugin-active-header-links](./official/plugin-active-header-links.md)
28+
- [@vuepress/plugin-nprogress](./official/plugin-nprogress.md)
29+
- [@vuepress/plugin-search](./official/plugin-search.md)
30+
- [vuepress-plugin-container](https://vuepress.github.io/zh/plugins/container/)
31+
- [vuepress-plugin-smooth-scroll](https://vuepress.github.io/zh/plugins/smooth-scroll/)
932

10-
这里也有一个略微复杂的插件案例 [@vuepress/plugin-blog](https://vuepress-plugin-blog.ulivz.com), 其使用了编译器的元数据来生成了一些动态模块,并在客户端使用 `enhanceAppFiles` 来初始化他们。
33+
## 架构
1134

1235
整个插件系统的架构如下:
1336

packages/docs/docs/zh/plugin/official/plugin-active-header-links.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ module.exports = {
2222
}
2323
```
2424

25+
### 配置选项
26+
27+
```javascript
28+
module.exports = {
29+
plugins: ['@vuepress/active-header-links', {
30+
sidebarLinkSelector: '.sidebar-link',
31+
headerAnchorSelector: '.header-anchor'
32+
}]
33+
}
34+
```
35+
2536
## 选项
2637

2738
### sidebarLinkSelector

packages/docs/docs/zh/plugin/official/plugin-medium-zoom.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ yarn add -D @vuepress/plugin-medium-zoom
1616

1717
## 使用
1818

19-
## Usage
20-
2119
**简单使用**:
2220

2321
```javascript

0 commit comments

Comments
 (0)