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": "/favicon.ico",
  "outline": {
    "level": [
      1,
      3
    ]
  },
  "nav": [
    {
      "text": "Home",
      "link": "/"
    },
    {
      "text": "快速开始",
      "link": "/quick-start/quick-start"
    },
    {
      "text": "下载",
      "link": "/function/download"
    },
    {
      "text": "0.0.7升级",
      "link": "/function/upgrade-007"
    }
  ],
  "sidebar": [
    {
      "text": "联机_快速开始",
      "collapsed": true,
      "items": [
        {
          "text": "快速联机",
          "link": "/quick-start/quick-start"
        },
        {
          "text": "常见问题",
          "link": "/quick-start/normalquesion"
        },
        {
          "text": "获取支持",
          "link": "/quick-start/gethelp"
        }
      ]
    },
    {
      "text": "版本升级指南",
      "collapsed": true,
      "items": [
        {
          "text": "0.0.7升级指南",
          "link": "/function/upgrade-007"
        }
      ]
    },
    {
      "text": "MCTLogServer日志收集",
      "collapsed": true,
      "items": [
        {
          "text": "Readme.md",
          "link": "/function/logcollege"
        },
        {
          "text": "Config配置说明",
          "link": "/function/logconfig"
        },
        {
          "text": "Example(C#)",
          "link": "/example/logexample"
        }
      ]
    },
    {
      "text": "MCTRoomListService",
      "collapsed": true,
      "items": [
        {
          "text": "概述",
          "link": "/view/roomlist-index"
        },
        {
          "text": "API 参考",
          "link": "/view/roomlist-api"
        },
        {
          "text": "Android 接入",
          "link": "/view/roomlist-android"
        },
        {
          "text": "C# 客户端接入",
          "link": "/view/roomlist-csharp"
        }
      ]
    },
    {
      "text": "Examples",
      "items": [
        {
          "text": "Markdown Examples",
          "link": "/examples/markdown-examples"
        },
        {
          "text": "Runtime API Examples",
          "link": "/examples/api-examples"
        }
      ]
    }
  ],
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/MCZLF/MinecraftConnectTool"
    }
  ],
  "footer": {
    "message": "Released under the MIT License",
    "copyright": "Copyright © 2023 MCZLFStudio_MinecraftConnectTool"
  }
}

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.

Released under the MIT License