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.svg",
  "nav": [
    {
      "text": "教程文档",
      "link": "/"
    },
    {
      "text": "访问官网",
      "link": "https://clickhouse.com/"
    }
  ],
  "sidebar": [
    {
      "text": "简介",
      "base": "/introduction",
      "items": [
        {
          "text": "ClickHouse的特性",
          "link": "/distinctive-features"
        },
        {
          "text": "ClickHouse性能",
          "link": "/performance"
        },
        {
          "text": "ClickHouse历史",
          "link": "/history"
        },
        {
          "text": "ClickHouse用户",
          "link": "/adopters"
        }
      ]
    },
    {
      "text": "快速上手",
      "base": "/getting-started",
      "link": "/index",
      "items": [
        {
          "text": "安装部署",
          "link": "/install"
        },
        {
          "text": "使用教程",
          "link": "/tutorial"
        }
      ]
    },
    {
      "text": "API接口",
      "base": "/interfaces",
      "link": "/index",
      "items": [
        {
          "text": "命令行客户端",
          "link": "/cli"
        },
        {
          "text": "原生接口(TCP)",
          "link": "/tcp"
        },
        {
          "text": "HTTP客户端",
          "link": "/http"
        },
        {
          "text": "MySQL接口",
          "link": "/mysql"
        },
        {
          "text": "输入/输出格式",
          "link": "/formats"
        },
        {
          "text": "JDBC驱动",
          "link": "/jdbc"
        },
        {
          "text": "ODBC驱动",
          "link": "/odbc"
        },
        {
          "text": "cpp",
          "link": "/cpp"
        },
        {
          "text": "第三方工具",
          "base": "/interfaces/third-party",
          "items": [
            {
              "text": "第三方开发库",
              "link": "/client-libraries"
            },
            {
              "text": "第三方集成库",
              "link": "/integrations"
            },
            {
              "text": "第三方代理",
              "link": "/proxy"
            },
            {
              "text": "可视化界面",
              "link": "/gui"
            }
          ]
        }
      ]
    }
  ],
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/ClickHouse/ClickHouse"
    }
  ]
}

Page Data

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

Page Frontmatter

{
  "outline": "deep"
}

More

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