Preamble
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": "/favicon.svg",
"sidebar": [
{
"text": "Posts",
"items": [
{
"text": "Dec 20, 2024 · A peek into the world of microVMs.",
"link": "/posts/microvm/"
},
{
"text": "Dec 27, 2024 · Revisiting GitHub Actions on nixfiles.",
"link": "/posts/github-actions-nixfiles/"
}
]
},
{
"text": "About",
"items": [
{
"text": "Preamble",
"link": "/about/preamble"
},
{
"text": "About me",
"link": "/about/me"
}
]
}
],
"socialLinks": [
{
"icon": "linkedin",
"link": "https://linkedin.com/in/usertam"
},
{
"icon": "github",
"link": "https://github.com/usertam"
}
],
"footer": {
"copyright": "Copyright © 2024 Samuel Tam"
},
"editLink": {
"pattern": "https://github.com/usertam/blog/edit/master/:path",
"text": "Edit this page on GitHub"
}
}Page Data
{
"title": "Preamble",
"description": "",
"frontmatter": {
"title": "Preamble",
"outline": "deep",
"prev": false,
"next": {
"text": "About me",
"link": "/about/me"
}
},
"headers": [],
"relativePath": "about/preamble.md",
"filePath": "about/preamble.md",
"lastUpdated": 1735253078000
}Page Frontmatter
{
"title": "Preamble",
"outline": "deep",
"prev": false,
"next": {
"text": "About me",
"link": "/about/me"
}
}More
Check out the documentation for the full list of runtime APIs.