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
{
"nav": [
{
"text": "主页",
"link": "/"
},
{
"text": "最佳实践",
"link": "/bp"
}
],
"markdown": {},
"sidebar": [
{
"text": "DailyRead",
"items": [
{
"text": "最佳实践",
"link": "/bp"
},
{
"text": "文档",
"link": "/2023/"
}
]
}
],
"socialLinks": []
}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.
天色渐晚
>
天色渐晚
晚霞恰好走到了我对面
我轻点光阴
如泼墨般的记忆奔涌而来
我翻开一页空白
提笔续写着另一种期待
很多事情
明媚过后 便是永远的怀念
风追不上云的脚步
我们也再回不到最初
我固执地在黑暗中醒着
我的思念贯穿星辰
风来过 雨来过
云也路过了我
听说——
我也只是听说。
清风吹散了一纸寂寞
没结果...
这一阑夜色,
却 也都只是路过。
天色渐晚
晚霞恰好走到了我对面
我轻点光阴
如泼墨般的记忆奔涌而来
我翻开一页空白
提笔续写着另一种期待
很多事情
明媚过后 便是永远的怀念
风追不上云的脚步
我们也再回不到最初
我固执地在黑暗中醒着
我的思念贯穿星辰
风来过 雨来过
云也路过了我
听说——
我也只是听说。
清风吹散了一纸寂寞
没结果...
这一阑夜色,
却 也都只是路过。