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": "Home",
"link": "/"
},
{
"text": "APQC",
"link": "/apqc"
},
{
"text": "统考",
"link": "/统考"
},
{
"text": "Examples",
"link": "/markdown-examples"
}
],
"sidebar": {
"/apqc/": [
{
"text": "APQC",
"link": "/apqc",
"items": [
{
"text": "消化系统",
"link": "/apqc/消化系统",
"items": [
{
"text": "胃食管反流病",
"link": "/apqc/消化系统/胃食管反流病"
}
]
}
]
}
],
"/统考/": [
{
"text": "统考",
"link": "/统考",
"items": [
{
"text": "生理学",
"link": "/统考/生理学",
"items": [
{
"text": "1绪论细胞基本功能血液",
"link": "/统考/生理学/1绪论细胞基本功能血液"
},
{
"text": "2血液循环呼吸",
"link": "/统考/生理学/2血液循环呼吸"
},
{
"text": "3呼吸消化能量代谢",
"link": "/统考/生理学/3呼吸消化能量代谢"
},
{
"text": "4泌尿内分泌神经生殖",
"link": "/统考/生理学/4泌尿内分泌神经生殖"
}
]
},
{
"text": "药理学",
"link": "/统考/药理学",
"items": [
{
"text": "一-总论1-2章",
"link": "/统考/药理学/一-总论1-2章"
},
{
"text": "二-3-6章",
"link": "/统考/药理学/二-3-6章"
},
{
"text": "三-7-8章",
"link": "/统考/药理学/三-7-8章"
}
]
},
{
"text": "解剖学",
"link": "/统考/解剖学",
"items": [
{
"text": "一-绪论消化系统",
"link": "/统考/解剖学/一-绪论消化系统"
},
{
"text": "二-消化呼吸泌尿生殖",
"link": "/统考/解剖学/二-消化呼吸泌尿生殖"
},
{
"text": "三-腹膜脉管感觉器神经内分泌",
"link": "/统考/解剖学/三-腹膜脉管感觉器神经内分泌"
}
]
},
{
"text": "内科学",
"link": "/统考/内科学",
"items": [
{
"text": "呼吸系统",
"link": "/统考/内科学/1呼吸系统"
},
{
"text": "循环系统",
"link": "/统考/内科学/2循环系统"
},
{
"text": "消化系统",
"link": "/统考/内科学/3消化泌尿"
},
{
"text": "泌尿系统",
"link": "/统考/内科学/4泌尿系统"
},
{
"text": "血液内分泌",
"link": "/统考/内科学/5血液内分泌"
}
]
},
{
"text": "妇产科",
"link": "/统考/妇产科",
"items": [
{
"text": "妇产科一",
"link": "/统考/妇产科/1妇产科一"
},
{
"text": "妇产科二",
"link": "/统考/妇产科/2妇产科二"
},
{
"text": "妇产科三",
"link": "/统考/妇产科/3妇产科三"
}
]
},
{
"text": "儿科学",
"link": "/统考/儿科学",
"items": [
{
"text": "儿科学一",
"link": "/统考/儿科学/1儿科学一"
},
{
"text": "儿科学二",
"link": "/统考/儿科学/2儿科学二"
}
]
}
]
}
]
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/vuejs/vitepress"
}
]
}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.