跳转到内容

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 ​

{
  "search": {
    "provider": "local",
    "options": {
      "translations": {
        "button": {
          "buttonText": "搜索文档",
          "buttonAriaLabel": "搜索文档"
        },
        "modal": {
          "noResultsText": "无法找到相关结果",
          "resetButtonTitle": "清除查询条件",
          "footer": {
            "selectText": "选择",
            "navigateText": "切换",
            "closeText": "关闭"
          }
        }
      }
    }
  },
  "outline": {
    "label": "页面导航",
    "level": [
      2,
      3
    ]
  },
  "docFooter": {
    "prev": "上一页",
    "next": "下一页"
  },
  "footer": {
    "message": "基于 MIT 许可发布",
    "copyright": "版权所有 © 2025-2026 <a href=\"https://github.com/yyznm\">YYZ</a>"
  },
  "editLink": {
    "pattern": "https://github.com/bull-m/bullm-remote-docs/edit/main/basics/:path",
    "text": "在 GitHub 上编辑此页面"
  },
  "lastUpdated": {
    "text": "最后更新于"
  },
  "notFound": {
    "title": "没有找到那个她",
    "quote": "也不知道是走了还是本来就没有",
    "linkLabel": "前往首页",
    "linkText": "带我回去"
  },
  "langMenuLabel": "多语言",
  "returnToTopLabel": "回到顶部",
  "sidebarMenuLabel": "菜单",
  "darkModeSwitchLabel": "主题",
  "lightModeSwitchTitle": "切换到浅色模式",
  "darkModeSwitchTitle": "切换到深色模式",
  "skipToContentLabel": "跳转到内容",
  "nav": [
    {
      "text": "🧭指南",
      "link": "/guide/start/start",
      "activeMatch": "/guide/"
    },
    {
      "text": "🔌插件",
      "link": "/plugin/start",
      "activeMatch": "/plugin/"
    },
    {
      "text": "🍨一杯冰淇淋",
      "link": "/reward/make",
      "activeMatch": "/reward/"
    }
  ],
  "sidebar": {
    "/guide/": {
      "base": "/guide/",
      "items": [
        {
          "text": "介绍",
          "items": [
            {
              "text": "梦开始的地方",
              "link": "info/start"
            },
            {
              "text": "这是什么 ?",
              "link": "info/tis"
            }
          ]
        },
        {
          "text": "GoGoGo!!!",
          "items": [
            {
              "text": "开始",
              "link": "start/start"
            },
            {
              "text": "连接",
              "link": "start/link"
            },
            {
              "text": "系统架构",
              "link": "start/process"
            }
          ]
        },
        {
          "text": "输入输出",
          "items": [
            {
              "text": "I2C扩展板",
              "link": "io/extend"
            },
            {
              "text": "PWM",
              "link": "io/pwm"
            },
            {
              "text": "电平",
              "link": "io/digital"
            },
            {
              "text": "舵机",
              "link": "io/servo"
            },
            {
              "text": "电机驱动(组合)",
              "link": "io/group"
            },
            {
              "text": "步进电机",
              "link": "io/stepper"
            }
          ]
        },
        {
          "text": "模块",
          "items": [
            {
              "text": "底盘",
              "link": "module/chassis"
            },
            {
              "text": "云台",
              "link": "module/pzt"
            },
            {
              "text": "相机",
              "link": "module/camera"
            }
          ]
        }
      ]
    },
    "/plugin/": {
      "base": "/plugin/",
      "items": [
        {
          "text": "插件",
          "items": [
            {
              "text": "什么是插件?",
              "link": "start"
            }
          ]
        },
        {
          "text": "内置插件",
          "items": [
            {
              "text": "图传 (Live)",
              "link": "built-in/live"
            },
            {
              "text": "摇杆控制 (Nipple)",
              "link": "built-in/nipple"
            },
            {
              "text": "手柄控制 (Gamepad)",
              "link": "built-in/gamepad"
            },
            {
              "text": "键盘控制 (Keyboard)",
              "link": "built-in/keyboard"
            },
            {
              "text": "连接状态 (Signal)",
              "link": "built-in/signal"
            },
            {
              "text": "滑块 (Slider)",
              "link": "built-in/slider"
            },
            {
              "text": "开关按钮 (SwitchButton)",
              "link": "built-in/switch-button"
            },
            {
              "text": "按钮 (Button)",
              "link": "built-in/button"
            }
          ]
        },
        {
          "text": "插件开发",
          "items": [
            {
              "text": "项目初始化",
              "link": "develop"
            }
          ]
        }
      ]
    },
    "/reward/": {
      "base": "/reward/",
      "items": [
        {
          "text": "赚钱钱 🔬",
          "link": "make"
        },
        {
          "text": "一起玩 💬",
          "link": "me"
        }
      ]
    }
  },
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/bull-m/bullm-remote"
    }
  ],
  "logo": {
    "dark": "/logo-dark.svg",
    "light": "/logo.svg"
  }
}

Page Data ​

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

Page Frontmatter ​

{
  "outline": "deep"
}

More ​

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

基于 MIT 许可发布