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": { "light": "/branding/unately/text-vector.svg", "dark": "/branding/unately/text-vector.svg" }, "search": { "provider": "local", "options": { "detailedView": "auto", "locales": { "root": { "translations": { "button": { "buttonAriaLabel": "Suchen", "buttonText": "Suchen" }, "modal": { "displayDetails": "Details anzeigen", "noResultsText": "Keine Ergebnisse gefunden für", "resetButtonTitle": "Zurücksetzen", "backButtonTitle": "Zurück", "footer": { "closeKeyAriaLabel": "Schließen", "closeText": "Schließen", "navigateDownKeyAriaLabel": "Nach unten navigieren", "navigateText": "Navigieren", "navigateUpKeyAriaLabel": "Nach oben navigieren", "selectKeyAriaLabel": "Auswählen", "selectText": "Auswählen" } } } } } } }, "siteTitle": false, "nav": [ { "text": "Home", "link": "/" }, { "text": "Beispiele", "link": "/examples" }, { "text": "Services", "link": "/services/index" }, { "text": "Projekte", "items": [ { "text": "Open Source", "items": [ { "text": "uBingo", "link": "/oss/ubingo/about" }, { "text": "uPackages ⚠️", "link": "/oss/upackages" } ] }, { "text": "Projects", "items": [ { "text": "zentra.", "link": "/projects/zentra" } ] } ] }, { "text": "Kontakt", "link": "/contact" } ], "outline": { "level": "deep" }, "footer": { "message": "<a href=\"/legal/imprint\">Impressum</a> | <a href=\"/legal/privacy\">Datenschutzerklärung</a> | <a style=\"cursor: pointer;\" data-cc=\"show-preferencesModal\">Cookie Einstellungen</a> | <a href=\"/contact\">Kontakt</a>", "copyright": "Copyright © 2020-heute | Made in Germany 🇩🇪" }, "sidebar": { "/docs/": { "base": "/docs/", "items": [ { "text": "Markdown Examples", "link": "/examples" }, { "text": "Runtime API Examples", "link": "/api-examples" } ] }, "/oss/ubingo/": { "base": "/oss/ubingo/", "items": [ { "text": "Introduction", "collapsed": false, "items": [ { "text": "What is uBingo?", "link": "about" } ] }, { "text": "Modpack", "collapsed": false, "items": [ { "text": "Installation", "link": "modpack/installation" }, { "text": "Extra Mods", "link": "modpack/extramods" } ] }, { "text": "Server", "collapsed": false, "items": [ { "text": "Pre-Install", "link": "server/preinstall" }, { "text": "Installation", "items": [ { "text": "On Bare Metal", "link": "server/bare" }, { "text": "On Docker", "link": "server/docker" } ] }, { "text": "Configuration", "link": "server/config" }, { "text": "Help", "items": [ { "text": "Run Anyway", "link": "server/runanyway" }, { "text": "On Pterodactyl", "link": "server/pterodactyl" } ] } ] } ] }, "/services/pos/features/": { "base": "/services/pos/features/", "items": [ { "text": "Einführung", "link": "about" }, { "text": "Registrierkasse", "link": "registers" } ] } }, "socialLinks": [ { "icon": "github", "link": "https://github.com/unately" }, { "icon": "x", "link": "https://x.com/unatelystudios" } ] }
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.