Runtime API Examples
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>Results
Theme Data
{
"nav": [
{
"text": "首页",
"link": "/"
},
{
"text": "指南",
"link": "/guide",
"activeMatch": "^/guide/"
},
{
"text": "Examples",
"link": "/markdown-examples"
}
],
"sidebar": {
"/guide/": [
{
"text": "快速入门",
"link": "/guide/getting-started"
},
{
"text": "插件开发",
"items": [
{
"text": "TOC 文件",
"link": "/guide/toc-file"
},
{
"text": "事件处理",
"link": "/guide/event-handling"
},
{
"text": "数据存储",
"link": "/guide/saved-variables"
},
{
"text": "创建斜杠命令",
"link": "/guide/creating-slash-command"
}
]
},
{
"text": "工具和技巧",
"items": [
{
"text": "游戏内调试工具",
"link": "/guide/debug-tools"
},
{
"text": "暴雪界面代码",
"link": "/guide/blizzard-interface-code"
},
{
"text": "实用插件",
"link": "/guide/debug-addons"
},
{
"text": "代码编辑器",
"link": "/guide/code-editor"
},
{
"text": "在线工具",
"link": "/guide/online-tools"
}
]
},
{
"text": "Lua 速查表",
"link": "/guide/lua-cheat-sheet"
}
]
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/gjfLeo/wow-api-docs"
}
],
"outline": {
"level": "deep",
"label": "大纲"
}
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "api-examples.md",
"filePath": "api-examples.md",
"lastUpdated": 1727181721000
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.