Skip to content

Commit 3da75db

Browse files
committed
docs(plugin-active-header-links): add plugin reference
1 parent 49c3e09 commit 3da75db

File tree

2 files changed

+108
-2
lines changed

2 files changed

+108
-2
lines changed
Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,56 @@
11
# active-header-links
22

3-
> TODO
3+
> @vuepress/plugin-active-header-links
4+
5+
This plugin will listen to page scroll event. When the page scrolls to a certain _header anchor_, this plugin will change the route hash to that _header anchor_ if there is a corresponding _header link_.
6+
7+
This plugin is mainly used to develop themes, and has been integrated into the default theme. You won't need to use it directly in most cases.
8+
9+
## Options
10+
11+
### headerLinkSelector
12+
13+
- Type: `string`
14+
15+
- Default: `'.sidebar-link'`
16+
17+
- Details:
18+
19+
Selector of _header link_.
20+
21+
If a _header anchor_ does not have a corresponding _header link_, this plugin won't change the route hash to that anchor when scrolling to it.
22+
23+
### headerAnchorSelector
24+
25+
- Type: `string`
26+
27+
- Default: `'.header-anchor'`
28+
29+
- Details:
30+
31+
Selector of _header anchor_.
32+
33+
You don't need to specify this option unless you have changed the `permalinkClass` option of [markdown-it-anchor](https://github.com/valeriangalliat/markdown-it-anchor#readme) via [markdown.anchor](../config.md#markdown-anchor).
34+
35+
- Also see:
36+
- [Guide > Markdown > Syntax Extensions > Header Anchors](../../guide/markdown.md#header-anchors)
37+
38+
### delay
39+
40+
- Type: `number`
41+
42+
- Default: `200`
43+
44+
- Details:
45+
46+
The delay of the debounced scroll event listener.
47+
48+
### offset
49+
50+
- Type: `number`
51+
52+
- Default: `5`
53+
54+
- Details:
55+
56+
Even if you click the link of the _header anchor_ directly, the `scrollTop` might not be exactly equal to `offsetTop` of the _header anchor_, so we add an offset to avoid the error.
Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,56 @@
11
# active-header-links
22

3-
> TODO
3+
> @vuepress/plugin-active-header-links
4+
5+
该插件会监听页面滚动事件。当页面滚动至某个 _标题锚点_ 后,如果存在对应的 _标题链接_ ,那么该插件会将路由 Hash 更改为该 _标题锚点_
6+
7+
该插件主要用于开发主题,并且已经集成到默认主题中。大部分情况下你不需要直接使用它。
8+
9+
## 配置项
10+
11+
### headerLinkSelector
12+
13+
- 类型: `string`
14+
15+
- 默认值: `'.sidebar-link'`
16+
17+
- 详情:
18+
19+
_标题链接_ 的选择器。
20+
21+
如果一个 _标题锚点_ 没有对应的 _标题链接_ ,那么及时滚动到这个 _标题锚点_ ,该插件也不会更改路由 Hash 。
22+
23+
### headerAnchorSelector
24+
25+
- 类型: `string`
26+
27+
- 默认值: `'.header-anchor'`
28+
29+
- 详情:
30+
31+
_标题锚点_ 的选择器。
32+
33+
你通常不需要设置该选项,除非你通过 [markdown.anchor](../config.md#markdown-anchor) 修改了 [markdown-it-anchor](https://github.com/valeriangalliat/markdown-it-anchor#readme)`permalinkClass` 选项。
34+
35+
- 参考:
36+
- [指南 > Markdown > 语法扩展 > 标题锚点](../../guide/markdown.md#标题锚点)
37+
38+
### delay
39+
40+
- 类型: `number`
41+
42+
- 默认值: `200`
43+
44+
- 详情:
45+
46+
滚动事件监听器的 Debounce 延迟。
47+
48+
### offset
49+
50+
- 类型: `number`
51+
52+
- 默认值: `5`
53+
54+
- 详情:
55+
56+
即便直接点击 _标题锚点_ 的链接, `scrollTop` 也可能不会完全等于 _标题锚点_`offsetTop` ,所以我们添加一个 Offset 偏移量来避免这个误差。

0 commit comments

Comments
 (0)