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": "https://cdn.jsdelivr.net/gh/hypocritical-jiang/blog-assets@main/images/icons8-worldwide-delivery-96.png",
  "nav": [
    {
      "text": "首页",
      "link": "/"
    },
    {
      "text": "归档",
      "link": "/archives/"
    },
    {
      "text": "分类",
      "link": "/categories/"
    },
    {
      "text": "标签",
      "link": "/tags/"
    },
    {
      "text": "关于我",
      "items": [
        {
          "text": "github",
          "link": ""
        },
        {
          "text": "bilibili",
          "link": ""
        }
      ]
    }
  ],
  "sidebar": [
    {
      "text": "学习笔记",
      "collapsed": true,
      "items": [
        {
          "text": "AI和深度学习",
          "collapsed": true,
          "items": [
            {
              "text": "1 AI和机器学习",
              "link": "/posts/durham_study/Aritifical_intelligence/1"
            },
            {
              "text": "2 机器学习基础",
              "link": "/posts/durham_study/Aritifical_intelligence/2"
            }
          ]
        },
        {
          "text": "先进电子",
          "collapsed": true,
          "items": [
            {
              "text": "lecture 1 纳米电子学",
              "link": "/posts/durham_study/advanced_electronics/1"
            },
            {
              "text": "lecture 10 存储器",
              "link": "/posts/durham_study/advanced_electronics/10"
            },
            {
              "text": "lecture 11 带隙工程、低维材料与器件",
              "link": "/posts/durham_study/advanced_electronics/11"
            },
            {
              "text": "lecture 12 有机半导体与电荷输运",
              "link": "/posts/durham_study/advanced_electronics/12"
            },
            {
              "text": "lecture 13 自组装与薄膜制造",
              "link": "/posts/durham_study/advanced_electronics/13"
            },
            {
              "text": "lecture 14 薄膜晶体管(TFT)",
              "link": "/posts/durham_study/advanced_electronics/14"
            },
            {
              "text": "lecture 2 MOSFET 缩放",
              "link": "/posts/durham_study/advanced_electronics/2"
            },
            {
              "text": "lecture 3 隧穿与薄绝缘层",
              "link": "/posts/durham_study/advanced_electronics/3"
            },
            {
              "text": "lecture 4 纳米器件连接",
              "link": "/posts/durham_study/advanced_electronics/4"
            },
            {
              "text": "lecture 5 热力学计算",
              "link": "/posts/durham_study/advanced_electronics/5"
            },
            {
              "text": "lecture 6 能量 / 功耗计算",
              "link": "/posts/durham_study/advanced_electronics/6"
            },
            {
              "text": "lecture 7 导电模型",
              "link": "/posts/durham_study/advanced_electronics/7"
            },
            {
              "text": "lecture 8 声子、漂移与扩散",
              "link": "/posts/durham_study/advanced_electronics/8"
            },
            {
              "text": "lecture 9 微机电系统(MEMS)",
              "link": "/posts/durham_study/advanced_electronics/9"
            }
          ]
        },
        {
          "text": "先进电子测量",
          "collapsed": true,
          "items": [
            {
              "text": "Slides 1 MIMO 无线通信",
              "link": "/posts/durham_study/advanced_electronics_Measurements/1"
            },
            {
              "text": "Slides 2 无线电传播信号",
              "link": "/posts/durham_study/advanced_electronics_Measurements/2"
            },
            {
              "text": "Slides 3 无线电传播信号",
              "link": "/posts/durham_study/advanced_electronics_Measurements/3"
            },
            {
              "text": "习题1 课后作业",
              "link": "/posts/durham_study/advanced_electronics_Measurements/Question_1"
            },
            {
              "text": "习题2 课后作业",
              "link": "/posts/durham_study/advanced_electronics_Measurements/Question_2"
            },
            {
              "text": "1 多径传输与信道建模",
              "link": "/posts/durham_study/advanced_electronics_Measurements/summary_1"
            },
            {
              "text": "9 接触电阻",
              "link": "/posts/durham_study/advanced_electronics_Measurements/summary_10"
            },
            {
              "text": "2 多径信道的参数分析",
              "link": "/posts/durham_study/advanced_electronics_Measurements/summary_2"
            },
            {
              "text": "3 小尺度衰落",
              "link": "/posts/durham_study/advanced_electronics_Measurements/summary_3"
            },
            {
              "text": "4 大尺度衰落",
              "link": "/posts/durham_study/advanced_electronics_Measurements/summary_4"
            },
            {
              "text": "5 电子测量基础",
              "link": "/posts/durham_study/advanced_electronics_Measurements/summary_5"
            },
            {
              "text": "6 阻抗测量",
              "link": "/posts/durham_study/advanced_electronics_Measurements/summary_6"
            },
            {
              "text": "7 电阻率",
              "link": "/posts/durham_study/advanced_electronics_Measurements/summary_7"
            },
            {
              "text": "8 载流子类型与浓度",
              "link": "/posts/durham_study/advanced_electronics_Measurements/summary_8"
            },
            {
              "text": "9 接触电阻",
              "link": "/posts/durham_study/advanced_electronics_Measurements/summary_9"
            },
            {
              "text": "考试",
              "link": "/posts/durham_study/advanced_electronics_Measurements/test_1"
            }
          ]
        },
        {
          "text": "通信网络",
          "collapsed": true,
          "items": [
            {
              "text": "0 通信网络导论",
              "link": "/posts/durham_study/communication_networks/0"
            },
            {
              "text": "1 分层体系结构",
              "link": "/posts/durham_study/communication_networks/1"
            },
            {
              "text": "2 数据链路层协议",
              "link": "/posts/durham_study/communication_networks/2"
            },
            {
              "text": "3 媒体访问控制协议",
              "link": "/posts/durham_study/communication_networks/3"
            },
            {
              "text": "4 媒体访问控制协议",
              "link": "/posts/durham_study/communication_networks/4"
            },
            {
              "text": "5 无线个域网",
              "link": "/posts/durham_study/communication_networks/5"
            },
            {
              "text": "6 互联网协议",
              "link": "/posts/durham_study/communication_networks/6"
            },
            {
              "text": "7 传输层协议",
              "link": "/posts/durham_study/communication_networks/7"
            },
            {
              "text": "8 网络安全介绍",
              "link": "/posts/durham_study/communication_networks/8"
            }
          ]
        },
        {
          "text": "光子学",
          "collapsed": true,
          "items": [
            {
              "text": "0 基础知识复习",
              "link": "/posts/durham_study/phontonics/0"
            },
            {
              "text": "1 无损传输线模型",
              "link": "/posts/durham_study/phontonics/1"
            },
            {
              "text": "2 有限传输线模型",
              "link": "/posts/durham_study/phontonics/2"
            },
            {
              "text": "3 有损传输线模型",
              "link": "/posts/durham_study/phontonics/3"
            },
            {
              "text": "4 麦克斯韦方程",
              "link": "/posts/durham_study/phontonics/4"
            },
            {
              "text": "Devices 0 课程先导",
              "link": "/posts/durham_study/phontonics/5"
            },
            {
              "text": "Devices 1",
              "link": "/posts/durham_study/phontonics/6"
            },
            {
              "text": "Devices 2",
              "link": "/posts/durham_study/phontonics/7"
            },
            {
              "text": "Device 0 总结",
              "link": "/posts/durham_study/phontonics/8"
            }
          ]
        },
        {
          "text": "无线电与电子通信",
          "collapsed": true,
          "items": [
            {
              "text": "Radio Part 5",
              "link": "/posts/durham_study/radio_and_digital_communication/Radio_part_5"
            }
          ]
        }
      ]
    },
    {
      "text": "前端",
      "collapsed": true,
      "items": []
    },
    {
      "text": "机器学习",
      "collapsed": true,
      "items": []
    }
  ],
  "outline": {
    "level": [
      1,
      4
    ]
  },
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/vuejs/vitepress"
    }
  ]
}

Page Data

{
  "title": "Runtime API Examples",
  "description": "",
  "frontmatter": {
    "outline": "deep"
  },
  "headers": [],
  "relativePath": "categories/index.md",
  "filePath": "categories/index.md"
}

Page Frontmatter

{
  "outline": "deep"
}

More

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

© 2026 MySite. All rights reserved.