Appearance
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
{
"siteTitle": "小美技术",
"logo": {
"src": "/logo/xm-logo.png",
"alt": "小美技术 Logo"
},
"nav": [
{
"text": "首页",
"link": "/"
},
{
"text": "远程IO系统",
"link": "/remote-io"
},
{
"text": "飞达控制器",
"link": "/feeder"
},
{
"text": "项目案例",
"link": "/api-examples"
}
],
"sidebar": [
{
"text": "关于小美技术",
"items": [
{
"text": "Markdown 示例",
"link": "/markdown-examples"
},
{
"text": "Runtime API 示例",
"link": "/api-examples"
},
{
"text": "本地开发运行",
"link": "/localsetup"
}
]
},
{
"text": "定制项目",
"items": [
{
"text": "Markdown 示例",
"link": "/markdown-examples"
},
{
"text": "Runtime API 示例",
"link": "/api-examples"
},
{
"text": "本地开发运行",
"link": "/localsetup"
}
]
},
{
"text": "远程IO系统",
"items": [
{
"text": "型号识别",
"link": "/markdown-examples"
},
{
"text": "Runtime API 示例",
"link": "/api-examples"
},
{
"text": "本地开发运行",
"link": "/localsetup"
}
]
},
{
"text": "飞达控制器",
"items": [
{
"text": "型号识别",
"link": "/feeder"
},
{
"text": "Runtime API 示例",
"link": "/api-examples"
},
{
"text": "本地开发运行",
"link": "/localsetup"
}
]
}
]
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "api-examples.md",
"filePath": "api-examples.md"
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.
