Appearance
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": false, "nav": [ { "text": "首页", "link": "/" }, { "text": "1分钟上手", "link": "/quick_registration" }, { "text": "服务与价格", "link": "/model_price" }, { "text": "Midjourney接入", "link": "/mj_api" }, { "text": "ChatGPT接入", "items": [ { "text": "ChatGPT", "link": "/examples" }, { "text": "Google Gemini", "link": "/examples" }, { "text": "Claude", "link": "/examples" } ] }, { "text": "控制台", "link": "https://api.72live.com/setting?tab=personal", "target": "_blank" } ], "sidebar": [ { "text": "快速指引", "items": [ { "text": "1分钟上手指引", "link": "/quick_registration" }, { "text": "获取API Key", "link": "/get_key" }, { "text": "积分奖励规则", "link": "/freetrial" }, { "text": "积分计价机制", "link": "/tokens" }, { "text": "模型能力与价格", "link": "/model_price" }, { "text": "会员权益说明", "link": "/member_rules" }, { "text": "Midjourney接入示例", "link": "/mj_api" }, { "text": "MJ API接口文档", "link": "/mj_api_reference" }, { "text": "浏览器上使用", "link": "/examples" }, { "text": "安卓手机接入", "link": "/android" }, { "text": "苹果手机/平板接入", "link": "/examples" }, { "text": "Windows接入", "link": "/examples" }, { "text": "MacOS接入", "link": "/examples" } ] }, { "text": "更多AI API应用", "items": [ { "text": "小米音响接入", "link": "/xiaomia_speaker" }, { "text": "Runtime API Examples", "link": "/api-examples" } ] }, { "text": "使用交流", "items": [ { "text": "Markdown Examples", "link": "/examples" }, { "text": "Runtime API Examples", "link": "/api-examples" } ] } ] }
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.