Skip to content

docs: add onContentUpdated composition API #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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((reason) => {
console.log(`content updated reason: ${reason}`)
})
</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((reason) => {
console.log(`content updated reason: ${reason}`)
})
</script>
```

## 工具函数

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

## resolveRoutePath
### resolveRoutePath

- 详情:

Expand Down
Loading