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
{
"logo": "/logo.png",
"siteTitle": false,
"nav": [
{
"text": "首页",
"link": "/"
},
{
"text": "杂物间",
"items": [
{
"text": "VitePress",
"items": [
{
"text": "VitePress示例",
"link": "/examples/docexamples/docexamples"
}
]
},
{
"text": "工具箱",
"items": [
{
"text": "常用网页",
"link": "/utilityroom/toolbox/常用网页.html"
}
]
}
]
},
{
"text": "壁纸",
"items": [
{
"items": [
{
"text": "PC壁纸",
"link": "/壁纸/PC壁纸/2025年04月-1.html"
}
]
}
]
},
{
"text": "关于",
"items": [
{
"text": "关于本站",
"link": "/about/关于本站"
}
]
}
],
"outline": {
"label": "页面导航",
"level": [
2,
4
]
},
"footer": {
"message": "Released under the MIT License.",
"copyright": "© 2025 marchhare.wang 版权所有. ICP证:<a href=\"https://beian.miit.gov.cn/\" target=\"_blank\">辽ICP备2025052215号-1</a>"
},
"search": {
"provider": "algolia",
"options": {
"appId": "2Z834SUMQV",
"apiKey": "52572cf5945ec8ed05ae4e9f6b2581c5",
"indexName": "marchhare",
"locales": {
"root": {
"placeholder": "搜索文档",
"translations": {
"button": {
"buttonText": "搜索文档",
"buttonAriaLabel": "搜索文档"
},
"modal": {
"searchBox": {
"resetButtonTitle": "清除查询条件",
"resetButtonAriaLabel": "清除查询条件",
"cancelButtonText": "取消",
"cancelButtonAriaLabel": "取消"
},
"startScreen": {
"recentSearchesTitle": "搜索历史",
"noRecentSearchesText": "没有搜索历史",
"saveRecentSearchButtonTitle": "保存至搜索历史",
"removeRecentSearchButtonTitle": "从搜索历史中移除",
"favoriteSearchesTitle": "收藏",
"removeFavoriteSearchButtonTitle": "从收藏中移除"
},
"errorScreen": {
"titleText": "无法获取结果",
"helpText": "你可能需要检查你的网络连接"
},
"footer": {
"selectText": "选择",
"navigateText": "切换",
"closeText": "关闭",
"searchByText": ""
},
"noResultsScreen": {
"noResultsText": "无法找到相关结果",
"suggestedQueryText": "你可以尝试查询",
"reportMissingResultsText": "你认为该查询应该有结果?",
"reportMissingResultsLinkText": "点击反馈"
}
}
}
}
}
}
},
"socialLinks": [],
"returnToTopLabel": "返回顶部",
"lastUpdated": {
"text": "最后更新于",
"formatOptions": {
"dateStyle": "short",
"timeStyle": "medium"
}
},
"docFooter": {
"prev": "上一页",
"next": "下一页"
},
"sidebar": {
"/examples/": {
"base": "/examples/",
"items": [
{
"text": "VitePress自带示例",
"link": "docexamples/docexamples",
"items": [
{
"text": "Markdown Extension Examples",
"link": "docexamples/markdown-examples"
},
{
"text": "Runtime API Examples",
"link": "docexamples/api-examples"
},
{
"text": "测试用1",
"link": "docexamples/test"
}
],
"collapsed": true
}
]
}
}
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "examples/docexamples/api-examples.md",
"filePath": "examples/docexamples/api-examples.md",
"lastUpdated": 1743578157000
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.
