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": "linux相关",
"link": "/linux/ssl",
"activeMatch": "/linux/"
},
{
"text": "note",
"link": "/note/edgetts",
"activeMatch": "/note/"
},
{
"text": "code备忘录",
"link": "/code/go",
"activeMatch": "/code/"
},
{
"text": "yolo",
"link": "/yolo/yolo",
"activeMatch": "/yolo/"
},
{
"text": "微信小程序",
"link": "/wechat/bluetooth",
"activeMatch": "/wechat/"
},
{
"text": "其他",
"link": "/other/video",
"activeMatch": "/other/"
}
],
"sidebar": {
"/linux/": {
"base": "/linux/",
"items": [
{
"text": "linux相关",
"collapsed": false,
"items": [
{
"text": "ssl免费泛域名",
"link": "/ssl"
},
{
"text": "vps安全ssh",
"link": "/vpsssh"
},
{
"text": "vps使用UFW自动拦截",
"link": "/ufw"
},
{
"text": "ubuntu远程唤醒",
"link": "/ubuntu"
},
{
"text": "nginx缓存配置",
"link": "/nginx"
},
{
"text": "xray重装",
"link": "/xrayonekey"
},
{
"text": "xray免客户端",
"link": "/xray"
},
{
"text": "git自建",
"link": "/git"
}
]
}
]
},
"/note/": {
"base": "/note/",
"items": [
{
"text": "note",
"collapsed": false,
"items": [
{
"text": "edgeTTS",
"link": "/edgetts"
},
{
"text": "pnpm走代理",
"link": "/pnpm"
},
{
"text": "ffmpeg示例",
"link": "/ffmpeg"
},
{
"text": "小米4A刷入openwrt",
"link": "/mirouter"
},
{
"text": "openwrt配置",
"link": "/openwrt"
},
{
"text": "raspberry小车",
"link": "/picar"
}
]
}
]
},
"/code/": {
"base": "/code/",
"items": [
{
"text": "code备忘录",
"collapsed": false,
"items": [
{
"text": "golang",
"link": "/go"
},
{
"text": "nodejs",
"link": "/reptile"
}
]
}
]
},
"/yolo/": {
"base": "/yolo/",
"items": [
{
"text": "yolo",
"collapsed": false,
"items": [
{
"text": "yolo训练",
"link": "/yolo"
},
{
"text": "yolo目标检测",
"link": "/opencv"
}
]
}
]
},
"/wechat/": {
"base": "/wechat/",
"items": [
{
"text": "微信小程序",
"collapsed": false,
"items": [
{
"text": "小程序蓝牙通讯",
"link": "/bluetooth"
},
{
"text": "小程序NFC通讯",
"link": "/nfc"
}
]
}
]
},
"/other/": {
"base": "/other/",
"items": [
{
"text": "其他",
"collapsed": false,
"items": [
{
"text": "tvbox安卓",
"link": "/video"
},
{
"text": "tvbox爬虫",
"link": "/tvboxjar"
},
{
"text": "mac输入法",
"link": "/input"
},
{
"text": "bicycle组装山地车",
"link": "/bicycle"
},
{
"text": "pc组装台式机",
"link": "/pc"
},
{
"text": "iiipro奥利尼刹车",
"link": "/iiir"
},
{
"text": "zuk手机直供电",
"link": "/zuk"
},
{
"text": "测试长文章",
"link": "/text"
},
{
"text": "免责声明",
"link": "/disclaimer"
}
]
}
]
}
},
"footer": {
"message": "Released under the MIT License.",
"copyright": "Copyright © 2019-present Evan You"
},
"logo": {
"src": "/logo.jpg",
"width": 24,
"height": 24
},
"search": {
"provider": "local"
},
"outline": {
"level": 3,
"label": "页面导航"
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/wangz-code"
}
]
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "api-examples.md",
"filePath": "en/api-examples.md"
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.