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": "DLUX", "link": "/dlux" }, { "text": "SPK", "link": "/spk" }, { "text": "Honeycomb", "link": "/honeycomb" }, { "text": "1.2.0", "items": [ { "text": "Changelog", "link": "/changelog" }, { "text": "Contributing", "link": "/contributing" } ] } ], "sidebar": { "/": [ { "text": "Example", "items": [ { "text": "Markdown Examples", "link": "/markdown-examples" }, { "text": "Runtime API Examples", "link": "/api-examples" } ] }, { "text": "1.2.0", "items": [ { "text": "Changelog", "link": "/changelog" }, { "text": "Contributing", "link": "/contributing" } ] } ], "/dlux/": [ { "text": "Getting Started", "items": [ { "text": "Glitch Quickstart", "link": "/dlux/glitch-quickstart" }, { "text": "DLUX Builder", "link": "/dlux/dlux-builder" }, { "text": "A-Frame Inspector", "link": "/dlux/a-frame-inspector" } ] }, { "text": "Assets", "items": [ { "text": "Add Asset", "link": "/dlux/assets" }, { "text": "3D Models", "link": "/dlux/3d-models" }, { "text": "Images", "link": "/dlux/images" }, { "text": "Text", "link": "/dlux/text" }, { "text": "Shapes", "link": "/dlux/shapes" }, { "text": "Audio", "link": "/dlux/audio" }, { "text": "Video", "link": "/dlux/video" } ] }, { "text": "Components", "items": [ { "text": "Web XR", "link": "/dlux/webxr" }, { "text": "Environment", "link": "/dlux/environment" }, { "text": "Physics", "link": "/dlux/physics" }, { "text": "Navmesh", "link": "/dlux/navmesh" }, { "text": "Player Rig", "link": "/dlux/player-rig" }, { "text": "Controls", "link": "/dlux/controls" }, { "text": "AR Marker", "link": "/dlux/ar-marker" }, { "text": "AR Markerless", "link": "/dlux/ar-marker-less" }, { "text": "UI Overlay", "link": "/dlux/ui-overlay" }, { "text": "2D dApps", "link": "/dlux/2d-dapps" } ] }, { "text": "Integrations", "items": [ { "text": "DLUX API", "link": "/dlux/dlux-api" }, { "text": "HIVE Blockchain", "link": "/dlux/hive" } ] } ], "/spk/": [ { "text": "SPK", "items": [ { "text": "Services", "link": "/spk/services" }, { "text": "Storage", "link": "/spk/storage" }, { "text": "Trole", "link": "/spk/trole" }, { "text": "Proof of Access", "link": "/spk/poa" } ] } ], "/honeycomb/": [ { "text": "Honeycomb", "items": [ { "text": "DEX", "link": "/honeycomb/dex" }, { "text": "New Token", "link": "/honeycomb/new-token" }, { "text": "New Node", "link": "/honeycomb/new-node" }, { "text": "Node Voting", "link": "/honeycomb/node-voting" }, { "text": "Token Actions", "link": "/honeycomb/token-actions" } ] } ] }, "socialLinks": [ { "icon": "github", "link": "https://github.com/disregardfiat/honeycomb" } ] }
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.