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": "/manjarodocs_logo.svg",
"nav": [
{
"text": "Home",
"link": "/"
},
{
"text": "Examples",
"link": "/markdown-examples"
}
],
"sidebar": [
{
"text": "Documentation",
"items": [
{
"text": "Switching branches",
"link": "/switching-branches"
}
]
},
{
"text": "VitePress examples",
"items": [
{
"text": "Markdown Examples",
"link": "/markdown-examples"
},
{
"text": "Runtime API Examples",
"link": "/api-examples"
}
]
}
],
"socialLinks": [
{
"icon": {
"svg": "<svg height=\"800px\" width=\"800px\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" xml:space=\"preserve\"><circle style=\"fill:#2196f3\" cx=\"256\" cy=\"256\" r=\"244.494\"/><path style=\"fill:#231f20\" d=\"M512 256c0-68.38-26.63-132.668-74.981-181.019C388.668 26.629 324.38 0 256 0 187.619 0 123.332 26.629 74.98 74.981 26.629 123.332 0 187.62 0 256s26.629 132.668 74.981 181.02C123.332 485.371 187.619 512 256 512c68.38 0 132.668-26.629 181.019-74.98C485.37 388.668 512 324.38 512 256zm-40.091 87.53c-19.928-18.858-45.447-32.163-73.256-41.424a459.156 459.156 0 0 0 2.31-46.11c0-15.627-.788-31.041-2.31-46.105 27.808-9.262 53.326-22.568 73.253-41.428 11.004 27.041 17.084 56.59 17.084 87.537-.001 30.944-6.08 60.491-17.081 87.53zm-337.865-87.533c0-13.405.605-26.63 1.778-39.577 36.192 9.092 74.607 12.428 108.671 13.017v53.127c-34.062.589-72.477 3.926-108.671 13.015a439.054 439.054 0 0 1-1.778-39.582zm110.448 231.926c-27.028-4.988-52.52-27.467-72.765-64.557-.366-.67-.72-1.354-1.082-2.031 23.512-16.669 48.395-26.35 73.846-28.595v95.183zm23.011-95.181c25.452 2.244 50.336 11.923 73.846 28.593-.361.678-.717 1.362-1.083 2.033-20.244 37.088-45.737 59.569-72.764 64.557l.001-95.183zm0-368.673c27.027 4.988 52.52 27.469 72.764 64.557.366.67.72 1.353 1.082 2.03-23.508 16.669-48.391 26.35-73.845 28.593l-.001-95.18zm-23.011 95.179c-25.452-2.245-50.336-11.927-73.844-28.596.36-.675.715-1.358 1.079-2.026 20.245-37.088 45.737-59.569 72.765-64.557v95.179zm23.011 23.082c29.093-2.161 57.341-12.516 83.846-30.581 10.24 24.369 17.697 51.963 22.064 81.453-30.339 7.986-65.981 12.485-105.91 13.207V142.33zm92.103-66.279c-8.943-16.111-18.913-29.839-29.674-41.011a232.058 232.058 0 0 1 48.15 22.598c-6.026 6.661-12.192 12.795-18.476 18.413zm-207.215-.003c-6.283-5.617-12.448-11.75-18.472-18.408a232.09 232.09 0 0 1 48.142-22.596c-10.761 11.169-20.728 24.896-29.67 41.004zm92.101 66.282v64.079c-39.929-.723-75.572-5.221-105.912-13.208 4.368-29.491 11.824-57.085 22.064-81.454 26.508 18.066 54.755 28.421 83.848 30.583zm0 163.26v64.069c-29.091 2.162-57.339 12.518-83.847 30.583-10.239-24.368-17.696-51.958-22.063-81.446 30.339-7.986 65.982-12.483 105.91-13.206zm-92.098 130.343c8.943 16.109 18.905 29.851 29.665 41.024a232.062 232.062 0 0 1-48.154-22.604c6.031-6.664 12.2-12.8 18.489-18.42zm207.207-.004c6.29 5.622 12.462 11.759 18.492 18.424a232.074 232.074 0 0 1-48.161 22.606c10.762-11.174 20.726-24.918 29.669-41.03zm-92.098-66.271v-64.069c39.928.723 75.57 5.22 105.909 13.205-4.368 29.488-11.823 57.078-22.062 81.445-26.508-18.064-54.756-28.419-83.847-30.581zm0-87.094v-53.127c34.062-.588 72.477-3.926 108.669-13.016a439.287 439.287 0 0 1 1.778 39.576c0 13.408-.605 26.633-1.778 39.582-36.193-9.09-74.606-12.427-108.669-13.015zm194.001-136.247c-.075.077-.156.144-.23.223-15.45 16.585-37.696 29.965-65.643 39.852-5.066-32.301-13.662-62.5-25.437-89.027 9.267-7.87 18.272-16.743 26.983-26.577 26.469 20.225 48.492 45.979 64.327 75.529zM114.821 70.789c8.71 9.833 17.715 18.705 26.98 26.573-11.776 26.527-20.372 56.726-25.438 89.028-27.946-9.887-50.19-23.266-65.638-39.851-.074-.079-.154-.146-.229-.222 15.835-29.55 37.858-55.303 64.325-75.528zm-74.726 97.674c19.925 18.859 45.443 32.164 73.248 41.426a459.091 459.091 0 0 0-2.31 46.106c0 15.629.788 31.046 2.31 46.112-27.807 9.261-53.325 22.565-73.252 41.421-11.001-27.037-17.08-56.584-17.08-87.528 0-30.947 6.08-60.495 17.084-87.537zm10.396 197.212c.076-.077.158-.145.232-.226 15.45-16.582 37.695-29.958 65.641-39.844 5.066 32.297 13.662 62.494 25.434 89.019-9.268 7.87-18.277 16.743-26.989 26.577-26.464-20.224-48.484-45.977-64.318-75.526zm346.698 75.527c-8.714-9.835-17.723-18.709-26.992-26.58 11.774-26.525 20.368-56.72 25.433-89.018 27.947 9.884 50.194 23.262 65.645 39.845.075.081.156.147.234.226-15.834 29.55-37.855 55.303-64.32 75.527z\"/></svg>"
},
"link": "https://manjaro.org",
"ariaLabel": "Main web"
},
{
"icon": "github",
"link": "https://github.com/manjaro"
},
{
"icon": {
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 200\"><path fill=\"#e24329\" d=\"m193.83 79.73-.27-.69-26.14-68.22a6.81 6.81 0 0 0-2.69-3.24 7 7 0 0 0-8 .43 7 7 0 0 0-2.32 3.52l-17.65 54H65.29l-17.65-54A6.86 6.86 0 0 0 45.32 8a7 7 0 0 0-8-.43 6.87 6.87 0 0 0-2.69 3.24L8.44 79l-.26.69a48.54 48.54 0 0 0 16.1 56.1l.09.07.24.17 39.82 29.82 19.7 14.91 12 9.06a8.07 8.07 0 0 0 9.76 0l12-9.06 19.7-14.91 40.06-30 .1-.08a48.56 48.56 0 0 0 16.08-56.04z\"/><path fill=\"#fc6d26\" d=\"m193.83 79.73-.27-.69a88.3 88.3 0 0 0-35.15 15.8L101 138.25c19.55 14.79 36.57 27.64 36.57 27.64l40.06-30 .1-.08a48.56 48.56 0 0 0 16.1-56.08z\" class=\"cls-2\"/><path fill=\"#fca326\" d=\"m64.43 165.89 19.7 14.91 12 9.06a8.07 8.07 0 0 0 9.76 0l12-9.06 19.7-14.91S120.55 153 101 138.25C81.45 153 64.43 165.89 64.43 165.89z\"/><path fill=\"#fc6d26\" d=\"M43.58 94.84A88.19 88.19 0 0 0 8.44 79l-.26.69a48.54 48.54 0 0 0 16.1 56.1l.09.07.24.17 39.82 29.82L101 138.21 43.58 94.84z\" class=\"cls-2\"/></svg>"
},
"link": "https://gitlab.manjaro.org/explore/groups",
"ariaLabel": "GitLab"
},
{
"icon": "x",
"link": "https://x.com/ManjaroLinux",
"ariaLabel": "X"
},
{
"icon": "youtube",
"link": "https://youtube.com/@manjaro-linux",
"ariaLabel": "Youtube"
},
{
"icon": "linkedin",
"link": "https://linkedin.com/company/manjaro-linux",
"ariaLabel": "LinkedIn"
}
],
"editLink": {
"pattern": "https://github.com/cfinnberg/mdocs/edit/main/docs/:path"
}
}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.