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>
<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": "/markdown-examples" } ], "sidebar": [ { "text": "系统介绍", "items": [ { "text": "关于系统", "link": "/profile/about" }, { "text": "获得授权", "link": "/profile/getauthorized" }, { "text": "技术支持", "link": "/profile/technicalsupport.md" }, { "text": "联系我们", "link": "/profile/contactus.md" } ] }, { "text": "安装部署", "items": [ { "text": "环境搭建", "link": "/indeploy/envsetup.md" }, { "text": "Docker 快速部署", "link": "/indeploy/deploy.md" }, { "text": "系统升级", "link": "/indeploy/systemUpgrades.md" } ] }, { "text": "快速入门", "items": [ { "text": "创建模板", "link": "/quickStart/creatingTemplate.md" }, { "text": "创建项目", "link": "/quickStart/creatingProject.md" }, { "text": "权限设置", "link": "/quickStart/permissionSetting.md" } ] }, { "text": "功能介绍", "items": [ { "text": "我的项目", "link": "/functions/minepro.md" }, { "text": "公司项目", "link": "/CompanyProject/CompanyProject.md" }, { "text": "我的分享", "link": "/MyShare/MyShare.md" }, { "text": "回收站", "link": "/RecycleBin/RecycleBin.md" }, { "text": "项目管理", "items": [ { "text": "公司项目", "link": "/functions/ProjectManagement/CompanyProject.md" }, { "text": "回收站", "link": "/functions/ProjectManagement/RecycleBin.md" } ] }, { "text": "项目设置", "items": [ { "text": "模板设置", "link": "/projectSetup/TemplateSetup.md" }, { "text": "分类管理", "link": "/projectSetup/ClassificationManagement.md" }, { "text": "标签管理", "link": "/projectSetup/LabelManagement.md" }, { "text": "人员管理", "link": "/projectSetup/PersonnelManagement" }, { "text": "角色管理", "link": "/projectSetup/RoleCreation" } ] }, { "text": "监控中心", "items": [ { "text": "系统日志", "link": "/MonitoringCenter/SystemLog.md" }, { "text": "操作日志", "link": "/MonitoringCenter/OperationLog.md" } ] }, { "text": "数据管理", "items": [ { "text": "数据字典", "link": "/DataManagement/DataDictionary.md" } ] }, { "text": "系统设置", "items": [ { "text": "系统设置", "link": "/SystemSettings/SystemSettings.md" }, { "text": "应用配置", "link": "/SystemSettings/ApplicationConfiguration.md" }, { "text": "管理人员", "link": "/SystemSettings/ManagementPersonnel.md" }, { "text": "角色管理", "link": "/SystemSettings/RoleManagement.md" }, { "text": "权限管理", "link": "/SystemSettings/AuthorityManagement.md" }, { "text": "部门管理", "link": "/SystemSettings/DepartmentManagement.md" } ] } ] }, { "text": "升级日志", "link": "/changelog.md" } ], "socialLinks": [ { "icon": "github", "link": "" } ] }
Page Data
{ "title": "Runtime API Examples", "description": "", "frontmatter": { "outline": "deep" }, "headers": [], "relativePath": "deploy/install.md", "filePath": "deploy/install.md" }
Page Frontmatter
{ "outline": "deep" }