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

{
  "nav": [
    {
      "text": "Home",
      "link": "/"
    },
    {
      "text": "Doc",
      "link": "/markdown-examples"
    }
  ],
  "sidebar": [
    {
      "text": "简介",
      "items": [
        {
          "text": "📖 系统介绍",
          "link": "/markdown-examples"
        },
        {
          "text": "📋 使用须知",
          "link": "/markdown-examples"
        }
      ]
    },
    {
      "text": "部署说明",
      "items": [
        {
          "text": "💻 系统要求",
          "link": "/markdown-examples"
        },
        {
          "text": "📦 下载部署",
          "link": "/markdown-examples"
        }
      ]
    },
    {
      "text": "使用说明",
      "items": [
        {
          "text": "🔗 TG绑定",
          "link": "/markdown-examples"
        },
        {
          "text": "📡 频道选择",
          "link": "/api-examples"
        },
        {
          "text": "⚙️ 交易配置",
          "link": "/api-examples"
        },
        {
          "text": "🔍 正则匹配",
          "link": "/api-examples"
        },
        {
          "text": "📊 交易日志",
          "link": "/api-examples"
        },
        {
          "text": "⚡ 授权激活",
          "link": "/api-examples"
        }
      ]
    },
    {
      "text": "成功案例",
      "items": [
        {
          "text": "🔗 TG绑定",
          "link": "/markdown-examples"
        },
        {
          "text": "📡 频道选择",
          "link": "/api-examples"
        },
        {
          "text": "⚙️ 交易配置",
          "link": "/api-examples"
        },
        {
          "text": "🔍 正则匹配",
          "link": "/api-examples"
        },
        {
          "text": "📊 交易日志",
          "link": "/api-examples"
        },
        {
          "text": "⚡ 授权激活",
          "link": "/api-examples"
        }
      ]
    },
    {
      "text": "联系客服",
      "items": [
        {
          "text": "🔑 授权激活",
          "link": "/markdown-examples"
        },
        {
          "text": "🛠️ 技术支持",
          "link": "/markdown-examples"
        }
      ]
    }
  ],
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/vuejs/vitepress"
    }
  ]
}

Page Data

{
  "title": "Runtime API Examples",
  "description": "",
  "frontmatter": {
    "outline": "deep"
  },
  "headers": [],
  "relativePath": "api-examples.md",
  "filePath": "api-examples.md"
}

Page Frontmatter

{
  "outline": "deep"
}

More

Check out the documentation for the full list of runtime APIs.