Skip to content

Commit ec1f7a5

Browse files
committed
docs: add built-in components reference
1 parent 6d6f2c5 commit ec1f7a5

File tree

4 files changed

+113
-2
lines changed

4 files changed

+113
-2
lines changed

docs/guide/markdown.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ Take our documentation source files as an example:
8282
This links extension is supported by our built-in plugin.
8383

8484
Config reference: [markdown.links](../reference/config.md#markdown-links)
85+
86+
Also see: [Built-in Components > OutboundLink](../reference/components.md#outboundlink)
8587
:::
8688

8789
### Emoji :tada:

docs/reference/components.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,56 @@
11
# Built-in Components
22

3-
> TODO
3+
## ClientOnly
4+
5+
- Usage:
6+
7+
```md
8+
<ClientOnly>
9+
<NonSsrFriendlyComponent />
10+
</ClientOnly>
11+
```
12+
13+
- Details:
14+
15+
This component and its children will only be rendered in client-side. That means, it will not be rendered to HTML during build (SSR).
16+
17+
If a component is trying to access Browser / DOM APIs directly in `setup()`, an error will occur during build because those APIs are unavailable in Node.js environment. In such case, you could do either:
18+
19+
- Modify the component to only access Browser / DOM APIs in `onBeforeMount()` or `onMounted()` hook.
20+
- Wrap the component with `<ClientOnly>`.
21+
22+
## Content
23+
24+
- Props:
25+
- pagePath
26+
- Type: `string`
27+
- Required: `false`
28+
29+
- Usage:
30+
31+
```md
32+
<Content page-path="/" />
33+
<Content page-path="/foo.html" />
34+
```
35+
36+
- Details:
37+
38+
This component will render the Markdown content of a page.
39+
40+
If the `pagePath` prop is not provided, it will render the page of current route path.
41+
42+
This component is mainly for developing themes. You won't need it in most cases.
43+
44+
## OutboundLink
45+
46+
- Usage:
47+
48+
```md
49+
<OutboundLink />
50+
```
51+
52+
- Details:
53+
54+
This component will render an indicator for links to external URLs.
55+
56+
This component is mainly for developing themes. You won't need it in most cases.

docs/zh/guide/markdown.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ VuePress 会使用 [markdown-it](https://github.com/markdown-it/markdown-it) 来
8383
链接扩展是由我们的内置插件支持的。
8484

8585
配置参考: [markdown.links](../reference/config.md#markdown-links)
86+
87+
参考: [內置组件 > OutboundLink](../reference/components.md#outboundlink)
8688
:::
8789

8890
### Emoji :tada:

docs/zh/reference/components.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,57 @@
11
# 内置组件
22

3-
> TODO
3+
4+
## ClientOnly
5+
6+
- 使用:
7+
8+
```md
9+
<ClientOnly>
10+
<NonSsrFriendlyComponent />
11+
</ClientOnly>
12+
```
13+
14+
- 详情:
15+
16+
该组件和它的子元素只会在客户端被渲染。也就是说,它不会在构建 (SSR) 过程中被渲染到 HTML 内。
17+
18+
如果一个组件在 `setup()` 中直接使用 浏览器 / DOM API ,它会导致构建过程报错,因为这些 API 在 Node.js 的环境中是无法使用的。在这种情况下,你可以选择一种方式:
19+
20+
- 修改这个组件,只在 `onBeforeMount()``onMounted()` Hook 中使用 浏览器 / DOM API 。
21+
- 使用 `<ClientOnly>` 包裹这个组件。
22+
23+
## Content
24+
25+
- Props:
26+
- pagePath
27+
- 类型: `string`
28+
- 是否必须: `false`
29+
30+
- 使用:
31+
32+
```md
33+
<Content page-path="/" />
34+
<Content page-path="/foo.html" />
35+
```
36+
37+
- 详情:
38+
39+
该组件会渲染页面的 Markdown 内容。
40+
41+
如果没有传入 `pagePath` Prop ,它会渲染当前路由路径下的页面。
42+
43+
该组件主要是为了开发主题时使用。在绝大多数情况下你不会用到它。
44+
45+
## OutboundLink
46+
47+
- 使用:
48+
49+
```md
50+
<OutboundLink />
51+
```
52+
53+
- 详情:
54+
55+
该组件会渲染一个标识外部 URL 链接的图标。
56+
57+
该组件主要是为了开发主题时使用。在绝大多数情况下你不会用到它。

0 commit comments

Comments
 (0)