运行时API案例
This page demonstrates usage of some of the runtime APIs provided by VitePress.
The main useData()
API can be used to access site, theme, and page data for the current page. It works in both .md
and .vue
files:
md
<script setup>
import { useData } from 'vitepress'
const { theme, page, frontmatter } = useData()
</script>
## Results
### Theme Data
<pre>{{ theme }}</pre>
### Page Data
<pre>{{ page }}</pre>
### Page Frontmatter
<pre>{{ frontmatter }}</pre>
<script setup>
import { useData } from 'vitepress'
const { theme, page, frontmatter } = useData()
</script>
## Results
### Theme Data
<pre>{{ theme }}</pre>
### Page Data
<pre>{{ page }}</pre>
### Page Frontmatter
<pre>{{ frontmatter }}</pre>
Results
Theme Data
{ "logo": "/logo.png", "outline": { "label": "本页内容" }, "nav": [ { "text": "指南", "link": "/zh/guide/", "activeMatch": "^/zh/guide/" }, { "text": "API", "link": "/zh/api/", "activeMatch": "^/zh/api/" }, { "text": "相关链接", "items": [ { "text": "论坛", "link": "https://github.com/JuckZ/awesome-brain-manager/discussions" }, { "text": "更新日志", "link": "https://github.com/JuckZ/awesome-brain-manager/blob/master/CHANGELOG.md" }, { "text": "路线图", "link": "https://github.com/users/JuckZ/projects/2" } ] } ], "sidebar": { "/zh/api/": [ { "text": "packages", "items": [ { "text": "core", "link": "/zh/api/modules/core.html" }, { "text": "pomodoro", "link": "/zh/api/modules/pomodoro.html" }, { "text": "ai", "link": "/zh/api/modules/ai.html" }, { "text": "obsidian", "link": "/zh/api/modules/obsidian.html" }, { "text": "utils", "link": "/zh/api/modules/utils.html" }, { "text": "ntfy", "link": "/zh/api/modules/ntfy.html" }, { "text": "browser", "link": "/zh/api/modules/browser.html" } ] } ], "/zh/": [ { "text": "介绍", "items": [ { "text": "Awesome Brain Manager 是什么?", "link": "/zh/introduction.html" }, { "text": "开始", "link": "/zh/getting-started.html" } ] }, { "text": "核心功能", "items": [ { "text": "功能预览", "link": "/zh/guide/" }, { "text": "番茄钟", "link": "/zh/guide/pomodoro.html" }, { "text": "特效", "link": "/zh/guide/special-effects.html" }, { "text": "小工具", "link": "/zh/guide/utils.html" } ] }, { "text": "手册", "collapsed": false, "items": [ { "text": "目录", "link": "/zh/cookbook/" }, { "text": "热更新", "link": "/zh/cookbook/hot-module-replacement.html" }, { "text": "测试", "link": "/zh/cookbook/testing.html" }, { "text": "高级", "link": "/zh/cookbook/advanced.html" } ] } ] }, "socialLinks": [ { "icon": { "svg": "rss" }, "link": "/feed.rss" }, { "icon": "github", "link": "https://github.com/JuckZ/awesome-brain-manager" } ], "footer": { "copyright": "Copyright © 2022-present Juck", "message": "Released under the MIT License." }, "editLink": { "pattern": "https://github.com/JuckZ/awesome-brain-manager/edit/develop/docs/:path", "text": "对本页提出修改建议" }, "docFooter": { "prev": "上一页", "next": "下一页" } }
Page Data
{ "title": "运行时API案例", "description": "", "frontmatter": { "outline": "deep" }, "headers": [], "relativePath": "zh/api-examples.md", "filePath": "zh/api-examples.md", "lastUpdated": 1734362192000 }
Page Frontmatter
{ "outline": "deep" }
More
Check out the documentation for the full list of runtime APIs.