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": "/home_page/logo.svg",
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/XMuli/QuickUtilitiesSuite"
},
{
"icon": "gmail",
"link": "https://mail.google.com/mail/u/0/?view=cm&fs=1&tf=1&to=xmulitech@gmail.com&su=%5BQuick%20Utilities%20Suite%5D%20Suggestions%20and%20Feedback"
}
],
"nav": [
{
"text": "首頁",
"link": "/zh-tw/"
},
{
"text": "範例",
"link": "/zh-tw/markdown-examples"
},
{
"text": "隱私協議",
"link": "/zh-tw/privacy/open-source-license"
}
],
"sidebar": [
{
"text": "範例",
"items": [
{
"text": "Markdown 範例",
"link": "/zh-tw/markdown-examples"
},
{
"text": "運行時 API 範例",
"link": "/zh-tw/api-examples"
}
]
},
{
"text": "隱私協議",
"items": [
{
"text": "開源許可協議",
"link": "/zh-tw/privacy/open-source-license"
},
{
"text": "軟體許可協議",
"link": "/zh-tw/privacy/license"
},
{
"text": "隱私與資料保護",
"link": "/zh-tw/privacy/privacy-and-data-protection"
},
{
"text": "功能介紹",
"link": "/zh-tw/privacy/functions"
}
]
}
]
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "zh-tw/api-examples.md",
"filePath": "zh-tw/api-examples.md"
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.