Runtime API Examples
更新: 8/21/2025 字数: 0 字 时长: 0 分钟
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
{ "lastUpdated": { "text": "最后更新于", "formatOptions": { "dateStyle": "short", "timeStyle": "medium" } }, "docFooter": { "prev": "上一页", "next": "下一页" }, "editLink": { "pattern": "https://github.com/VenenoSix24/IvyLabs/edit/main/docs/:path", "text": "在GitHub上编辑本页" }, "outline": { "level": [ 2, 3 ], "label": "当前页大纲" }, "search": { "provider": "local" }, "logo": "/logo-ivy0.png", "nav": [ { "text": "首页", "link": "/" }, { "text": "导航", "link": "/nav" }, { "text": "个人项目", "items": [ { "text": "我去抢个座", "link": "/feature/igolib" }, { "text": "总之就是非常可爱", "link": "/feature/kawaii" }, { "text": "黑苹果 OC EFI", "link": "/feature/ocefi" }, { "text": "个人密码生成器", "link": "/feature/ts" }, { "text": "个人主页模板", "link": "/feature/home" }, { "text": "开发者在线工具", "link": "/feature/tool" }, { "text": "打瓦加密器", "link": "/feature/dava" }, { "text": "原神抽卡模拟", "link": "/feature/ys" } ] }, { "text": "网站搭建", "items": [ { "text": "VitePress", "items": [ { "text": "快速上手", "link": "/webbuild/vitepress1" }, { "text": "页面配置", "link": "/webbuild/vitepress2" }, { "text": "Frontmatter", "link": "/webbuild/vitepress3" }, { "text": "域名托管到CF", "link": "/webbuild/sp2cf" } ] }, { "text": "Hexo", "items": [ { "text": "基础配置", "link": "webbuild/start-hexo" }, { "text": "进阶玩法", "link": "webbuild/autodeploy-hexo" } ] } ] }, { "text": "关于", "link": "/about" }, { "text": "我", "link": "https://m.ivyris.top/" } ], "sidebar": [ { "text": "🍃 IvyLabs", "items": [ { "text": "首页", "link": "/" }, { "text": "导航", "link": "/nav" }, { "text": "团队", "link": "/team" }, { "text": "关于", "link": "/about" } ] }, { "text": "🐣 个人项目", "items": [ { "text": "我去抢个座", "link": "/feature/igolib" }, { "text": "总之就是非常可爱", "link": "/feature/kawaii" }, { "text": "黑苹果 OC EFI", "link": "/feature/ocefi" }, { "text": "个人密码生成器", "link": "/feature/ts" }, { "text": "个人主页模板", "link": "/feature/home" }, { "text": "开发者在线工具", "link": "/feature/tool" }, { "text": "打瓦加密器", "link": "/feature/dava" }, { "text": "原神抽卡模拟", "link": "/feature/ys" } ] }, { "text": "网站搭建", "items": [ { "text": "VitePress", "items": [ { "text": "快速上手", "link": "/webbuild/vitepress1" }, { "text": "页面配置", "link": "/webbuild/vitepress2" }, { "text": "Frontmatter", "link": "/webbuild/vitepress3" }, { "text": "域名托管到CF", "link": "/webbuild/sp2cf" } ] }, { "text": "Hexo", "items": [ { "text": "基础配置", "link": "webbuild/start-hexo" }, { "text": "进阶玩法", "link": "webbuild/autodeploy-hexo" } ] } ] }, { "text": "🧩 文档测试", "items": [ { "text": "Markdown Examples", "link": "/markdown-examples" }, { "text": "Runtime API Examples", "link": "/api-examples" } ] }, { "text": "🔌 插件", "items": [ { "text": "vitepress-plugin-group-icons", "link": "/vitepress-plugin-group-icons" }, { "text": "vitepress-plugin-autobar", "link": "/vitepress-plugin-autobar" } ] }, { "text": "📚 参考文档", "items": [ { "text": "VitePress 中文教程", "link": "https://vitepress.yiov.top/" }, { "text": "XaviDocs 个人技术文档", "link": "https://xaviw.github.io/XaviDocs/%E5%B7%A5%E5%85%B7%E7%B3%BB%E5%88%97/VitePress%E6%90%AD%E5%BB%BA/%E5%9F%BA%E7%A1%80%E6%90%AD%E5%BB%BA.html" }, { "text": "vitepress-theme-async", "link": "https://github.com/MaLuns/vitepress-theme-async" }, { "text": "唯知笔记", "link": "https://note.weizwz.com/" } ] } ], "socialLinks": [ { "icon": "github", "link": "https://github.com/VenenoSix24" }, { "icon": "telegram", "link": "https://t.me/s1xig" }, { "icon": "x", "link": "https://x.com/S1xlg" } ], "footer": { "message": "VenenoSix24 🩷 Ivyris Amaris", "copyright": "Copyright © 2020-2025 Present Ivy Labs" } }
Page Data
{ "title": "Runtime API Examples", "description": "", "frontmatter": { "outline": "deep" }, "headers": [], "relativePath": "api-examples.md", "filePath": "api-examples.md", "lastUpdated": 1755754410000 }
Page Frontmatter
{ "outline": "deep" }
More
Check out the documentation for the full list of runtime APIs.