Skip to content

Commit

Permalink
docs: add onContentUpdated
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo committed Dec 6, 2024
1 parent a2815b1 commit 1b677c1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
20 changes: 19 additions & 1 deletion docs/reference/client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,24 @@ const {

The properties of current locale have been merged into the root-level properties.

### onContentUpdated

- Details:

When the content of the markdown file changes, the callback is triggered.

This function can only be called during the `setup` phase of the component.

```vue
<script setup>
import { onContentUpdated } from 'vuepress/client'
onContentUpdated(() => {
console.log('content updated')
})
</script>
```

## Helpers

### defineClientConfig
Expand All @@ -126,7 +144,7 @@ const {
- Also see:
- [Advanced > Cookbook > Resolving Routes](../advanced/cookbook/resolving-routes.md)

## resolveRoutePath
### resolveRoutePath

- Details:

Expand Down
20 changes: 19 additions & 1 deletion docs/zh/reference/client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,24 @@ const {

当前 locale 中的配置已经合并到顶层配置中。

### onContentUpdated

- 详情:

当 markdown 文件内容发生变化时,触发回调。

该函数仅能在组件的 `setup` 阶段被调用。

```vue
<script setup>
import { onContentUpdated } from 'vuepress/client'
onContentUpdated(() => {
console.log('content updated')
})
</script>
```

## 工具函数

### defineClientConfig
Expand All @@ -126,7 +144,7 @@ const {
- 参考:
- [深入 > Cookbook > 解析路由](../advanced/cookbook/resolving-routes.md)

## resolveRoutePath
### resolveRoutePath

- 详情:

Expand Down

0 comments on commit 1b677c1

Please sign in to comment.