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
{ "search": { "provider": "local" }, "nav": [ { "text": "Главная", "link": "/" }, { "text": "Frontend", "link": "/frontend/introduction" }, { "text": "Examples", "link": "/examples/" } ], "sidebar": [ { "text": "Готовые решения", "collapsable": true, "collapsed": true, "items": [ { "text": "Лучшие практики Frontend", "link": "/frontend/introduction", "collapsable": true, "collapsed": true, "items": [ { "text": "Модальные окна", "link": "/frontend/modals" }, { "text": "Анимации модальных окон", "link": "/frontend/modals-animate" }, { "text": "Scoped Slots Vue", "link": "/frontend/vue-slots" } ] }, { "text": "Настройка сервера", "link": "/server/intro", "collapsable": true, "collapsed": true, "items": [ { "text": "Установка docker", "link": "/server/docker-install" }, { "text": "Настройка SSH Key", "link": "/server/ssh-key" }, { "text": "Настройка Nginx", "link": "/server/nginx" }, { "text": "Настройка домена", "link": "/server/domain" }, { "text": "Настройка CI/CD", "link": "/server/ci-cd" }, { "text": "Настройка SSL", "link": "/server/ssl" }, { "text": "Настройка безопасности", "link": "/server/secure" } ] }, { "text": "Linux команды", "link": "/linux/intro", "collapsable": true, "collapsed": true, "items": [ { "text": "Работа с ENV", "link": "/linux/env" }, { "text": "Файловая иерархия", "link": "/linux/file-system" }, { "text": "Работа с файлами", "link": "/linux/command" }, { "text": "Пользователи", "link": "/linux/users" }, { "text": "Установка Arch Linux", "link": "/linux/install-arch" } ] } ] }, { "text": "CI/CD", "collapsable": false, "collapsed": true, "items": [ { "text": "Введение", "link": "/ci-cd/intro" }, { "text": "Глоссарий", "link": "/ci-cd/glossary" } ] }, { "text": "Углубленные практики", "collapsable": false, "collapsed": true, "items": [ { "text": "Слоты", "link": "/advanced/slots" }, { "text": "Асинхронное поведение", "link": "/advanced/async" }, { "text": "HTTP запросы", "link": "/advanced/http-request" }, { "text": "Анимация", "link": "/advanced/transitions" }, { "text": "Экземпляр комопнента", "link": "/advanced/component-instance" }, { "text": "Повторное использование", "link": "/advanced/composition" }, { "text": "Тестирование v-model", "link": "/advanced/v-model" }, { "text": "Тестирование vuex", "link": "/advanced/vuex" }, { "text": "Тестирование vue-router", "link": "/advanced/vue-router" }, { "text": "Тестирование teleport", "link": "/advanced/teleport" }, { "text": "Stubs и shallowMount", "link": "/advanced/stubs-shallow-mount" }, { "text": "Тестирование SSR", "link": "/advanced/ssr" } ] }, { "text": "Расширения VTU", "items": [ { "text": "Плагины", "link": "/extending-vtu/plugins" } ] }, { "text": "Пример оформления", "items": [ { "text": "Markdown Examples", "link": "/preview/markdown-examples" }, { "text": "Runtime API Examples", "link": "/preview/api-examples" } ] }, { "collapsable": false, "items": [ { "text": "API", "link": "/api/" } ] } ], "socialLinks": [ { "icon": "github", "link": "https://github.com/vuejs/vitepress" } ] }
Page Data
{ "title": "Runtime API Examples", "description": "", "frontmatter": { "outline": "deep" }, "headers": [], "relativePath": "preview/api-examples.md", "filePath": "preview/api-examples.md" }
Page Frontmatter
{ "outline": "deep" }
More
Check out the documentation for the full list of runtime APIs.