Skip to content

Commit 3d5b3f8

Browse files
committed
docs: add global component page
1 parent 72e116c commit 3d5b3f8

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

docs/.vitepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ function getGuideSidebar() {
6161
children: [
6262
{ text: 'Frontmatter', link: '/guide/frontmatter' },
6363
{ text: 'Global Computed', link: '/guide/global-computed' },
64+
{ text: 'Global Component', link: '/guide/global-component' },
6465
{ text: 'Customization', link: '/guide/customization' },
6566
{
6667
text: 'Differences from Vuepress',

docs/guide/differences-from-vuepress.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ In case you decide to move your project to VitePress, this is a list of differen
110110
- `path`
111111
- `regularPath`
112112

113-
## Default Components
113+
## Global Components
114114

115115
- Missing
116-
- [`<ClientOnly>`](https://vuepress.vuejs.org/guide/using-vue.html#browser-api-access-restrictions)
117116
- [`<Badge>`](https://vuepress.vuejs.org/guide/using-vue.html#badge)

docs/guide/global-component.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Global Component
2+
3+
VitePress comes with few built-in component that can be used globally. You may use these components in your markdown or your custom theme configuration.
4+
5+
## Content
6+
7+
The `Content` component displays the rendered markdown contents. Useful [when creating your own theme](http://localhost:3000/guide/customization.html).
8+
9+
```vue
10+
<template>
11+
<h1>Custom Layout!</h1>
12+
<Content />
13+
</template>
14+
```
15+
16+
## ClientOnly
17+
18+
The `ClientOnly` component renderes its slot only at client side.
19+
20+
Because VitePress applications are server-rendered in Node.js when generating static builds, any Vue usage must conform to the universal code requirements. In short, make sure to only access Browser / DOM APIs in beforeMount or mounted hooks.
21+
22+
If you are using or demoing components that are not SSR-friendly (for example, contain custom directives), you can wrap them inside the `ClientOnly` component.
23+
24+
```html
25+
<ClientOnly>
26+
<NonSSRFriendlyComponent />
27+
</ClientOnly>
28+
```

0 commit comments

Comments
 (0)