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": "Главная",
"link": "/"
},
{
"text": "Locarus Server",
"link": "/server/"
}
],
"sidebar": [
{
"text": "Начало работы",
"items": [
{
"text": "Главная",
"link": "/"
},
{
"text": "Markdown Examples",
"link": "/markdown-examples"
},
{
"text": "Runtime API Examples",
"link": "/api-examples"
}
]
},
{
"text": "Locarus Server",
"items": [
{
"text": "Главная",
"link": "/server/index"
},
{
"text": "Информация",
"link": "/server/info"
}
]
}
],
"darkModeSwitchLabel": "Оформление",
"lightModeSwitchTitle": "Переключить на светлую тему",
"darkModeSwitchTitle": "Переключить на темную тему",
"sidebarMenuLabel": "Меню",
"returnToTopLabel": "Наверх",
"langMenuLabel": "Сменить язык",
"outline": {
"label": "На этой странице"
},
"docFooter": {
"prev": "Предыдущая страница",
"next": "Следующая страница"
},
"logo": "/assets/brand/logo/locarus.svg",
"siteTitle": "Locarus Docs",
"socialLinks": [
{
"icon": {
"svg": "<svg role=\"img\" viewBox=\"0 0 511.99 511.99\" xmlns=\"http://www.w3.org/2000/svg\"><title>Locarus</title><path fill=\"currentColor\" d=\"M511.99,230.37v21.34c-1.08,6.15-2.69,12.12-5.74,17.76-8.07,15.37-21.88,22.19-39.01,24.33-7.53,1.02-15.25,.26-22.69,1.71-3.23,.68-6.37,1.54-9.24,3.16-.81,.43-1.7,.94-1.52,1.88,.18,1.02,1.35,.94,2.24,1.02h.9c9.69-2.99,19.55-.34,29.33-.68,3.05,0,5.92-.68,8.88-1.2,4.22-.77,5.47,.26,5.74,4.27,.18,1.71,.27,3.41-.09,5.12-4.3,16.47-13,29.79-30.31,36.53-3.77,1.39-7.79,2.09-11.84,2.05-7.8,0-15.52-.68-23.32,.77-.9,.17-2.06,.26-3.05,.6-1.61,.51-4.3,.6-3.86,2.56s2.87,.68,4.3,.6c5.92-.51,11.66,.43,17.4,1.11,1.79,.17,3.59,.34,5.38,.09,5.74-.6,7.71,1.45,6.28,7-2.69,11.01-8.97,19.63-19.1,25.78-10.76,6.57-22.96,8.54-35.42,9.13-8.07,.43-16.14,0-24.21,.09-1.79,0-3.95-.34-5.38,1.37,0,.6,.27,1.02,.72,1.02,6.73,0,13.09,2.65,19.82,2.99,4.48,.26,5.83,2.22,4.13,6.23-2.78,5.9-7.5,10.78-13.45,13.91-7.71,4.44-16.23,7.09-24.75,9.82-15.69,5.12-31.39,10.16-46.55,16.65-2.69,1.2-6.01,2.99-8.7,.26-2.42-2.56-1.17-5.72,0-8.54,5.02-11.68,10.5-23.19,16.41-34.49,.9-1.96,2.06-3.84,2.42-5.98,.18-1.54-.18-2.82-1.52-3.76-1.43-.94-2.87-.6-4.3,0-2.69,1.28-4.22,3.59-5.38,6.06-6.46,12.63-10.76,25.86-14.98,39.27-6.73,21.68-12.73,43.53-17.94,65.56-.72,2.82-1.79,5.46-5.38,6.23h-4.48c-3.86-1.2-4.66-4.52-5.38-7.68-3.05-13.74-6.82-27.32-10.58-40.97-5.14-19.3-11.48-38.28-19.01-56.85-1.35-3.64-3.42-7-6.1-9.9-1.79-1.79-3.86-3.5-6.64-1.71-2.51,1.71-1.52,4.01-.54,6.15,5.38,10.84,10.58,21.6,15.69,32.52,1.17,2.56,2.06,5.12,3.05,7.6,1.08,2.39,1.26,4.69-.99,6.66-2.15,1.71-4.48,1.28-6.73,.26-6.82-2.99-13.81-5.55-20.81-8.02-11.48-4.1-22.96-7.94-34.62-11.61-7.3-2.22-14.24-5.38-20.63-9.39-4.48-2.82-7.62-6.66-9.87-11.27-2.42-4.61-1.26-6.57,4.13-7,6.28-.51,12.29-2.13,18.56-2.82,.45,0,.81-.26,1.17-.94-1.08-1.88-3.14-1.54-4.84-1.62h-20.63c-10.21,.07-20.35-1.57-29.95-4.87-14.67-4.57-25.61-16.32-28.61-30.73-1.17-5.21,.54-7,6.01-6.32,2.69,.26,5.11-.09,7.62-.43,6.82-1.01,13.76-1.18,20.63-.51-1.43-3.16-3.86-3.41-6.01-3.84-6.37-1.28-12.82-1.11-19.19-1.11-24.95,.86-46.2-17.12-48.25-40.8-.63-6.83,.9-8.11,8.07-6.57,5.44,1.03,11.02,1.18,16.5,.43,6.06-.88,12.24-.65,18.21,.68,1.52,.17,3.77,1.02,4.3-.85,.63-1.71-1.79-2.22-3.23-2.82-5.12-2.01-10.61-3.03-16.14-2.99-6.64,.09-13.18-.43-19.55-1.71-22.33-4.44-35.69-18.78-38.83-41.32-.18-.85,.18-1.71-.54-2.48v-17.07c1.08-4.1,.99-8.45,3.05-12.29,1.97-3.59,4.04-4.44,7.08-1.96,12.73,10.24,27.89,15.71,43.41,20.66,3.77,1.28,7.53,2.82,11.21,4.27,1.08,.51,2.51,1.11,3.23-.09,.9-1.54-.63-2.39-1.79-2.9-3.95-1.71-7.8-3.59-11.57-5.63-15.05-7.5-27.74-18.66-36.77-32.35-11.94-19.11-14.37-42.27-6.64-63.25,4.28-12.45,10.15-24.35,17.49-35.43,.72-1.11,1.52-2.13,2.6-2.9,3.59-2.82,6.37-2.39,8.88,1.37,.9,1.37,1.26,2.9,1.79,4.35,4.84,15.79,13,29.88,24.57,42.17l.54,.68c1.43,1.11,2.87,3.16,4.93,1.96,2.15-1.28,.9-3.41,.09-5.04-5.88-11.49-10.56-23.5-13.99-35.85-6.01-24.75-2.96-47.8,12.91-68.72,8.14-10.18,17.88-19.1,28.88-26.46,6.37-4.52,13.27-8.28,19.91-12.38,2.06-1.37,4.48-1.2,6.64-2.3h7.17c2.96,2.99,1.61,6.15,0,9.05-2.42,4.27-4.66,8.62-6.73,13.06-7.82,16.34-11.83,34.11-11.75,52.07,.26,18.11,4.6,35.95,12.73,52.33,11.48,23.73,27.8,44.05,46.9,62.57,8.83,8.66,18.07,16.92,27.71,24.75,8.43,6.83,9.87,14.77,4.66,24.07-3.05,5.46-7.17,10.16-10.76,15.28-7.81,10.86-12.34,23.56-13.09,36.71-.54,17.16,5.2,32.44,17.04,45.5,7.96,8.98,18.3,15.76,29.95,19.63,1.7,.51,3.32,1.2,5.2,1.28,4.48,.26,7-1.96,7.17-6.23,.18-4.01-1.7-7.43-3.41-10.93-3.59-7-5.02-14.17-2.15-21.85,4.13-10.5,11.57-15.11,22.78-13.66,8.34,1.11,15.69,9.65,16.41,19.04,.54,5.89-.63,11.35-3.32,16.56-1.57,2.62-2.75,5.44-3.5,8.37-1.35,6.57,2.87,10.24,9.6,8.37,36.95-10.74,57.75-47.96,46.46-83.13-1.85-5.75-4.5-11.24-7.9-16.32-3.77-5.8-8.07-11.27-11.75-17.07-6.28-10.16-5.38-16.22,3.14-24.41,6.28-5.98,13.18-11.44,19.73-17.24,8.52-7.43,15.87-15.88,23.32-24.16,10.04-11.01,18.83-22.88,26.1-35.6,9.41-15.74,15.5-33.08,17.94-51.05,2.96-25.1-2.24-48.66-13.99-71.11-1.43-2.73-3.14-5.46-4.22-8.45-1.08-2.82-1.35-5.63,2.15-7.34h5.38c11.21,3.41,20.36,9.99,29.51,16.56,11.75,8.62,22.24,18.44,30.22,30.56,12.2,18.69,13.63,38.84,9.51,59.67-2.68,12.55-7.21,24.68-13.45,36.02-.9,1.71-1.7,3.41-2.06,5.12-.27,1.2-.45,2.39,.9,3.07,.9,.6,1.97,0,2.87-.51,12.81-12.43,22.2-27.68,27.35-44.39,.9-3.24,1.79-7.17,6.01-7.68,4.13-.34,6.28,2.99,8.07,5.98,9.33,15.19,17.67,30.73,20,48.49,3.87,22.75-3.89,45.9-20.9,62.31-10.26,9.74-22.18,17.77-35.25,23.73-1.61,.85-5.02,1.2-3.86,3.67,.99,1.88,3.59-.09,5.2-.85,9.6-3.84,19.73-6.57,29.33-10.41,8.07-3.24,15.25-7.77,22.06-12.97,4.39-3.41,5.83-2.99,8.25,1.79,1.7,3.33,1.43,6.91,2.69,10.24l.09-.09,.03-.03Z\"/></svg>"
},
"link": "https://locarus.ru"
},
{
"icon": {
"svg": "<svg role=\"img\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><title>VK</title><path d=\"m9.489.004.729-.003h3.564l.73.003.914.01.433.007.418.011.403.014.388.016.374.021.36.025.345.03.333.033c1.74.196 2.933.616 3.833 1.516.9.9 1.32 2.092 1.516 3.833l.034.333.029.346.025.36.02.373.025.588.012.41.013.644.009.915.004.98-.001 3.313-.003.73-.01.914-.007.433-.011.418-.014.403-.016.388-.021.374-.025.36-.03.345-.033.333c-.196 1.74-.616 2.933-1.516 3.833-.9.9-2.092 1.32-3.833 1.516l-.333.034-.346.029-.36.025-.373.02-.588.025-.41.012-.644.013-.915.009-.98.004-3.313-.001-.73-.003-.914-.01-.433-.007-.418-.011-.403-.014-.388-.016-.374-.021-.36-.025-.345-.03-.333-.033c-1.74-.196-2.933-.616-3.833-1.516-.9-.9-1.32-2.092-1.516-3.833l-.034-.333-.029-.346-.025-.36-.02-.373-.025-.588-.012-.41-.013-.644-.009-.915-.004-.98.001-3.313.003-.73.01-.914.007-.433.011-.418.014-.403.016-.388.021-.374.025-.36.03-.345.033-.333c.196-1.74.616-2.933 1.516-3.833.9-.9 2.092-1.32 3.833-1.516l.333-.034.346-.029.36-.025.373-.02.588-.025.41-.012.644-.013.915-.009ZM6.79 7.3H4.05c.13 6.24 3.25 9.99 8.72 9.99h.31v-3.57c2.01.2 3.53 1.67 4.14 3.57h2.84c-.78-2.84-2.83-4.41-4.11-5.01 1.28-.74 3.08-2.54 3.51-4.98h-2.58c-.56 1.98-2.22 3.78-3.8 3.95V7.3H10.5v6.92c-1.6-.4-3.62-2.34-3.71-6.92Z\"/></svg>"
},
"link": "https://vk.com/locarus"
},
{
"icon": {
"svg": "<svg role=\"img\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><title>Telegram</title><path d=\"M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z\"/></svg>"
},
"link": "https://t.me/LocarusNews"
}
]
}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.