Skip to content

Commit 9b87e5b

Browse files
committed
docs: add AutoLink
1 parent b7821e4 commit 9b87e5b

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed

docs/reference/components.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,64 @@
11
# Built-in Components
22

3+
## AutoLink
4+
5+
- Props:
6+
7+
- config
8+
- Type: `AutoLinkConfig`
9+
- Required: `true`
10+
11+
```ts
12+
interface AutoLinkConfig {
13+
/**
14+
* Pattern to determine if the link should be active, which has higher priority than `exact`
15+
*/
16+
activeMatch?: string | RegExp
17+
18+
/**
19+
* The `aria-label` attribute
20+
*/
21+
ariaLabel?: string
22+
23+
/**
24+
* Whether the link should be active only if the url is an exact match
25+
*/
26+
exact?: boolean
27+
28+
/**
29+
* URL of the auto link
30+
*/
31+
link: string
32+
33+
/**
34+
* The `rel` attribute
35+
*/
36+
rel?: string
37+
38+
/**
39+
* The `target` attribute
40+
*/
41+
target?: string
42+
43+
/**
44+
* Text of the auto link
45+
*/
46+
text: string
47+
}
48+
```
49+
50+
```md
51+
<AutoLink :config="autoLinkConfig" />
52+
```
53+
54+
- Details:
55+
56+
This component will automatically render a `<RouteLink>` or `<a>` bases on your configuration.
57+
58+
It's recommended to use this component instead of the `<RouteLink>` component if the link can be both internal and external.
59+
60+
It has a default slot to render the content of the link (default is `config.text`), and you can also add slots named `before` and `after` to render content before and after the text.
61+
362
## ClientOnly
463

564
- Usage:

docs/zh/reference/components.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,66 @@
11
# 内置组件
22

3+
## AutoLink
4+
5+
- Props:
6+
7+
- config
8+
- 类型:`AutoLinkConfig`
9+
- 是否必须:`true`
10+
11+
```ts
12+
interface AutoLinkConfig {
13+
/**
14+
* 判断该链接是否被激活的模式,优先级高于 `exact`
15+
*/
16+
activeMatch?: string | RegExp
17+
18+
/**
19+
* `aria-label` 属性
20+
*/
21+
22+
ariaLabel?: string
23+
24+
/**
25+
* 该链接是否只有在 URL 完全匹配时才激活
26+
*/
27+
exact?: boolean
28+
29+
/**
30+
* 自动链接的 URL
31+
*/
32+
33+
link: string
34+
35+
/**
36+
* `rel` 属性
37+
*/
38+
rel?: string
39+
40+
/**
41+
* `target` 属性
42+
*/
43+
target?: string
44+
45+
/**
46+
* 自动链接的文本
47+
*/
48+
text: string
49+
}
50+
```
51+
52+
```md
53+
<AutoLink :config="autoLinkConfig" />
54+
```
55+
56+
- 详情:
57+
58+
该组件将根据您的配置自动渲染一个 `<RouteLink>``<a>`
59+
60+
如果链接既可以是内部链接也可以是外部链接,建议使用这个组件而不是 `<RouteLink>` 组件。
61+
62+
它有一个默认插槽用于渲染链接的内容(默认为 `config.text`),您还可以添加名为 `before``after` 的插槽,在文本之前和之后渲染内容。
63+
364
## ClientOnly
465

566
- 使用:

0 commit comments

Comments
 (0)