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
{
"sidebar": false,
"aside": "left",
"lastUpdated": true,
"outlineTitle": "目录",
"outline": [
2,
6
],
"logo": "/logo.jpg",
"nav": [
{
"text": "首页",
"link": "/"
},
{
"text": "编程基础",
"items": [
{
"text": "Git",
"link": "/programming-basis/Git"
},
{
"text": "Nginx",
"link": "/programming-basis/Nginx"
},
{
"text": "Jmeter",
"link": "/programming-basis/Jmeter"
},
{
"text": "Linux",
"link": "/programming-basis/Linux常见命令.md"
},
{
"text": "Posman",
"link": "/programming-basis/Posman"
}
]
},
{
"text": "编程技能",
"items": [
{
"text": "EasyExcel的使用",
"link": "/programming-skill/EasyExcel的使用.md"
},
{
"text": "Eclipse快捷键的使用",
"link": "/programming-skill/Eclipse中快捷键的使用.md"
},
{
"text": "IDEA快捷键的使用",
"link": "/programming-skill/IDEAShortCutKeys.md"
},
{
"text": "Stream流编程",
"link": "/programming-skill/Stream.md"
},
{
"text": "Git在IDEA中的使用",
"link": "/programming-skill/git在IDEA中的使用.md"
},
{
"text": "Mybatis Plus的使用",
"link": "/programming-skill/mybatisPlus.md"
},
{
"text": "IDEA中使用Debug",
"link": "/programming-skill/IDEA中使用debug.md"
},
{
"text": "MinIo的使用",
"link": "/programming-skill/MINIO.md"
},
{
"text": "SpringScurity的使用",
"link": "/programming-skill/SpringScurity.md"
},
{
"text": "Docker全篇",
"link": "/programming-skill/dockerPartOne.md"
},
{
"text": "日志框架",
"link": "/programming-skill/logFramework.md"
},
{
"text": "MySQL实战",
"link": "/programming-skill/MySQL.md"
},
{
"text": "RabbitMQ应用",
"link": "/programming-skill/RabbitMQ.md"
},
{
"text": "ShardingJDBC",
"link": "/programming-skill/ShardingJDBC.md"
}
]
},
{
"text": "软件配置安装",
"items": [
{
"text": "jdk",
"link": "/software-install/jdk配置和安装"
},
{
"text": "mysql",
"link": "/software-install/Mysql配置和安装"
},
{
"text": "maven",
"link": "/software-install/Maven配置和安装"
},
{
"text": "node",
"link": "/software-install/Node配置和安装"
}
]
},
{
"text": "代码总结",
"items": [
{
"text": "常用代码编写",
"link": "/code/常用代码编写"
},
{
"text": "全局异常处理",
"link": "/code/全局异常处理"
},
{
"text": "分页查询",
"link": "/code/分页查询"
},
{
"text": "权限分配",
"link": "/code/权限分配"
}
]
},
{
"text": "工具",
"items": [
{
"text": "图库",
"link": "https://www.iconfont.cn/"
},
{
"text": "IP查询",
"link": "https://www.ipip.net/"
},
{
"text": "原版软件",
"link": "https://next.itellyou.cn/"
}
]
}
],
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/trailblazer-zuo"
}
],
"docFooter": {
"prev": "上一篇",
"next": "下一篇"
},
"footer": {
"copyright": "Copyright © 2024 Albert Zuo <a href=\"https://beian.miit.gov.cn/\" target=\"_blank\">赣ICP备2025056631号</a>"
},
"search": {
"provider": "local",
"options": {
"translations": {
"button": {
"buttonText": "搜索文档",
"buttonAriaLabel": "搜索文档"
},
"modal": {
"noResultsText": "无法找到相关结果",
"resetButtonTitle": "清除查询条件",
"footer": {
"selectText": "选择",
"navigateText": "切换"
}
}
}
}
}
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "api-examples.md",
"filePath": "api-examples.md",
"lastUpdated": 1715763412000
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.
