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": "首页",
"link": "/"
},
{
"text": "下载",
"link": "https://github.com/Orange-Icepop/LSL/releases"
},
{
"text": "Examples",
"link": "/markdown-examples"
}
],
"sidebar": [
{
"text": "Examples",
"items": [
{
"text": "Markdown Examples",
"link": "/markdown-examples"
},
{
"text": "Runtime API Examples",
"link": "/api-examples"
}
]
}
],
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/Orange-Icepop/LSL"
}
],
"externalLinkIcon": false,
"i18nRouting": true,
"logo": "\\images\\logo.png",
"outline": {
"level": 2,
"label": "On this page"
},
"search": {
"provider": "local",
"options": {
"appId": "",
"apiKey": "",
"indexName": "",
"locales": {
"zh": {
"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": "点击反馈"
}
}
}
},
"en": {
"placeholder": "Search docs",
"translations": {
"button": {
"buttonText": "Search docs",
"buttonAriaLabel": "Search docs"
},
"modal": {
"searchBox": {
"resetButtonTitle": "Clear query",
"resetButtonAriaLabel": "Clear query",
"cancelButtonText": "Cancel",
"cancelButtonAriaLabel": "Cancel"
},
"startScreen": {
"recentSearchesTitle": "Recent searches",
"noRecentSearchesText": "No recent searches",
"saveRecentSearchButtonTitle": "Save search",
"removeRecentSearchButtonTitle": "Remove search",
"favoriteSearchesTitle": "Favorites",
"removeFavoriteSearchButtonTitle": "Remove from favorites"
},
"errorScreen": {
"titleText": "Unable to fetch results",
"helpText": "You may want to check your network connection"
},
"footer": {
"selectText": "select",
"navigateText": "navigate",
"closeText": "close",
"searchByText": "Search by"
},
"noResultsScreen": {
"noResultsText": "No results for",
"suggestedQueryText": "You can try searching for",
"reportMissingResultsText": "You think it should have results?",
"reportMissingResultsLinkText": "Click here to report it"
}
}
}
}
}
}
},
"langMenuLabel": "多语言",
"returnToTopLabel": "回到顶部",
"sidebarMenuLabel": "菜单",
"darkModeSwitchLabel": "主题",
"lightModeSwitchTitle": "切换到浅色模式",
"darkModeSwitchTitle": "切换到深色模式",
"editLink": {
"text": "Edit this page on GitHub",
"pattern": "https://github.com/zhangdi168/VitePressSimple/edit/main/docs/:path"
},
"docFooter": {
"prev": "Previous page",
"next": "Next Page"
},
"siteTitle": "Lime Server Launcher",
"footer": {
"message": "",
"copyright": "版权所有 © 2025 橙子冰棒"
}
}Page Data
{
"title": "api-examples",
"description": "",
"frontmatter": {
"outline": [
1,
3
],
"title": "api-examples",
"description": "",
"navbar": true,
"sideBar": true,
"footer": false,
"editLink": false,
"lastUpdated": true,
"aside": "right",
"layout": "doc",
"custom": {},
"hero": {
"image": {
"src": "",
"alt": "",
"width": "",
"height": ""
},
"name": "VitePressSimple",
"text": "quick to config vitePress",
"description": "",
"tagline": "",
"actions": [],
"features": [],
"head": []
}
},
"headers": [],
"relativePath": "api-examples.md",
"filePath": "api-examples.md"
}Page Frontmatter
{
"outline": [
1,
3
],
"title": "api-examples",
"description": "",
"navbar": true,
"sideBar": true,
"footer": false,
"editLink": false,
"lastUpdated": true,
"aside": "right",
"layout": "doc",
"custom": {},
"hero": {
"image": {
"src": "",
"alt": "",
"width": "",
"height": ""
},
"name": "VitePressSimple",
"text": "quick to config vitePress",
"description": "",
"tagline": "",
"actions": [],
"features": [],
"head": []
}
}More
Check out the documentation for the full list of runtime APIs.
