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.svg",
"siteTitle": "Wink",
"search": {
"provider": "local"
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/vuejs/vitepress"
}
],
"nav": [
{
"text": "Home",
"link": "/"
},
{
"text": "Manual",
"link": "/manual/introduction"
}
],
"sidebar": {
"/manual/": [
{
"text": "Getting Started",
"items": [
{
"text": "Introduction",
"link": "/manual/introduction"
},
{
"text": "First Steps & Access",
"link": "/manual/getting-started"
},
{
"text": "Interface Overview",
"link": "/manual/interface"
}
]
},
{
"text": "Managing Content",
"items": [
{
"text": "Register Wink Player",
"link": "/manual/register-player"
},
{
"text": "Upload Files",
"link": "/manual/upload-files"
},
{
"text": "Create Playlists",
"link": "/manual/playlists"
},
{
"text": "Apps",
"link": "/manual/apps"
},
{
"text": "Layouts",
"link": "/manual/layouts"
}
]
},
{
"text": "Schedule",
"items": [
{
"text": "Schedule Playlists",
"link": "/manual/schedule-playlists"
},
{
"text": "Schedule Brightness",
"link": "/manual/schedule-brightness"
},
{
"text": "Schedule Power",
"link": "/manual/schedule-power"
},
{
"text": "Schedule Volume",
"link": "/manual/schedule-volume"
},
{
"text": "Schedule Files",
"link": "/manual/schedule-files"
}
]
}
]
}
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "api-examples.md",
"filePath": "api-examples.md"
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.