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

{
  "docFooter": {
    "prev": "上一页",
    "next": "下一页"
  },
  "outline": {
    "label": "本页目录"
  },
  "lightModeSwitchTitle": "切换到浅色主题",
  "darkModeSwitchTitle": "切换到深色主题",
  "sidebarMenuLabel": "菜单",
  "returnToTopLabel": "返回顶部",
  "nav": [
    {
      "text": "首页",
      "link": "/"
    },
    {
      "text": "💯考试",
      "items": [
        {
          "text": "软考",
          "items": [
            {
              "text": "软件设计师",
              "link": "/softExam/designer/computerStructure"
            },
            {
              "text": "系统架构师",
              "link": "/softExam/architect/computerHardware"
            }
          ]
        },
        {
          "text": "公考",
          "items": [
            {
              "text": "历年真题",
              "link": "/civilServant/realQuestion/guangdong/aat/2023-county"
            },
            {
              "text": "笔记资料",
              "link": "/civilServant/generalKnowledge/gd"
            },
            {
              "text": "分析",
              "link": "/civilServant/analysis/gd/numericalReasoning/realQuestion"
            },
            {
              "text": "错题本",
              "link": "/civilServant/errorNotebook/2025-2-19"
            }
          ]
        }
      ]
    },
    {
      "text": "AI",
      "link": "/ai/home"
    },
    {
      "text": "好用的工具",
      "link": "/tools/easyUse"
    },
    {
      "text": "前端",
      "items": [
        {
          "text": "Vue3",
          "items": [
            {
              "text": "组件收集",
              "link": "/vue3/components/mindmap/example"
            }
          ]
        },
        {
          "text": "测试",
          "link": "/frontendProject/test"
        }
      ]
    },
    {
      "text": "后端",
      "link": "/backendProject/test"
    },
    {
      "text": "Debian 12",
      "link": "/debian12/init/install"
    },
    {
      "text": "PVE",
      "link": "/pve/install"
    },
    {
      "text": "Docker",
      "link": "/docker/common/command"
    }
  ],
  "sidebar": {
    "/frontendProject/": [
      {
        "items": [
          {
            "text": "前端项目",
            "items": [
              {
                "text": "测试",
                "link": "/frontendProject/test"
              }
            ]
          }
        ]
      }
    ],
    "/backendProject/": [
      {
        "items": [
          {
            "text": "后端项目",
            "items": [
              {
                "text": "测试",
                "link": "/backendProject/test"
              }
            ]
          }
        ]
      }
    ],
    "/docker/": [
      {
        "items": [
          {
            "text": "通用",
            "items": [
              {
                "text": "常用命令",
                "link": "/docker/common/command"
              },
              {
                "text": "网桥",
                "link": "/docker/common/network"
              },
              {
                "text": "更改存储目录",
                "link": "/docker/common/updatePath"
              },
              {
                "text": "将镜像上传到 Harbor",
                "link": "/docker/common/uploadHarbor"
              },
              {
                "text": "将镜像做成外部包",
                "link": "/docker/common/offline"
              }
            ]
          },
          {
            "text": "Docker软件安装",
            "items": [
              {
                "text": "中间件",
                "collapsed": false,
                "items": [
                  {
                    "text": "Nginx相关",
                    "items": [
                      {
                        "text": "Nginx",
                        "link": "/docker/middleware/nginx"
                      },
                      {
                        "text": "Nginx-UI(推荐)",
                        "link": "/docker/middleware/nginx-ui"
                      },
                      {
                        "text": "SSL证书",
                        "link": "/docker/middleware/ssl"
                      }
                    ]
                  },
                  {
                    "text": "Mysql",
                    "link": "/docker/middleware/mysql"
                  },
                  {
                    "text": "Sqlserver",
                    "link": "/docker/middleware/sqlserver"
                  },
                  {
                    "text": "Redis",
                    "link": "/docker/middleware/redis"
                  },
                  {
                    "text": "Nacos",
                    "link": "/docker/middleware/nacos"
                  },
                  {
                    "text": "xxl-job",
                    "link": "/docker/middleware/xxljob"
                  },
                  {
                    "text": "Minio",
                    "link": "/docker/middleware/minio"
                  },
                  {
                    "text": "Nexus",
                    "link": "/docker/middleware/nexus"
                  },
                  {
                    "text": "Harbor",
                    "link": "/docker/middleware/harbor"
                  },
                  {
                    "text": "建木",
                    "link": "/docker/middleware/jianmu"
                  }
                ]
              },
              {
                "text": "其他",
                "collapsed": false,
                "items": [
                  {
                    "text": "Filebrowser 文件管理",
                    "link": "/docker/other/filebrowser"
                  },
                  {
                    "text": "HomePage 自定义主页",
                    "link": "/docker/other/homePage"
                  },
                  {
                    "text": "Navidrome 音乐服务器",
                    "link": "/docker/other/navidrome"
                  },
                  {
                    "text": "komga 漫画服务器",
                    "link": "/docker/other/komga"
                  },
                  {
                    "text": "DDNS",
                    "link": "/docker/other/ddns"
                  },
                  {
                    "text": "Vaultwarden密码管理",
                    "link": "/docker/other/vaultwarden"
                  }
                ]
              }
            ]
          }
        ]
      }
    ],
    "/debian12/": [
      {
        "items": [
          {
            "text": "初始化",
            "items": [
              {
                "text": "系统安装",
                "link": "/debian12/init/install"
              },
              {
                "text": "开启 root 用户 SSH",
                "link": "/debian12/init/ssh"
              },
              {
                "text": "解决 nano 中文乱码",
                "link": "/debian12/init/nano"
              },
              {
                "text": "设置 静态 IP",
                "link": "/debian12/init/ip"
              },
              {
                "text": "配置 apt 源",
                "link": "/debian12/init/apt"
              },
              {
                "text": "安装 sudo",
                "link": "/debian12/init/sudo"
              },
              {
                "text": "挂载 硬盘(物理)",
                "link": "/debian12/init/disk"
              },
              {
                "text": "挂载 硬盘(逻辑) 推荐",
                "items": [
                  {
                    "text": "之前没挂载过时",
                    "link": "/debian12/init/diskLVM"
                  },
                  {
                    "text": "物理挂载过时",
                    "link": "/debian12/init/diskLVMOld"
                  },
                  {
                    "text": "动态扩容",
                    "link": "/debian12/init/diskLVMDynamic"
                  },
                  {
                    "text": "删除卷组",
                    "link": "/debian12/init/diskLVMDel"
                  }
                ]
              },
              {
                "text": "安装 Docker",
                "link": "/debian12/init/docker"
              },
              {
                "text": "安装 Docker Compose",
                "link": "/debian12/init/dockerCompose"
              }
            ]
          },
          {
            "text": "常用命令",
            "items": [
              {
                "text": "用户相关",
                "link": "/debian12/command/user"
              },
              {
                "text": "LVM硬盘相关",
                "link": "/debian12/command/lvm2"
              }
            ]
          }
        ]
      }
    ],
    "/pve/": [
      {
        "items": [
          {
            "text": "PVE",
            "items": [
              {
                "text": "系统安装",
                "link": "/pve/install"
              },
              {
                "text": "OpenWRT",
                "link": "/pve/openWrt"
              }
            ]
          }
        ]
      }
    ],
    "/softExam/designer/": [
      {
        "items": [
          {
            "text": "目录",
            "items": [
              {
                "text": "计算机的组成和结构",
                "link": "/softExam/designer/computerStructure"
              }
            ]
          }
        ]
      }
    ],
    "/softExam/architect/": [
      {
        "items": [
          {
            "text": "目录",
            "items": [
              {
                "text": "计算机硬件",
                "link": "/softExam/architect/computerHardware"
              }
            ]
          }
        ]
      }
    ],
    "/civilServant/": [
      {
        "items": [
          {
            "text": "全国重要会议",
            "collapsed": false,
            "items": [
              {
                "text": "二十届三中全会",
                "collapsed": false,
                "items": [
                  {
                    "text": "重要考点梳理-李铁",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/GKA/20sz01"
                  },
                  {
                    "text": "重要考点梳理(全文)-李铁",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/GKA/20sz02"
                  },
                  {
                    "text": "真题答案梳理",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/GKA/20sz03"
                  },
                  {
                    "text": "真题答案默写自测",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/GKA/20sz04"
                  }
                ]
              },
              {
                "text": "二十次全国代表大会",
                "collapsed": false,
                "items": [
                  {
                    "text": "重要考点梳理—李铁",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/GKA/20da02"
                  },
                  {
                    "text": "重要考点梳理(全文)-李铁",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/GKA/20da01"
                  },
                  {
                    "text": "30个必考点-李梦娇",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/GKA/20da03"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "items": [
          {
            "text": "常识",
            "collapsed": false,
            "items": [
              {
                "text": "法律",
                "collapsed": false,
                "items": [
                  {
                    "text": "法理学",
                    "collapsed": true,
                    "link": "/civilServant/commonSense/law/jurisprudence"
                  },
                  {
                    "text": "宪法",
                    "collapsed": true,
                    "link": "/civilServant/commonSense/law/constitution"
                  },
                  {
                    "text": "行政法",
                    "collapsed": true,
                    "link": "/civilServant/commonSense/law/administrative"
                  },
                  {
                    "text": "刑法",
                    "collapsed": true,
                    "link": "/civilServant/commonSense/law/penalCode"
                  },
                  {
                    "text": "民法",
                    "collapsed": true,
                    "link": "/civilServant/commonSense/law/civilLaw"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "items": [
          {
            "text": "广东",
            "collapsed": false,
            "items": [
              {
                "text": "规律统计",
                "collapsed": false,
                "items": [
                  {
                    "text": "数字推理",
                    "collapsed": true,
                    "link": "/civilServant/gd/numerical"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "items": [
          {
            "text": "逻辑判断",
            "collapsed": false,
            "items": [
              {
                "text": "翻译推理",
                "collapsed": true,
                "link": "/civilServant/commonSense/jr/translation"
              },
              {
                "text": "真假推理",
                "collapsed": true,
                "link": "/civilServant/commonSense/jr/trueAndFalseReasoning"
              }
            ]
          }
        ]
      },
      {
        "items": [
          {
            "text": "目录",
            "items": [
              {
                "text": "省情",
                "collapsed": false,
                "items": [
                  {
                    "text": "广东",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/gd"
                  }
                ]
              },
              {
                "text": "时政",
                "collapsed": false,
                "items": [
                  {
                    "text": "25广东政府工作报告-李铁",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/GKA/gd2025-GRA"
                  },
                  {
                    "text": "25广东政府工作报告划重点",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/GKA/gd2025-GRA-other"
                  },
                  {
                    "text": "25广东高质量发展大会-李铁",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/GKA/gd2025-fz"
                  }
                ]
              },
              {
                "text": "常识25页速记",
                "collapsed": true,
                "link": "/civilServant/generalKnowledge/cs"
              },
              {
                "text": "🥜花生十三高频成语700词",
                "collapsed": true,
                "link": "/civilServant/generalKnowledge/hs13Idiom"
              },
              {
                "text": "三色笔记",
                "collapsed": false,
                "items": [
                  {
                    "text": "三色笔记(理)",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/three/l"
                  },
                  {
                    "text": "三色笔记(文)",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/three/w"
                  }
                ]
              },
              {
                "text": "党史",
                "collapsed": false,
                "items": [
                  {
                    "text": "自整理",
                    "collapsed": true,
                    "link": "/civilServant/generalKnowledge/CPCHistory/zyArrange"
                  }
                ]
              },
              {
                "text": "法理学",
                "collapsed": false,
                "items": [
                  {
                    "text": "法理学1",
                    "collapsed": true,
                    "link": "/civilServant/jurisprudence/jurisprudence1"
                  },
                  {
                    "text": "法理学2",
                    "collapsed": true,
                    "link": "/civilServant/jurisprudence/jurisprudence2"
                  },
                  {
                    "text": "法理学3",
                    "collapsed": true,
                    "link": "/civilServant/jurisprudence/jurisprudence3"
                  },
                  {
                    "text": "法理学4",
                    "collapsed": true,
                    "link": "/civilServant/jurisprudence/jurisprudence4"
                  }
                ]
              }
            ]
          }
        ]
      }
    ],
    "/civilServant/realQuestion/": [
      {
        "items": [
          {
            "text": "广东",
            "collapsed": false,
            "items": [
              {
                "text": "行测",
                "collapsed": false,
                "items": [
                  {
                    "text": "县级",
                    "collapsed": true,
                    "items": [
                      {
                        "text": "2024",
                        "link": "/civilServant/realQuestion/guangdong/aat/2024-county"
                      },
                      {
                        "text": "2023",
                        "link": "/civilServant/realQuestion/guangdong/aat/2023-county"
                      },
                      {
                        "text": "2022",
                        "link": "/civilServant/realQuestion/guangdong/aat/2022-county"
                      },
                      {
                        "text": "2021",
                        "link": "/civilServant/realQuestion/guangdong/aat/2021-county"
                      },
                      {
                        "text": "2020",
                        "link": "/civilServant/realQuestion/guangdong/aat/2020-county"
                      },
                      {
                        "text": "2019",
                        "link": "/civilServant/realQuestion/guangdong/aat/2019-county"
                      }
                    ]
                  },
                  {
                    "text": "乡镇",
                    "collapsed": true,
                    "items": [
                      {
                        "text": "2023",
                        "link": "/civilServant/realQuestion/guangdong/aat/2023-township"
                      },
                      {
                        "text": "2022",
                        "link": "/civilServant/realQuestion/guangdong/aat/2022-township"
                      },
                      {
                        "text": "2021",
                        "link": "/civilServant/realQuestion/guangdong/aat/2021-township"
                      },
                      {
                        "text": "2020",
                        "link": "/civilServant/realQuestion/guangdong/aat/2020-township"
                      },
                      {
                        "text": "2019",
                        "link": "/civilServant/realQuestion/guangdong/aat/2019-township"
                      }
                    ]
                  }
                ]
              },
              {
                "text": "事业单位统考",
                "collapsed": false,
                "items": [
                  {
                    "text": "2024",
                    "link": "/civilServant/realQuestion/guangdong/npe/2024"
                  },
                  {
                    "text": "2023",
                    "link": "/civilServant/realQuestion/guangdong/npe/2023"
                  },
                  {
                    "text": "2022",
                    "link": "/civilServant/realQuestion/guangdong/npe/2022"
                  },
                  {
                    "text": "2021",
                    "link": "/civilServant/realQuestion/guangdong/npe/2021"
                  },
                  {
                    "text": "2020",
                    "link": "/civilServant/realQuestion/guangdong/npe/2020"
                  }
                ]
              },
              {
                "text": "申论",
                "collapsed": false,
                "items": [
                  {
                    "text": "县级",
                    "collapsed": true,
                    "items": [
                      {
                        "text": "2023",
                        "link": "/civilServant/realQuestion/guangdong/ew/2023-county"
                      },
                      {
                        "text": "2022",
                        "link": "/civilServant/realQuestion/guangdong/ew/2022-county"
                      },
                      {
                        "text": "2021",
                        "link": "/civilServant/realQuestion/guangdong/ew/2021-county"
                      },
                      {
                        "text": "2020",
                        "link": "/civilServant/realQuestion/guangdong/ew/2020-county"
                      },
                      {
                        "text": "2019",
                        "link": "/civilServant/realQuestion/guangdong/ew/2019-county"
                      }
                    ]
                  },
                  {
                    "text": "乡镇",
                    "collapsed": true,
                    "items": [
                      {
                        "text": "2023",
                        "link": "/civilServant/realQuestion/guangdong/ew/2023-township"
                      },
                      {
                        "text": "2022",
                        "link": "/civilServant/realQuestion/guangdong/ew/2022-township"
                      },
                      {
                        "text": "2021",
                        "link": "/civilServant/realQuestion/guangdong/ew/2021-township"
                      },
                      {
                        "text": "2020",
                        "link": "/civilServant/realQuestion/guangdong/ew/2020-township"
                      },
                      {
                        "text": "2019",
                        "link": "/civilServant/realQuestion/guangdong/ew/2019-township"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    ],
    "/civilServant/errorNotebook/": [
      {
        "text": "2025年2月19日",
        "collapsed": true,
        "link": "/civilServant/errorNotebook/2025-2-19"
      },
      {
        "text": "2025年2月23日",
        "collapsed": true,
        "link": "/civilServant/errorNotebook/2025-2-23"
      },
      {
        "text": "2025年2月24日",
        "collapsed": true,
        "link": "/civilServant/errorNotebook/2025-2-24"
      }
    ],
    "/civilServant/analysis/": [
      {
        "items": [
          {
            "text": "广东",
            "collapsed": false,
            "items": [
              {
                "text": "数字推理",
                "collapsed": false,
                "items": [
                  {
                    "text": "近5年真题",
                    "collapsed": true,
                    "link": "/civilServant/analysis/gd/numericalReasoning/realQuestion"
                  },
                  {
                    "text": "总结",
                    "collapsed": true,
                    "link": "/civilServant/analysis/gd/numericalReasoning/summarize"
                  }
                ]
              },
              {
                "text": "图形推理",
                "collapsed": false,
                "items": [
                  {
                    "text": "近5年真题",
                    "collapsed": true,
                    "link": "/civilServant/analysis/gd/figuralReasoning/realQuestion"
                  },
                  {
                    "text": "总结",
                    "collapsed": true,
                    "link": "/civilServant/analysis/gd/figuralReasoning/summarize"
                  }
                ]
              }
            ]
          }
        ]
      }
    ],
    "/vue3/": [
      {
        "items": [
          {
            "text": "Vue3 组件收集",
            "items": [
              {
                "text": "思维导图",
                "items": [
                  {
                    "text": "例子",
                    "link": "/vue3/components/mindmap/example"
                  },
                  {
                    "text": "安装说明",
                    "link": "/vue3/components/mindmap/install"
                  },
                  {
                    "text": "在 VitePress 中配置使用",
                    "link": "/vue3/components/mindmap/vitePressExample"
                  }
                ]
              },
              {
                "text": "Excel公式计算",
                "items": [
                  {
                    "text": "例子",
                    "link": "/vue3/components/excelFormula/example"
                  },
                  {
                    "text": "安装说明",
                    "link": "/vue3/components/excelFormula/install"
                  },
                  {
                    "text": "在 VitePress 中配置使用",
                    "link": "/vue3/components/excelFormula/vitePressExample"
                  }
                ]
              }
            ]
          }
        ]
      }
    ],
    "/ai/": [
      {
        "items": [
          {
            "text": "主页",
            "link": "/ai/home"
          },
          {
            "text": "基础镜像",
            "link": "/ai/base-images/cuda"
          },
          {
            "text": "TTS",
            "items": [
              {
                "text": "介绍",
                "link": "/ai/tts/主页"
              },
              {
                "text": "CosyVoice",
                "link": "/ai/tts/CosyVoice"
              },
              {
                "text": "Kokoro",
                "link": "/ai/tts/Kokoro"
              },
              {
                "text": "对比",
                "link": "/ai/tts/对比"
              }
            ]
          },
          {
            "text": "本地部署",
            "items": [
              {
                "text": "VLLM",
                "collapsed": false,
                "items": [
                  {
                    "text": "部署流程",
                    "link": "/ai/vllm"
                  }
                ]
              }
            ]
          },
          {
            "text": "Comfy-UI",
            "items": [
              {
                "text": "安装",
                "link": "/ai/comfy-ui/install"
              }
            ]
          },
          {
            "text": "Asr",
            "items": [
              {
                "text": "FunAsr",
                "link": "/ai/asr/funAsr"
              }
            ]
          },
          {
            "text": "n8n",
            "items": [
              {
                "text": "安装",
                "link": "/ai/n8n/install"
              }
            ]
          }
        ]
      }
    ],
    "/tools/": [
      {
        "items": [
          {
            "text": "主页",
            "link": "/tools/easyUse"
          }
        ]
      }
    ]
  },
  "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.