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

{
  "editLink": {
    "pattern": "https://github.com/mameikagou/vitepress-template/edit/main/:path",
    "text": "在 GitHub 上编辑此页面"
  },
  "search": {
    "provider": "local",
    "options": {
      "locales": {
        "zh": {
          "translations": {
            "button": {
              "buttonText": "搜索文档",
              "buttonAriaLabel": "搜索文档"
            },
            "modal": {
              "noResultsText": "无法找到相关结果",
              "resetButtonTitle": "清除查询条件",
              "footer": {
                "selectText": "选择",
                "navigateText": "切换"
              }
            }
          }
        }
      }
    }
  },
  "docFooter": {
    "prev": "上一页",
    "next": "下一页"
  },
  "outline": {
    "label": "页面导航"
  },
  "returnToTopLabel": "回到顶部",
  "sidebarMenuLabel": "菜单",
  "darkModeSwitchLabel": "主题",
  "lightModeSwitchTitle": "切换到浅色模式",
  "darkModeSwitchTitle": "切换到深色模式",
  "nav": [
    {
      "text": "主页",
      "link": "/"
    }
  ],
  "appearance": "dark",
  "vite": {
    "plugins": [
      {
        "name": "vitepress-plugin-group-icons",
        "enforce": "post"
      }
    ]
  },
  "markdown": {
    "lineNumbers": true,
    "codeTransformers": [
      {}
    ],
    "image": {
      "lazyLoading": true
    }
  },
  "locales": {
    "root": {
      "label": "简体中文",
      "lang": "Zh_CN"
    },
    "en": {
      "label": "English",
      "lang": "en",
      "link": "/en/"
    },
    "fr": {
      "label": "French",
      "lang": "fr",
      "link": "/fr/"
    }
  },
  "sidebar": {
    "/": {
      "base": "/",
      "items": [
        {
          "text": "Example",
          "link": "src/Example"
        },
        {
          "text": "HR面",
          "items": [
            {
              "text": "京东HR",
              "link": "src/HR面/京东HR"
            }
          ],
          "collapsed": false
        },
        {
          "text": "ZOOM",
          "items": [
            {
              "text": "2025其一某社招",
              "link": "src/ZOOM/2025其一某社招"
            }
          ],
          "collapsed": false
        },
        {
          "text": "liu",
          "items": [
            {
              "text": "2025.3.14 滴滴一面",
              "link": "src/liu/2025.3.14 滴滴一面"
            },
            {
              "text": "2025.3.17腾讯一面",
              "link": "src/liu/2025.3.17腾讯一面"
            },
            {
              "text": "2025.3.18字节一面",
              "link": "src/liu/2025.3.18字节一面"
            },
            {
              "text": "2025.3.18滴滴二面",
              "link": "src/liu/2025.3.18滴滴二面"
            },
            {
              "text": "2025.3.20快看漫画一面",
              "link": "src/liu/2025.3.20快看漫画一面"
            },
            {
              "text": "2025.7.1二战字节二面",
              "link": "src/liu/2025.7.1二战字节二面"
            },
            {
              "text": "MAC-2025.4.23 腾讯一面应该是",
              "link": "src/liu/MAC-2025.4.23 腾讯一面应该是"
            },
            {
              "text": "MAC-2025.4.23-网易雷火",
              "link": "src/liu/MAC-2025.4.23-网易雷火"
            },
            {
              "text": "bigquant一面",
              "link": "src/liu/bigquant一面"
            },
            {
              "text": "一战字节二面",
              "link": "src/liu/一战字节二面"
            },
            {
              "text": "二战字节一面",
              "link": "src/liu/二战字节一面"
            },
            {
              "text": "云智二面",
              "link": "src/liu/云智二面"
            },
            {
              "text": "克里云一面",
              "link": "src/liu/克里云一面"
            },
            {
              "text": "忘了 一面",
              "link": "src/liu/忘了 一面"
            },
            {
              "text": "快看漫画二面",
              "link": "src/liu/快看漫画二面"
            },
            {
              "text": "懂车帝一面",
              "link": "src/liu/懂车帝一面"
            },
            {
              "text": "懂车帝二面",
              "link": "src/liu/懂车帝二面"
            },
            {
              "text": "收集的字节面试",
              "link": "src/liu/收集的字节面试"
            },
            {
              "text": "星辰征途",
              "link": "src/liu/星辰征途"
            },
            {
              "text": "智谱一面",
              "link": "src/liu/智谱一面"
            },
            {
              "text": "海康威视电话面",
              "link": "src/liu/海康威视电话面"
            },
            {
              "text": "滴滴秋储一面",
              "link": "src/liu/滴滴秋储一面"
            },
            {
              "text": "美团酒旅二面",
              "link": "src/liu/美团酒旅二面"
            },
            {
              "text": "腾讯cdg一面",
              "link": "src/liu/腾讯cdg一面"
            },
            {
              "text": "腾讯微信小游戏一面",
              "link": "src/liu/腾讯微信小游戏一面"
            },
            {
              "text": "腾讯电竞一面",
              "link": "src/liu/腾讯电竞一面"
            }
          ],
          "collapsed": false
        },
        {
          "text": "京东",
          "items": [
            {
              "text": "不知名面试",
              "link": "src/京东/不知名面试"
            },
            {
              "text": "其一2025秋招前端",
              "link": "src/京东/其一2025秋招前端"
            },
            {
              "text": "其三前端二面",
              "link": "src/京东/其三前端二面"
            },
            {
              "text": "其二2025秋招前端",
              "link": "src/京东/其二2025秋招前端"
            },
            {
              "text": "其四2025暑期",
              "link": "src/京东/其四2025暑期"
            },
            {
              "text": "零售",
              "link": "src/京东/零售"
            }
          ],
          "collapsed": false
        },
        {
          "text": "其他",
          "items": [
            {
              "text": "cider日常",
              "link": "src/其他/cider日常"
            },
            {
              "text": "转转",
              "link": "src/其他/转转"
            },
            {
              "text": "麦当劳南京日常",
              "link": "src/其他/麦当劳南京日常"
            }
          ],
          "collapsed": false
        },
        {
          "text": "场景题",
          "link": "src/场景题/index.md",
          "items": [
            {
              "text": "业务题",
              "link": "src/场景题/业务题/index.md",
              "items": [],
              "collapsed": true
            },
            {
              "text": "开放性问题",
              "link": "src/场景题/开放性问题/index.md",
              "items": [],
              "collapsed": true
            },
            {
              "text": "性能",
              "link": "src/场景题/性能/index.md",
              "items": [],
              "collapsed": true
            },
            {
              "text": "智力题",
              "link": "src/场景题/智力题/index.md",
              "items": [],
              "collapsed": true
            },
            {
              "text": "计算机网络",
              "link": "src/场景题/计算机网络/index.md",
              "items": [],
              "collapsed": true
            }
          ],
          "collapsed": false
        },
        {
          "text": "字节",
          "items": [
            {
              "text": "2025ttshop二面",
              "link": "src/字节/2025ttshop二面"
            },
            {
              "text": "2025抖电前端一面",
              "link": "src/字节/2025抖电前端一面"
            },
            {
              "text": "2025抖电提前批二面",
              "link": "src/字节/2025抖电提前批二面"
            },
            {
              "text": "2025抖音直播",
              "link": "src/字节/2025抖音直播"
            },
            {
              "text": "2025生服前端",
              "link": "src/字节/2025生服前端"
            },
            {
              "text": "2025番茄春招",
              "link": "src/字节/2025番茄春招"
            },
            {
              "text": "tac",
              "link": "src/字节/tac"
            },
            {
              "text": "互娱",
              "link": "src/字节/互娱"
            },
            {
              "text": "其七某部门",
              "link": "src/字节/其七某部门"
            },
            {
              "text": "其三某部门",
              "link": "src/字节/其三某部门"
            },
            {
              "text": "其二某部门秋招",
              "link": "src/字节/其二某部门秋招"
            },
            {
              "text": "其五某部门实习(质量不错)",
              "link": "src/字节/其五某部门实习(质量不错)"
            },
            {
              "text": "其六某部门秋招",
              "link": "src/字节/其六某部门秋招"
            },
            {
              "text": "其四某部门",
              "link": "src/字节/其四某部门"
            },
            {
              "text": "剪映",
              "link": "src/字节/剪映"
            },
            {
              "text": "国际化",
              "link": "src/字节/国际化"
            },
            {
              "text": "国际化其二",
              "link": "src/字节/国际化其二"
            },
            {
              "text": "国际电商",
              "link": "src/字节/国际电商"
            },
            {
              "text": "子公司",
              "items": [
                {
                  "text": "沐瞳9.17前端",
                  "link": "src/字节/子公司/沐瞳9.17前端"
                }
              ],
              "collapsed": true
            },
            {
              "text": "抖音电商",
              "link": "src/字节/抖音电商"
            },
            {
              "text": "抖音直播社招",
              "link": "src/字节/抖音直播社招"
            },
            {
              "text": "某部门一面",
              "link": "src/字节/某部门一面"
            },
            {
              "text": "某部门三面",
              "link": "src/字节/某部门三面"
            },
            {
              "text": "某部门秋招",
              "link": "src/字节/某部门秋招"
            },
            {
              "text": "汽水",
              "link": "src/字节/汽水"
            },
            {
              "text": "番茄",
              "link": "src/字节/番茄"
            },
            {
              "text": "社招",
              "link": "src/字节/社招"
            },
            {
              "text": "风控日常一面8.7",
              "link": "src/字节/风控日常一面8.7"
            },
            {
              "text": "风控日常三面8.19",
              "link": "src/字节/风控日常三面8.19"
            },
            {
              "text": "风控日常二面8.14",
              "link": "src/字节/风控日常二面8.14"
            },
            {
              "text": "飞书",
              "link": "src/字节/飞书"
            },
            {
              "text": "飞书一面",
              "link": "src/字节/飞书一面"
            }
          ],
          "collapsed": false
        },
        {
          "text": "小红书",
          "items": [
            {
              "text": "2025商业技术秋招",
              "link": "src/小红书/2025商业技术秋招"
            },
            {
              "text": "社区工程",
              "link": "src/小红书/社区工程"
            }
          ],
          "collapsed": false
        },
        {
          "text": "常规八股",
          "items": [
            {
              "text": "JS基础",
              "link": "src/常规八股/JS基础/index.md",
              "items": [
                {
                  "text": "Promise",
                  "link": "src/常规八股/JS基础/Promise"
                },
                {
                  "text": "字节的基础题",
                  "link": "src/常规八股/JS基础/字节的基础题"
                }
              ],
              "collapsed": true
            },
            {
              "text": "React",
              "link": "src/常规八股/React/index.md",
              "items": [],
              "collapsed": true
            },
            {
              "text": "微前端",
              "link": "src/常规八股/微前端/index.md",
              "items": [],
              "collapsed": true
            },
            {
              "text": "浏览器",
              "link": "src/常规八股/浏览器/index.md",
              "items": [],
              "collapsed": true
            }
          ],
          "collapsed": false
        },
        {
          "text": "快手",
          "items": [
            {
              "text": "某部门",
              "link": "src/快手/某部门"
            },
            {
              "text": "某部门二面",
              "link": "src/快手/某部门二面"
            }
          ],
          "collapsed": false
        },
        {
          "text": "拼多多",
          "items": [
            {
              "text": "2022秋招",
              "link": "src/拼多多/2022秋招"
            },
            {
              "text": "2024笔试",
              "link": "src/拼多多/2024笔试"
            },
            {
              "text": "2025暑期",
              "link": "src/拼多多/2025暑期"
            },
            {
              "text": "2025秋招9.1",
              "link": "src/拼多多/2025秋招9.1"
            }
          ],
          "collapsed": false
        },
        {
          "text": "携程",
          "items": [
            {
              "text": "2025秋招线下面",
              "link": "src/携程/2025秋招线下面"
            }
          ],
          "collapsed": false
        },
        {
          "text": "无名面经",
          "items": [
            {
              "text": "其一",
              "link": "src/无名面经/其一"
            },
            {
              "text": "其三",
              "link": "src/无名面经/其三"
            },
            {
              "text": "其二",
              "link": "src/无名面经/其二"
            },
            {
              "text": "其五",
              "link": "src/无名面经/其五"
            },
            {
              "text": "其四",
              "link": "src/无名面经/其四"
            }
          ],
          "collapsed": false
        },
        {
          "text": "滴滴",
          "items": [
            {
              "text": "其一一二三面",
              "link": "src/滴滴/其一一二三面"
            },
            {
              "text": "某部门",
              "link": "src/滴滴/某部门"
            },
            {
              "text": "某部门秋招一面",
              "link": "src/滴滴/某部门秋招一面"
            }
          ],
          "collapsed": false
        },
        {
          "text": "特斯拉",
          "items": [
            {
              "text": "其二特斯拉一面",
              "link": "src/特斯拉/其二特斯拉一面"
            },
            {
              "text": "特斯拉一面",
              "link": "src/特斯拉/特斯拉一面"
            }
          ],
          "collapsed": false
        },
        {
          "text": "百度",
          "items": [
            {
              "text": "其三提前批",
              "link": "src/百度/其三提前批"
            },
            {
              "text": "某部门提前批",
              "link": "src/百度/某部门提前批"
            },
            {
              "text": "某部门秋招",
              "link": "src/百度/某部门秋招"
            }
          ],
          "collapsed": false
        },
        {
          "text": "算法手撕",
          "link": "src/算法手撕/index.md",
          "items": [
            {
              "text": "JsAPI",
              "link": "src/算法手撕/JsAPI"
            },
            {
              "text": "PromiseAPI",
              "link": "src/算法手撕/PromiseAPI"
            },
            {
              "text": "其他",
              "link": "src/算法手撕/其他"
            },
            {
              "text": "字节合集",
              "link": "src/算法手撕/字节合集"
            },
            {
              "text": "美团合集",
              "link": "src/算法手撕/美团合集"
            }
          ],
          "collapsed": false
        },
        {
          "text": "网易",
          "items": [
            {
              "text": "日常其一",
              "link": "src/网易/日常其一"
            }
          ],
          "collapsed": false
        },
        {
          "text": "美团",
          "items": [
            {
              "text": "2022年闪购",
              "link": "src/美团/2022年闪购"
            },
            {
              "text": "2025暑期二面",
              "link": "src/美团/2025暑期二面"
            },
            {
              "text": "2025闪购二面",
              "link": "src/美团/2025闪购二面"
            },
            {
              "text": "上海到综一面",
              "link": "src/美团/上海到综一面"
            },
            {
              "text": "其二某部门",
              "link": "src/美团/其二某部门"
            },
            {
              "text": "北京光年之外",
              "link": "src/美团/北京光年之外"
            },
            {
              "text": "某部门",
              "link": "src/美团/某部门"
            },
            {
              "text": "某部门二面",
              "link": "src/美团/某部门二面"
            },
            {
              "text": "食杂零售暑期",
              "link": "src/美团/食杂零售暑期"
            }
          ],
          "collapsed": false
        },
        {
          "text": "腾讯",
          "items": [
            {
              "text": "CDG",
              "items": [
                {
                  "text": "其二秋招一面",
                  "link": "src/腾讯/CDG/其二秋招一面"
                },
                {
                  "text": "秋招cdg金融一面",
                  "link": "src/腾讯/CDG/秋招cdg金融一面"
                }
              ],
              "collapsed": true
            },
            {
              "text": "CSIG",
              "items": [
                {
                  "text": "csig腾讯云一面",
                  "link": "src/腾讯/CSIG/csig腾讯云一面"
                }
              ],
              "collapsed": true
            },
            {
              "text": "IEG",
              "items": [
                {
                  "text": "ieg 游戏流量中台一面二面三面",
                  "link": "src/腾讯/IEG/ieg 游戏流量中台一面二面三面"
                }
              ],
              "collapsed": true
            },
            {
              "text": "PCG",
              "items": [
                {
                  "text": "pcg qq一面",
                  "link": "src/腾讯/PCG/pcg qq一面"
                }
              ],
              "collapsed": true
            },
            {
              "text": "Unknown",
              "items": [
                {
                  "text": "其一某部门加面",
                  "link": "src/腾讯/Unknown/其一某部门加面"
                }
              ],
              "collapsed": true
            },
            {
              "text": "csig 腾讯云一面",
              "link": "src/腾讯/csig 腾讯云一面"
            },
            {
              "text": "ieg春招",
              "link": "src/腾讯/ieg春招"
            },
            {
              "text": "tme",
              "items": [
                {
                  "text": "2023暑期",
                  "link": "src/腾讯/tme/2023暑期"
                },
                {
                  "text": "2024暑期",
                  "link": "src/腾讯/tme/2024暑期"
                },
                {
                  "text": "其一2025暑期",
                  "link": "src/腾讯/tme/其一2025暑期"
                },
                {
                  "text": "其一不知名面经",
                  "link": "src/腾讯/tme/其一不知名面经"
                },
                {
                  "text": "其三2025暑期",
                  "link": "src/腾讯/tme/其三2025暑期"
                },
                {
                  "text": "其三不知名面经",
                  "link": "src/腾讯/tme/其三不知名面经"
                },
                {
                  "text": "其二2025暑期",
                  "link": "src/腾讯/tme/其二2025暑期"
                },
                {
                  "text": "其二不知名面经",
                  "link": "src/腾讯/tme/其二不知名面经"
                },
                {
                  "text": "其四2025暑期",
                  "link": "src/腾讯/tme/其四2025暑期"
                }
              ],
              "collapsed": true
            },
            {
              "text": "wxg",
              "items": [
                {
                  "text": "2020微信支付社招",
                  "link": "src/腾讯/wxg/2020微信支付社招"
                },
                {
                  "text": "2021wxgcdg实习",
                  "link": "src/腾讯/wxg/2021wxgcdg实习"
                },
                {
                  "text": "2024企业微信暑期",
                  "link": "src/腾讯/wxg/2024企业微信暑期"
                },
                {
                  "text": "基础微信&视频号",
                  "link": "src/腾讯/wxg/基础微信&视频号"
                }
              ],
              "collapsed": true
            },
            {
              "text": "wxg 公众号&小程序一面",
              "link": "src/腾讯/wxg 公众号&小程序一面"
            },
            {
              "text": "企业微信日常一面",
              "link": "src/腾讯/企业微信日常一面"
            },
            {
              "text": "微信公众号小程序",
              "link": "src/腾讯/微信公众号小程序"
            },
            {
              "text": "微信支付简单一面",
              "link": "src/腾讯/微信支付简单一面"
            },
            {
              "text": "某部门",
              "link": "src/腾讯/某部门"
            },
            {
              "text": "某部门一面",
              "link": "src/腾讯/某部门一面"
            },
            {
              "text": "某部门其二",
              "link": "src/腾讯/某部门其二"
            },
            {
              "text": "腾讯广告暑期一面",
              "link": "src/腾讯/腾讯广告暑期一面"
            }
          ],
          "collapsed": false
        },
        {
          "text": "虾皮",
          "items": [
            {
              "text": "虾皮一面",
              "link": "src/虾皮/虾皮一面"
            }
          ],
          "collapsed": false
        },
        {
          "text": "阿里",
          "items": [
            {
              "text": "2025.5.28蚂蚁国际一面",
              "link": "src/阿里/2025.5.28蚂蚁国际一面"
            },
            {
              "text": "菜鸟",
              "items": [
                {
                  "text": "2025社招",
                  "link": "src/阿里/菜鸟/2025社招"
                }
              ],
              "collapsed": true
            }
          ],
          "collapsed": false
        }
      ]
    }
  },
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/mameikagou/vitepress-template"
    }
  ]
}

Page Data

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

Page Frontmatter

{
  "outline": "deep"
}

More

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

本站访客数 人次 本站总访问量