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
{
"defaultTheme": "li",
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/BreadQ3166"
},
{
"icon": "bilibili",
"link": "https://b23.tv/f7qzwJX"
},
{
"icon": "gitee",
"link": "https://gitee.com/the-origin-of-bread/bakery"
}
],
"nav": [
{
"text": "🏡Home",
"link": "/"
},
{
"text": "🗃Examples",
"link": "/chat/markdown-examples"
},
{
"text": "📨Foreword",
"link": "/foreword/index"
},
{
"text": "🔖Tabs",
"link": "/chat/tags"
},
{
"text": "📃Archive",
"link": "/chat/archives"
},
{
"text": "🧭Travel",
"link": "/chat/travel"
},
{
"text": "🔮闲人",
"items": [
{
"text": "Minecraft",
"link": "/minecraft/total"
},
{
"text": "Web",
"link": "/web/total"
}
]
},
{
"text": "🎻小袖",
"items": [
{
"text": "Diffusion",
"link": "/diffusion/total"
},
{
"text": "Competition",
"link": "/competition/light"
},
{
"text": "Firmware",
"link": "/firmware/can"
},
{
"text": "Environment",
"link": "/environment/conda"
},
{
"text": "Yolo",
"link": "/network/total"
}
]
},
{
"text": "📦灵光",
"items": [
{
"text": "Minecraft",
"link": "/minecraft/total"
},
{
"text": "API",
"link": "/chat/api-examples"
}
]
}
],
"sidebar": {
"/diffusion/": [
{
"text": "Diffusion",
"collapsed": true,
"items": [
{
"text": "🥝起源",
"link": "/diffusion/total"
},
{
"text": "🍧提示词",
"link": "/diffusion/prompt"
},
{
"text": "🍯物品一致性",
"link": "/diffusion/marker"
},
{
"text": "🍰科研汇报",
"link": "/diffusion/research"
},
{
"text": "🍣ComfyUI自定义节点",
"link": "/diffusion/comfyui_nodes"
},
{
"text": "🥛DDPM论文阅读笔记",
"link": "/diffusion/ddpm"
}
]
}
],
"/competition/": [
{
"text": "Competition",
"collapsed": true,
"items": [
{
"text": "🥝光电赛",
"link": "/competition/light"
},
{
"text": "🍧电赛",
"link": "/competition/electron"
},
{
"text": "🍯蓝桥杯嵌入式",
"link": "/competition/bridge"
},
{
"text": "🍝蓝桥杯智能体",
"link": "/competition/agent"
},
{
"text": "🍰金融建模",
"link": "/competition/digfax"
},
{
"text": "🍣南山区职业技术竞赛",
"link": "/competition/technology"
}
]
}
],
"/firmware/": [
{
"text": "Firmware",
"collapsed": true,
"items": [
{
"text": "🥝CAN通信",
"link": "/firmware/can"
},
{
"text": "🍧平衡车",
"link": "/firmware/balance"
},
{
"text": "🍯客制键盘",
"link": "/firmware/keyboard"
},
{
"text": "🍰ROS系统",
"link": "/firmware/ros"
},
{
"text": "🥛STM32",
"link": "/firmware/stm32"
}
]
}
]
},
"editLink": {
"pattern": "https://github.com/vuejs/vitepress/edit/main/docs/:path",
"text": "Edit this page on GitHub"
},
"confetti": true,
"musicBall": {
"src": "https://img3.tukuppt.com/newpreview_music/09/01/62/5c89fd22dea6948307.mp3"
},
"logo": "/favicon.svg",
"siteTitle": "Bakery",
"search": {
"provider": "local"
}
}Page Data
{
"title": "API-Example",
"description": "怎么在Vitepress中实现API的调用",
"frontmatter": {
"outline": "deep",
"title": "API-Example",
"description": "怎么在Vitepress中实现API的调用",
"layout": "doc",
"tags": [
"blog"
],
"created": "2025-01-10",
"updated": "2025-01-10"
},
"headers": [],
"relativePath": "chat/api-examples.md",
"filePath": "chat/api-examples.md"
}Page Frontmatter
{
"outline": "deep",
"title": "API-Example",
"description": "怎么在Vitepress中实现API的调用",
"layout": "doc",
"tags": [
"blog"
],
"created": "2025-01-10",
"updated": "2025-01-10"
}More
Check out the documentation for the full list of runtime APIs.
