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": "Home", "link": "/" }, { "text": "Description", "link": "/features" }, { "text": "Contacts", "link": "/contacts" } ], "logo": "app_logo_play.png", "sidebar": [ { "text": "For whoms", "items": [ { "text": "Target audience", "link": "/target-audience" }, { "text": "Personal usage", "link": "/personal-use" }, { "text": "Group usage", "link": "/groupe-use" }, { "text": "Motivation", "link": "/motivation" } ] }, { "text": "Market", "items": [ { "text": "Market usage", "link": "/market-usage" } ] }, { "text": "Project state", "items": [ { "text": "State of application", "link": "/project-state" }, { "text": "Features of application", "link": "/features" }, { "text": "RoadMap of application", "link": "/roadmap" }, { "text": "Sibscribe news", "link": "/subscribe" } ] }, { "text": "Team", "items": [ { "text": "Team members", "link": "/team-members" } ] }, { "text": "Investment", "items": [ { "text": "For investors", "link": "/project-investing" }, { "text": "Make investment", "link": "/make-investment" } ] }, { "text": "Contacts", "items": [ { "text": "Contacts", "link": "/contacts" }, { "text": "Meeting", "link": "/meeting" } ] } ], "footer": { "message": "The entire code base is owned by Andrey MK under copyright law. Law of Ukraine on December 1, 2022 № 2811-IX", "copyright": "Copyright © 2014-present <a href=\"https://github.com/andim27\" target=\"_blank\">Andrey MK</a>" }, "socialLinks": [ { "icon": "github", "link": "https://github.com/andim27/ema-deals-com" } ] }
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.