Runtime API Examples
作者: ryan 发布于: 2025/5/9 更新于: 2025/5/9 字数: 0 字 阅读: 0 分钟
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.png", "siteTitle": "欣语漫言", "sidebarMenuLabel": "菜单", "returnToTopLabel": "返回顶部", "darkModeSwitchLabel": "外观", "lightModeSwitchTitle": "切换到浅色模式", "darkModeSwitchTitle": "切换到深色模式", "nav": [ { "text": "Home", "link": "/" }, { "text": "云原生", "items": [ { "text": "运行时", "items": [ { "text": "Docker", "link": "/cloudnative/docker/docker-base" }, { "text": "Containerd", "link": "/cloudnative/containerd/containerd" } ] }, { "text": "调度与编排", "items": [ { "text": "Kubernetes", "link": "/cloudnative/k8s/2" }, { "text": "Rancher", "link": "/fe/javascript/types" }, { "text": "kubeSphere", "link": "/fe/javascript/types" }, { "text": "Kuboard", "link": "/fe/css/" } ] }, { "text": "云原生存储", "items": [ { "text": "CubeFS", "link": "/fe/typescript/base" }, { "text": "Longhorn", "link": "/fe/typescript/challenges" }, { "text": "Ceph", "link": "/fe/typescript/challenges" }, { "text": "Rook", "link": "/fe/typescript/challenges" } ] }, { "text": "监控集群", "items": [ { "text": "Prometheus", "link": "/cloudnative/prometheus/61_Prometheus基础" }, { "text": "VictoriaMetrics", "link": "/fe/browser/" }, { "text": "Loki", "link": "/fe/coding/" } ] } ], "activeMatch": "^/cloudnative/" }, { "text": "DevOps", "items": [ { "text": "持续集成与交付", "activeMatch": "^/cicd", "items": [ { "text": "Jenkins", "link": "/cicd/Jenkins Slave" }, { "text": "Tekton", "link": "/cicd/Tekton/1_Tekton", "activeMatch": "^/cicd/Tekton" }, { "text": "Argo CD", "link": "/cicd/1_Tekton" } ] }, { "text": "镜像", "items": [ { "text": "Harbor", "link": "/pit/npm" }, { "text": "Helm", "link": "/pit/npm" }, { "text": "Dockerfile", "link": "/pit/npm" } ] } ], "activeMatch": "^/daily-notes|pit" }, { "text": "后端", "items": [ { "text": "Go 语言", "activeMatch": "^/go", "items": [ { "text": "语言基础", "link": "/go/basic/gohistory/" }, { "text": "数据结构", "link": "/go/log/strconv" }, { "text": "函数", "link": "/go/basic/2_Anonymous_Function" }, { "text": "结构体与接口", "link": "/go/basic//go/basic/6_struct" }, { "text": "包管理", "link": "/go/basic/3_Recursive_Functions" }, { "text": "日志", "link": "/go/basic/4_Closure" }, { "text": "数据库", "link": "/go/basic/5_defer" }, { "text": "ORM框架", "link": "/go/basic/6_struct" }, { "text": "多线程编程", "link": "/go/basic/6_struct" }, { "text": "TCP编程", "link": "/go/basic/6_struct" }, { "text": "携程与通道", "link": "/go/basic/6_struct" } ] } ], "activeMatch": "^/daily-notes|pit" }, { "text": "笔记", "items": [ { "text": "日常笔记", "link": "/daily-notes/index", "activeMatch": "^/daily-notes" }, { "text": "踩坑记录", "items": [] } ], "activeMatch": "^/daily-note2|pit" }, { "text": "提效工具", "items": [ { "text": "软件推荐与配置", "items": [ { "text": "多平台软件", "link": "/efficiency/software/cross-platform" }, { "text": "Mac 平台", "link": "/efficiency/software/mac" }, { "text": "Windows 平台", "link": "/efficiency/software/windows" }, { "text": "浏览器设置与扩展", "link": "/efficiency/software/browser" } ] }, { "text": "在线工具", "link": "/efficiency/online-tools" } ], "activeMatch": "^/efficiency" } ], "sidebar": { "/cloudnative/": [ { "text": "运行时", "link": "/cloudnative", "collapsed": true, "items": [ { "text": "Docker", "link": "/cloudnative/docker/docker-base" }, { "text": "Containerd", "link": "/cloudnative/containerd/containerd.html" } ] }, { "text": "Kubernetes", "link": "/cloudnative", "collapsed": true, "items": [ { "text": "基础", "collapsed": true, "items": [ { "text": "集群部署", "link": "/cloudnative/k8s/2" }, { "text": "资源清单", "link": "/cloudnative/k8s/212" }, { "text": "Pod", "link": "/cloudnative/k8s/213" } ] }, { "text": "控制器", "collapsed": true, "items": [ { "text": "ReplicaSet 控制器", "link": "/cloudnative/k8s/222" }, { "text": "Deployment 控制器 ", "link": "/cloudnative/k8s/333" }, { "text": "StatefulSet 控制器", "link": "/cloudnative/k8s/444" }, { "text": "DaemonSet 与 Job", "link": "/cloudnative/k8s/555" }, { "text": "HPA", "link": "/cloudnative/k8s/666" }, { "text": "Admission", "link": "/cloudnative/k8s/666" }, { "text": "CRD", "link": "/cloudnative/k8s/7776" } ] }, { "text": "配置管理", "collapsed": true, "items": [ { "text": "ConfigMap", "link": "/cloudnative/k8s/311" }, { "text": "Secret", "link": "/cloudnative/k8s/312" }, { "text": "RBAC", "link": "/cloudnative/k8s/313" }, { "text": "Security Context", "link": "/cloudnative/k8s/314" } ] }, { "text": "网络", "collapsed": true, "items": [ { "text": "Service", "link": "/cloudnative/k8s/411" }, { "text": "服务发现", "link": "/cloudnative/k8s/412" }, { "text": "LocalDNS", "link": "/cloudnative/k8s/413" }, { "text": "ingress", "link": "/cloudnative/k8s/414" }, { "text": "Ingress-nginx", "link": "/cloudnative/k8s/414" }, { "text": "Traefik", "link": "/cloudnative/k8s/415" }, { "text": "APISIX", "link": "/cloudnative/k8s/416" } ] }, { "text": "调度器", "collapsed": true, "items": [ { "text": "调度器原理", "link": "/cloudnative/k8s/511" }, { "text": "亲合性调度", "link": "/cloudnative/k8s/512" }, { "text": "拓扑分布约束", "link": "/cloudnative/k8s/513" }, { "text": "Descheduler", "link": "/cloudnative/k8s/514" } ] } ] }, { "text": "Rancher", "link": "/cloudnative/rancher", "collapsed": true }, { "text": "KubeSphere", "link": "/cloudnative/KubeSphere", "collapsed": true }, { "text": "Kobard", "link": "/cloudnative/Kobard", "collapsed": true }, { "text": "存储", "collapsed": true, "items": [ { "text": "CubeFS", "collapsed": true, "items": [ { "text": "集群部署", "link": "/cloudnative/k8s/2" }, { "text": "资源清单", "link": "/cloudnative/k8s/212" }, { "text": "Pod", "link": "/cloudnative/k8s/213" } ] }, { "text": "Longhorn", "collapsed": true, "items": [ { "text": "ReplicaSet 控制器", "link": "/cloudnative/k8s/222" }, { "text": "Deployment 控制器 ", "link": "/cloudnative/k8s/333" }, { "text": "StatefulSet 控制器", "link": "/cloudnative/k8s/444" }, { "text": "DaemonSet 与 Job", "link": "/cloudnative/k8s/555" }, { "text": "HPA", "link": "/cloudnative/k8s/666" }, { "text": "Admission", "link": "/cloudnative/k8s/666" }, { "text": "CRD", "link": "/cloudnative/k8s/7776" } ] }, { "text": "Ceph", "collapsed": true, "items": [ { "text": "ReplicaSet 控制器", "link": "/cloudnative/k8s/222" }, { "text": "Deployment 控制器 ", "link": "/cloudnative/k8s/333" } ] }, { "text": "Rook", "collapsed": true, "items": [ { "text": "ReplicaSet 控制器", "link": "/cloudnative/k8s/222" }, { "text": "Deployment 控制器 ", "link": "/cloudnative/k8s/333" } ] } ] }, { "text": "集群监控", "collapsed": true, "items": [ { "text": "Prometheus", "collapsed": true, "items": [ { "text": "安装部署", "link": "/cloudnative/prometheus/61_Prometheus基础" }, { "text": "exporter监控", "link": "/cloudnative/prometheus/62_Prometheus应用监控" }, { "text": "容器监控", "link": "/cloudnative/prometheus/63_基于Kubernetes服务发现" }, { "text": "监控Pods", "link": "/cloudnative/prometheus/64_监控Pods" }, { "text": "PromQL", "link": "/cloudnative/prometheus/65_PromQL" }, { "text": "Grafana数据可视化", "link": "/cloudnative/prometheus/66_Grafana_数据可视化" } ] }, { "text": "VictoriaMetrics", "collapsed": true, "items": [ { "text": "ReplicaSet 控制器", "link": "/cloudnative/k8s/222" }, { "text": "Deployment 控制器 ", "link": "/cloudnative/k8s/333" } ] }, { "text": "Loki", "collapsed": true, "items": [ { "text": "ReplicaSet 控制器", "link": "/cloudnative/k8s/222" }, { "text": "Deployment 控制器 ", "link": "/cloudnative/k8s/333" } ] } ] }, { "text": "", "link": "", "collapsed": true } ], "/config/": [ { "text": "配置指南", "items": [ { "text": "概览", "link": "/config/" }, { "text": "三方配置", "link": "/config/three" }, { "text": "四方配置", "link": "/config/four" } ] } ], "/cicd/": [ { "text": "持续集成", "items": [ { "text": "Jenkins", "link": "/cicd/Jenkins Slave" }, { "text": "Tekton", "link": "/cicd/Tekton/1_Tekton", "collapsed": false, "items": [ { "text": "Tekton 安装部署", "link": "/cicd/Tekton/1_Tekton" }, { "text": "Pipeline", "link": "/cicd/Tekton/2_Tekton流水线" }, { "text": "Triggers", "link": "/cicd/Tekton/3_Tekton触发器和事件监听器" }, { "text": "Tekton 项目实战", "link": "/cicd/Tekton/4_Tekton项目实战.md" } ] } ] } ], "/go/basic/": [ { "text": "Go基础部分", "link": "/go/go-basic-syntax/", "collapsed": false, "items": [ { "text": "语言基础", "collapsed": true, "items": [ { "text": "GO发展历程", "link": "/go/basic/gohistory" }, { "text": "开发环境", "link": "/cloudnative/k8s/2" }, { "text": "计算机基础知识", "link": "/cloudnative/k8s/2" }, { "text": "语法基础", "link": "/cloudnative/k8s/2" }, { "text": "程序控制", "link": "/cloudnative/k8s/2" } ] }, { "text": "数据结构", "link": "/go/go-basic-syntax/", "collapsed": true, "items": [ { "text": "线性数据结构", "collapsed": true }, { "text": "数组", "collapsed": true }, { "text": "切片", "collapsed": true }, { "text": "常见线性数据结构", "collapsed": true }, { "text": "字符集", "collapsed": true }, { "text": "字符串", "collapsed": true }, { "text": "哈希表", "collapsed": true } ] }, { "text": "函数", "link": "/go/go-basic-syntax/", "collapsed": true, "items": [ { "text": "函数定义", "link": "/go/basic/2_Anonymous_Function", "collapsed": true, "items": [] }, { "text": "作用域", "link": "/go/basic/1_scope" }, { "text": "匿名函数", "link": "/go/basic/2_Anonymous_Function" }, { "text": "递归函数", "link": "/go/basic/3_Recursive_Functions" }, { "text": "闭包", "link": "/go/basic/4_Closure" }, { "text": "Defer", "link": "/go/basic/5_defer" } ] }, { "text": "结构体与接口", "link": "/go/go-basic-syntax/", "collapsed": true, "items": [ { "text": "结构体", "collapsed": true, "link": "/go/basic/6_struct" }, { "text": "接口", "collapsed": true }, { "text": "错误处理", "collapsed": true }, { "text": "面向对象", "collapsed": true }, { "text": "序列化与反序列化", "collapsed": true }, { "text": "时间", "collapsed": true } ] }, { "text": "包管理", "link": "/go/go-basic-syntax/", "collapsed": true, "items": [ { "text": "结构体定义", "collapsed": true } ] }, { "text": "日志", "link": "/go/go-basic-syntax/", "collapsed": true, "items": [ { "text": "结构体定义", "collapsed": true } ] }, { "text": "数据库", "link": "/go/go-basic-syntax/", "collapsed": true, "items": [ { "text": "结构体定义", "collapsed": true } ] }, { "text": "ORM框架", "link": "/go/go-basic-syntax/", "collapsed": true, "items": [ { "text": "结构体定义", "collapsed": true } ] }, { "text": "多线程编程", "link": "/go/go-basic-syntax/", "collapsed": true, "items": [ { "text": "结构体定义", "collapsed": true } ] }, { "text": "TCP编程", "link": "/go/go-basic-syntax/", "collapsed": true, "items": [ { "text": "结构体定义", "collapsed": true } ] }, { "text": "携程与通道", "link": "/go/go-basic-syntax/", "collapsed": true, "items": [ { "text": "结构体定义", "collapsed": true } ] } ] }, { "text": "项目实战", "link": "/go/go-basic-syntax/", "collapsed": false, "items": [ { "text": "函数", "collapsed": true, "items": [ { "text": "匿名函数", "link": "/cloudnative/k8s/2" }, { "text": "递归函数", "link": "/cloudnative/k8s/212" }, { "text": "闭包", "link": "/cloudnative/k8s/213" } ] } ] } ], "/daily-notes/": [ { "text": "2025", "items": [ { "text": "Jenkins", "link": "/daily-notes/index" } ] }, { "text": "2024", "items": [ { "text": "Jenkins", "link": "/daily-notes/index" } ] }, { "text": "2023", "items": [ { "text": "Jenkins", "link": "/daily-notes/index" } ] }, { "text": "2022", "items": [ { "text": "Jenkins", "link": "/daily-notes/index" } ] } ], "/efficiency/": [ { "text": "软件推荐与配置", "items": [ { "text": "多平台软件", "link": "/efficiency/software/cross-platform" }, { "text": "MAC", "link": "/efficiency/software/mac" }, { "text": "Windows", "link": "/efficiency/software/windows" }, { "text": "浏览器设置与扩展", "link": "/efficiency/software/browser" } ] }, { "text": "在线工具", "link": "/efficiency/online-tools" } ] }, "outline": { "label": "页面导航", "level": "deep" }, "search": { "provider": "local", "options": { "translations": { "button": { "buttonText": "搜索文档", "buttonAriaLabel": "搜索文档" }, "modal": { "noResultsText": "没有相关结果", "resetButtonTitle": "清除", "footer": { "selectText": "选择", "navigateText": "切换", "closeText": "关闭" } } } } }, "socialLinks": [ { "icon": "github", "link": "https://github.com/vuejs/vitepress" } ], "footer": { "message": "如有转载或 CV 的请标注本站原文地址", "copyright": "Copyright © 2020-2025 Ryan <a href=\"https://beian.miit.gov.cn/#/Integrated/index\" style=\"text-decoration:none;\"target=\"_blank\">京ICP备19033045号-2</a>" }, "docFooter": { "prev": "上一篇", "next": "下一篇" }, "lastUpdated": { "text": "Updated at", "formatOptions": { "dateStyle": "full", "timeStyle": "medium" } } }
Page Data
{ "title": "Runtime API Examples", "description": "", "frontmatter": { "outline": "deep" }, "headers": [], "relativePath": "api-examples.md", "filePath": "api-examples.md", "lastUpdated": 1746783152000 }
Page Frontmatter
{ "outline": "deep" }
More
Check out the documentation for the full list of runtime APIs.