Dev
This page demonstrates usage of some of the runtime APIs provided by VitePress. lol
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": "MD Examples", "link": "/markdown-examples" } ], "editLink": { "pattern": "https://github.com/bauhaas/notes/edit/main/docs/:path", "text": "Edit this page on GitHub" }, "sidebar": [ { "text": "API Examples", "link": "/api-examples" }, { "text": "Cooking", "link": "/cooking/", "items": [ { "text": "Recipes", "items": [ { "text": "French", "items": [ { "text": "Dessert", "items": [ { "text": "Crêpes", "link": "/cooking/recipes/french/dessert/crepes" } ], "collapsed": true } ], "collapsed": true } ], "collapsed": false } ], "collapsed": false }, { "text": "Dev", "link": "/dev/", "items": [ { "text": "Databases", "link": "/dev/databases/", "items": [ { "text": "Postgres", "link": "/dev/databases/postgres" } ], "collapsed": false }, { "text": "People to follow", "link": "/dev/people_to_follow" }, { "text": "Programming Languages", "link": "/dev/programming_languages/", "items": [ { "text": "Javascript", "link": "/dev/programming_languages/javascript/", "items": [ { "text": "ES Lint", "link": "/dev/programming_languages/javascript/eslint" }, { "text": "JS frameworks", "link": "/dev/programming_languages/javascript/js_frameworks/", "items": [ { "text": "NestJS", "link": "/dev/programming_languages/javascript/js_frameworks/nestjs" }, { "text": "VitePress", "link": "/dev/programming_languages/javascript/js_frameworks/vitepress" } ], "collapsed": true }, { "text": "JS libraries", "link": "/dev/programming_languages/javascript/js_libraries/", "items": [ { "text": "ReactJS", "link": "/dev/programming_languages/javascript/js_libraries/reactjs" } ], "collapsed": true }, { "text": "Package Managers", "link": "/dev/programming_languages/javascript/package_managers" } ], "collapsed": true } ], "collapsed": false }, { "text": "Side_projects", "items": [ { "text": "Cornucopia", "link": "/dev/side_projects/cornucopia" } ], "collapsed": false }, { "text": "Tools", "items": [ { "text": "Peek", "link": "/dev/tools/peek" }, { "text": "VS Code", "link": "/dev/tools/vs_code" } ], "collapsed": false }, { "text": "Work Process", "link": "/dev/work_process/", "items": [ { "text": "Code Review", "link": "/dev/work_process/code_review" } ], "collapsed": false } ], "collapsed": false }, { "text": "Markdown Extension Examples", "link": "/markdown-examples" } ], "footer": { "message": "Made with ❤️ by Baudoin Haas", "copyright": "Copyright © 2024-present Baudoin Haas" }, "socialLinks": [ { "icon": "github", "link": "https://github.com/bauhaas" }, { "icon": "twitter", "link": "https://twitter.com/BaudoinHaas" } ], "externalLinkIcon": true, "search": { "provider": "local" } }
Page Data
{ "title": "Dev", "description": "", "frontmatter": { "layout": "doc", "outline": "deep", "title": "Dev" }, "headers": [], "relativePath": "dev/index.md", "filePath": "dev/index.md", "lastUpdated": 1706883544000 }
Page Frontmatter
{ "layout": "doc", "outline": "deep", "title": "Dev" }
More
Check out the documentation for the full list of runtime APIs.