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
{ "logo": "logo.png", "footer": { "copyright": "Copyright © 2002-2024 新大陆软件工程有限公司 <a target=\"_blank\" style=\"text-decoration: none;\" href=\"http://beian.miit.gov.cn/\">闽ICP备14017290号-1</a>" }, "search": { "provider": "local" }, "nav": [ { "text": "首页", "link": "/" }, { "text": "文档", "link": "/ch1/README" } ], "sidebar": [ { "text": "概述", "collapsed": true, "link": "/ch1/README", "items": [ { "text": "顶层架构", "link": "/ch1/1" }, { "text": "底层算法", "link": "/ch1/2" }, { "text": "概念模型", "link": "/ch1/3" }, { "text": "编程范式", "link": "/ch1/4" }, { "text": "业务组件", "link": "/ch1/5" } ] }, { "text": "引擎组件", "link": "/ch2/README", "collapsed": true, "items": [ { "text": "基座", "link": "/ch2/1" }, { "text": "微服务框架", "link": "/ch2/2" }, { "text": "取数模块", "link": "/ch2/3" }, { "text": "引擎模块", "link": "/ch2/4" }, { "text": "服务模块", "link": "/ch2/5" } ] }, { "text": "管理组件", "collapsed": true, "link": "/ch3/README", "items": [ { "text": "组件管理", "link": "/ch3/1" }, { "text": "数据管理", "link": "/ch3/2" }, { "text": "规则管理", "link": "/ch3/3" }, { "text": "版本管理", "link": "/ch3/4" }, { "text": "运营管理", "link": "/ch3/5" }, { "text": "基础管理", "link": "/ch3/6" } ] }, { "text": "基础组件", "collapsed": true, "link": "/ch4/README", "items": [ { "text": "数据库", "link": "/ch4/1" }, { "text": "消息队列", "link": "/ch4/2" }, { "text": "网络协议", "link": "/ch4/3" }, { "text": "虚拟化技术", "link": "/ch4/4" }, { "text": "编辑器", "link": "/ch4/5" } ] }, { "text": "知识图谱", "collapsed": true, "link": "/ch5/README", "items": [ { "text": "符号主义", "link": "/ch5/1" }, { "text": "图谱语言", "link": "/ch5/2" }, { "text": "决策语言", "link": "/ch5/3" }, { "text": "图式数据库", "link": "/ch5/4" } ] }, { "text": "代码示例", "collapsed": true, "items": [ { "text": "Drools Examples", "link": "/examples/drools-examples" }, { "text": "Neo4j Examples", "link": "/examples/neo4j-examples" }, { "text": "Markdown Examples", "link": "/examples/markdown-examples" }, { "text": "API Examples", "link": "/examples/api-examples" } ] }, { "text": "附录", "collapsed": true, "items": [ { "text": "术语表", "link": "/appendix/GLOSSARY" }, { "text": "参考资料", "link": "/appendix/REFERENCES" }, { "text": "更新日志", "link": "/appendix/CHANGELOG" } ] } ], "socialLinks": [ { "icon": "github", "link": "https://github.com/kiegroup" } ] }
Page Data
{ "title": "Runtime API Examples", "description": "", "frontmatter": { "outline": "deep" }, "headers": [], "relativePath": "examples/api-examples.md", "filePath": "examples/api-examples.md" }
Page Frontmatter
{ "outline": "deep" }
More
Check out the documentation for the full list of runtime APIs.