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
{
"siteTitle": "SoPay 文档中心",
"nav": [
{
"text": "接入指南",
"items": [
{
"text": "快速开始",
"link": "/guide/intro"
},
{
"text": "签名规范",
"link": "/signature"
},
{
"text": "异步回调",
"link": "/callback"
},
{
"text": "支持国家",
"link": "/supported-countries"
}
]
},
{
"text": "接入文档",
"items": [
{
"text": "泰国",
"link": "/tha/overview"
},
{
"text": "巴基斯坦",
"link": "/pk/overview"
},
{
"text": "印度",
"link": "/in/overview"
},
{
"text": "中国",
"link": "/cn/overview"
},
{
"text": "菲律宾",
"link": "/ph/overview"
},
{
"text": "印尼",
"link": "/id/overview"
}
]
},
{
"text": "解决方案",
"items": [
{
"text": "印度支付 API",
"link": "/solutions/india-payment-api"
},
{
"text": "泰国支付 API",
"link": "/solutions/thailand-payment-api"
},
{
"text": "巴基斯坦支付 API",
"link": "/solutions/pakistan-payment-api"
},
{
"text": "支付渠道 API",
"link": "/solutions/payment-gateway-api"
},
{
"text": "代付 API",
"link": "/solutions/payout-api"
}
]
}
],
"sidebar": {
"/": [
{
"text": "_",
"items": [
{
"text": "_",
"link": "/"
}
]
}
]
},
"outline": {
"level": [
1,
2
]
},
"docFooter": {
"prev": "上一页",
"next": "下一页"
},
"lastUpdated": {
"text": "最后更新于"
},
"footer": false,
"logo": "/logo.png",
"search": {
"provider": "local"
},
"aside": false
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "api-examples.md",
"filePath": "api-examples.md",
"lastUpdated": 1784457415000
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.
