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
{
"search": {
"provider": "local"
},
"outline": "deep",
"nav": [
{
"text": "Home",
"link": "/"
},
{
"text": "相关阅读",
"items": [
{
"text": "运维",
"link": "/KnowledgeBase/运维/django-docker"
},
{
"text": "UI",
"link": "/KnowledgeBase/UI/miev-nav"
},
{
"text": "Apple ID 美区注册",
"link": "/KnowledgeBase/AppleID美区注册"
}
]
},
{
"text": "浅谈浅见",
"items": [
{
"text": "看山是山",
"link": "/CasualTalk/看山是山"
}
]
},
{
"text": "技术服务",
"items": [
{
"text": "业务介绍",
"link": "/about/business"
},
{
"text": "Hws文件富搜索",
"link": "/utility/everything-voidtools"
}
]
}
],
"sidebar": {
"/Examples/": [
{
"text": "api-examples",
"link": "/Examples/api-examples"
},
{
"text": "markdown-examples",
"link": "/Examples/markdown-examples"
}
],
"/KnowledgeBase/运维/": [
{
"text": "CICD Vitepress gitactions stiemap",
"link": "/KnowledgeBase/运维/CICD"
},
{
"text": "Django 使用gitaction构建 dokcer镜像, 并发布到github, dockerhub, 阿里云镜像",
"link": "/KnowledgeBase/运维/django-docker"
},
{
"text": "Ubuntu partition 扩展分区",
"link": "/KnowledgeBase/运维/ubuntu-partition"
},
{
"text": "video-test",
"link": "/KnowledgeBase/运维/video-test"
}
],
"/KnowledgeBase/UI/": [
{
"text": "仿小米汽车网站导航",
"link": "/KnowledgeBase/UI/miev-nav"
}
],
"/CasualTalk/": [
{
"text": "看山是山",
"link": "/CasualTalk/看山是山"
}
]
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/WorshipMoon/sean_web"
}
]
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "Examples/api-examples.md",
"filePath": "Examples/api-examples.md",
"lastUpdated": 1730461644000
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.