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"
},
"logo": "/liuming.png",
"nav": [
{
"text": "Back to FranJ2",
"link": "https://franj2.com/"
},
{
"text": "test",
"link": "https://bot-manual.commspt.franj2.com/"
},
{
"text": "test",
"link": "https://afdian.com/a/tnqzh123"
}
],
"docFooter": {
"prev": "Previous",
"next": "Next"
},
"langMenuLabel": "Languages",
"returnToTopLabel": "Return to top",
"sidebarMenuLabel": "Menu",
"darkModeSwitchLabel": "Appearance",
"lightModeSwitchTitle": "Switch to light mode",
"darkModeSwitchTitle": "Switch to dark mode",
"externalLinkIcon": true,
"lastUpdated": {
"text": "Last updated"
},
"outline": {
"label": "On this page"
},
"editLink": {
"pattern": "https://github.com/RankFrank4010/Liuming_Manual",
"text": "Help us improve this page"
},
"sidebar": {
"/en/": [
{
"text": "LiuMing Docs",
"link": "/en/"
},
{
"text": "Community Rules",
"collapsed": false,
"items": [
{
"text": "Terms of Service",
"link": "/en/policies/tos"
},
{
"text": "Privacy Policy",
"link": "/en/policies/privacy"
}
]
},
{
"text": "Operation Guide",
"collapsed": false,
"items": []
},
{
"text": "Academic Standards",
"collapsed": false,
"items": []
}
]
},
"footer": {
"copyright": "Copyright © 2023-present FranJ2 | 京ICP备12345678号 | 京公网安备11010802012345号"
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/LittleSkinChina/manual-ng"
}
]
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "en/api-examples.md",
"filePath": "en/api-examples.md",
"lastUpdated": 1786263178000
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.
