Skip to content

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": "管理组件",
      "collapsed": true,
      "link": "/ch2/README",
      "items": [
        {
          "text": "业务领域",
          "link": "/ch2/1"
        },
        {
          "text": "业务规则",
          "link": "/ch2/2"
        },
        {
          "text": "规则引擎",
          "link": "/ch2/3"
        },
        {
          "text": "业务对象",
          "link": "/ch2/4"
        },
        {
          "text": "取数引擎",
          "link": "/ch2/5"
        },
        {
          "text": "领域服务",
          "link": "/ch2/6"
        },
        {
          "text": "运营看板",
          "link": "/ch2/7"
        },
        {
          "text": "权限管理",
          "link": "/ch2/8"
        }
      ]
    },
    {
      "text": "引擎组件",
      "link": "/ch3/README",
      "collapsed": true,
      "items": [
        {
          "text": "事件驱动",
          "link": "/ch3/1"
        },
        {
          "text": "加载配置",
          "link": "/ch3/2"
        },
        {
          "text": "加速响应",
          "link": "/ch3/3"
        },
        {
          "text": "加快排障",
          "link": "/ch3/4"
        },
        {
          "text": "成熟度模型与评估",
          "link": "/ch3/5"
        }
      ]
    },
    {
      "text": "知识图谱",
      "collapsed": true,
      "link": "/ch4/README",
      "items": [
        {
          "text": "符号主义",
          "link": "/ch4/1"
        },
        {
          "text": "图谱语言",
          "link": "/ch4/2"
        },
        {
          "text": "决策语言",
          "link": "/ch4/3"
        },
        {
          "text": "图式数据库",
          "link": "/ch4/4"
        }
      ]
    },
    {
      "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": "术语表",
          "link": "/appendix/GLOSSARY"
        },
        {
          "text": "参考资料",
          "link": "/appendix/REFERENCES"
        },
        {
          "text": "更新日志",
          "link": "/appendix/CHANGELOG"
        }
      ]
    },
    {
      "text": "Examples",
      "collapsed": true,
      "items": [
        {
          "text": "Markdown Examples",
          "link": "/examples/markdown-examples"
        },
        {
          "text": "Runtime API Examples",
          "link": "/examples/api-examples"
        }
      ]
    }
  ],
  "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.