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
{
"head": [
[
"link",
{
"rel": "icon",
"href": "/favicon.ico"
}
]
],
"logo": "/logo.png",
"search": {
"provider": "local"
},
"outline": {
"level": [
2,
4
],
"label": "页面导航"
},
"lastUpdated": {
"text": "最后更新",
"formatOptions": {
"dateStyle": "short",
"timeStyle": "short"
}
},
"docFooter": {
"prev": "上一页",
"next": "下一页"
},
"langMenuLabel": "多语言",
"returnToTopLabel": "回到顶部",
"sidebarMenuLabel": "菜单",
"darkModeSwitchLabel": "主题",
"lightModeSwitchTitle": "切换到浅色模式",
"darkModeSwitchTitle": "切换到深色模式",
"outlineTitle": "目录",
"nav": [
{
"text": "运维指南",
"link": "/docs/"
},
{
"text": "帮助中心",
"link": "/help/"
},
{
"text": "友情链接",
"items": [
{
"text": "网址导航",
"link": "https://nav.aisk.cc/"
},
{
"text": "攀岩之鹿",
"link": "https://aisk.cc/"
},
{
"text": "XC知识库",
"link": "https://gxxc.wiki/"
},
{
"text": "Jeremy Blog",
"link": "https://www.cnblogs.com/aistack/"
}
]
}
],
"sidebar": {
"/docs/": [
{
"text": "运维手册",
"collapsed": false,
"items": [
{
"text": "运维指南",
"link": "/docs/"
},
{
"text": "基础篇2",
"link": "/docs/linux"
}
]
},
{
"text": "麒麟系统",
"collapsed": true,
"items": [
{
"text": "麒麟系统激活",
"link": "/docs/kylin/kylin-activation"
}
]
},
{
"text": "一体化监测",
"collapsed": true,
"items": [
{
"text": "Prom基本授权",
"link": "docs/monitoring/Prometheus_basic_auth"
}
]
}
],
"/help/": [
{
"text": "帮助中心",
"collapsed": false,
"items": [
{
"text": "运维帮助",
"link": "/help/"
},
{
"text": "运维帮助2",
"link": "/help/docs"
}
]
}
]
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/Stack-Baize"
}
],
"footer": {
"message": "内容仅供参考,操作前请备份!",
"copyright": "Copyright © 2024-2025 By Jeremy.Peng"
}
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "help/index.md",
"filePath": "help/index.md",
"lastUpdated": 1762592503000
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.
