Runtime API Examples
作者: ryan 发布于: 5/9/2025 更新于: 5/9/2025 字数: 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-install-online" }, { "text": "Containerd", "link": "/cloudnative/containerd/2-containerd" } ] }, { "text": "调度与编排", "items": [ { "text": "Kubernetes", "link": "/cloudnative/k8s/5-Kubernetes-Introduction" }, { "text": "Rancher", "link": "/fe/coding/" }, { "text": "kubeSphere", "link": "/fe/coding/" }, { "text": "Kuboard", "link": "/fe/coding/" } ] }, { "text": "云原生存储", "items": [ { "text": "CubeFS", "link": "/fe/coding/" }, { "text": "Longhorn", "link": "/fe/coding/" }, { "text": "Ceph", "link": "/fe/coding/" }, { "text": "Rook", "link": "/fe/coding/" } ] }, { "text": "监控集群", "items": [ { "text": "Prometheus", "link": "/cloudnative/prometheus/61_Prometheus基础" }, { "text": "AlertManager", "link": "/cloudnative/alertmanager/67_AlertManager" }, { "text": "VictoriaMetrics", "link": "/cloudnative/VictoriaMetrics/69_VictoriaMetrics_Single" } ] }, { "text": "日志收集", "items": [ { "text": "Loki", "link": "/cloudnative/logging/Loki/82_Loki" }, { "text": "EFK", "link": "/cloudnative/logging/EFK/78_K8S_Logging_System" } ] } ], "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": "/fe/coding/" }, { "text": "Helm", "link": "/cicd/helm/55_Helm_Package_Management" }, { "text": "Dockerfile", "link": "/fe/coding/" } ] } ], "activeMatch": "^/cicd" }, { "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/structs-and-interfaces/1-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": "^/go" }, { "text": "笔记", "items": [ { "text": "日常笔记", "link": "/daily-notes/archive", "activeMatch": "^/daily-notes" }, { "text": "踩坑记录", "items": [] } ], "activeMatch": "^/daily-note|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/runtime/1-introduction-to-container-runtime", "collapsed": true, "items": [ { "text": "容器运行时介绍", "link": "/cloudnative/runtime/1-introduction-to-container-runtime", "collapsed": true }, { "text": "Docker", "collapsed": true, "link": "/cloudnative/docker/index", "items": [ { "text": "在线方式安装", "link": "/cloudnative/docker/docker-install-online" }, { "text": "离线方式安装", "link": "/cloudnative/docker/offline-docker-installation" }, { "text": "openEuler系统安装Docker", "link": "/cloudnative/docker/docker-base" }, { "text": "制作Tomcat基础镜像", "link": "/cloudnative/docker/tomcat-docker-basic-image" }, { "text": "制作JDK17镜像", "link": "/cloudnative/docker/create-a-jdk17-image" }, { "text": "批量清除Exited状态的容器", "link": "/cloudnative/docker/delete-docker-containers-in-exited-state" }, { "text": "MySQL Docker 生产级部署配置指南", "link": "/cloudnative/docker/mysql-docker-install" } ] }, { "text": "Containerd", "collapsed": true, "items": [ { "text": "安装", "link": "/cloudnative/containerd/2-containerd" }, { "text": "高级命令行工具", "link": "/cloudnative/containerd/3-containerd-advanced-tools" } ] }, { "text": "CGroups与Namespaces", "link": "/cloudnative/runtime/4-CGroups-Namespaces" } ] }, { "text": "编排与调度", "collapsed": true, "items": [ { "text": "Kubernetes", "collapsed": true, "items": [ { "text": "基础", "collapsed": true, "items": [ { "text": "简介", "link": "/cloudnative/k8s/5-Kubernetes-Introduction" }, { "text": "集群部署", "link": "/cloudnative/k8s/6-k8s-deployment" }, { "text": "资源清单", "link": "/cloudnative/k8s/7-k8s-Manifests" }, { "text": "Pod 原理", "link": "/cloudnative/k8s/8-pod-basics" }, { "text": "Pod 生命周期", "link": "/cloudnative/k8s/9-pod-lifecycle" }, { "text": "Pod 进阶使用", "link": "/cloudnative/k8s/10-advanced-use-of-k8s-pods" } ] }, { "text": "控制器", "collapsed": true, "items": [ { "text": "ReplicaSet 控制器", "link": "/cloudnative/k8s/controller/11-replicaset" }, { "text": "Deployment 控制器 ", "link": "/cloudnative/k8s/controller/12-deployment" }, { "text": "StatefulSet 控制器", "link": "/cloudnative/k8s/controller/13-statefulset" }, { "text": "DaemonSet 与 Job", "link": "/cloudnative/k8s/controller/14-daemonset-job" }, { "text": "HPA", "link": "/cloudnative/k8s/controller/15-hpa" }, { "text": "Admission", "link": "/cloudnative/k8s/controller/16-admission" }, { "text": "CRD", "link": "/cloudnative/k8s/controller/17-crd" } ] }, { "text": "配置管理", "collapsed": true, "items": [ { "text": "ConfigMap", "link": "/cloudnative/k8s/configuration-management/18-configmap" }, { "text": "Secret", "link": "/cloudnative/k8s/configuration-management/19-secret" }, { "text": "RBAC", "link": "/cloudnative/k8s/configuration-management/20-rbac" }, { "text": "Security Context", "link": "/cloudnative/k8s/configuration-management/21-security-context" } ] }, { "text": "网络", "collapsed": true, "items": [ { "text": "Service", "link": "/cloudnative/k8s/network/23-service" }, { "text": "服务发现", "link": "/cloudnative/k8s/network/24-service-discovery" }, { "text": "LocalDNS", "link": "/cloudnative/k8s/network/25-localdns" }, { "text": "Ingress", "collapsed": true, "items": [ { "text": "IngressClass", "link": "/cloudnative/k8s/network/26-ingress" }, { "text": "Ingress-nginx", "link": "/cloudnative/k8s/network/27-ingress-nginx" }, { "text": "高级配置1", "link": "/cloudnative/k8s/network/28-ingress-nginx-advanced-configuration" }, { "text": "高级配置2", "link": "/cloudnative/k8s/network/29-ingress-nginx-advanced-configuration-2" } ] }, { "text": "Traefik", "collapsed": true, "items": [ { "text": "Traefik 安装", "link": "/cloudnative/k8s/network/30-traefik" }, { "text": "ACME自签发与中间件", "link": "/cloudnative/k8s/network/31-traefik-acme-middleware" }, { "text": "Pilot平台与安装私有插件", "link": "/cloudnative/k8s/network/32-traefik-pilot" }, { "text": "灰度发布", "link": "/cloudnative/k8s/network/33-traefik-gray-scale-release" } ] }, { "text": "APISIX", "collapsed": true, "items": [ { "text": "APISIX Ingress", "link": "/cloudnative/k8s/network/35-apisix" }, { "text": "高级使用", "link": "/cloudnative/k8s/network/36-apisix-advanced-configuration" }, { "text": "自定义插件", "link": "/cloudnative/k8s/network/37-apisix-custom-plugins" } ] }, { "text": "Gateway API", "link": "/cloudnative/k8s/network/34-gateway-api" } ] }, { "text": "调度器", "collapsed": true, "items": [ { "text": "调度器原理", "link": "/cloudnative/k8s/scheduler/38-kube-scheduler" }, { "text": "亲合性调度", "link": "/cloudnative/k8s/scheduler/39-affinity-scheduling" }, { "text": "拓扑分布约束", "link": "/cloudnative/k8s/scheduler/40-pod-topology-spread" }, { "text": "Descheduler", "link": "/cloudnative/k8s/scheduler/41-descheduler" }, { "text": "服务质量", "link": "/cloudnative/k8s/scheduler/42-qos" } ] } ] }, { "text": "Rancher", "collapsed": true, "items": [ { "text": "Descheduler", "link": "/cloudnative/k8s/514" } ] }, { "text": "KubeSphere", "collapsed": true, "items": [ { "text": "Descheduler", "link": "/cloudnative/k8s/514" } ] }, { "text": "Kobard", "collapsed": true, "items": [ { "text": "Descheduler", "link": "/cloudnative/k8s/514" } ] } ] }, { "text": "云原生存储", "collapsed": true, "items": [ { "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": "Alertmanager", "collapsed": true, "items": [ { "text": "安装", "link": "/cloudnative/alertmanager/67_AlertManager" }, { "text": "高级警报管理", "link": "/cloudnative/alertmanager/68_AlertManager_Advanced_Alert_Management" } ] }, { "text": "VictoriaMetrics", "collapsed": true, "items": [ { "text": "单节点部署", "link": "/cloudnative/VictoriaMetrics/69_VictoriaMetrics_Single" }, { "text": "集群部署", "link": "/cloudnative/VictoriaMetrics/70_VictoriaMetrics_Cluser" }, { "text": "Vmagent", "link": "/cloudnative/VictoriaMetrics/71_Vmagent" }, { "text": "Vmalert", "link": "/cloudnative/VictoriaMetrics/72_Vmalert" }, { "text": "VM-Operator", "link": "/cloudnative/VictoriaMetrics/73_VM-Operator" } ] } ] }, { "text": "日志分析", "collapsed": true, "items": [ { "text": "Loki", "collapsed": true, "items": [ { "text": "Grafana Loki", "link": "/cloudnative/logging/Loki/82_Loki" }, { "text": "Promtail采集端", "link": "/cloudnative/logging/Loki/83_Promtail" }, { "text": "读写分离模式", "link": "/cloudnative/logging/Loki/84_Loki_Read_Write_Separation_Mode" }, { "text": "微服务模式部署", "link": "/cloudnative/logging/Loki/85_Microservices_Mode" }, { "text": "配置文件详解", "link": "/cloudnative/logging/Loki/86_Loki_config.md" }, { "text": "LogQL查询语句", "link": "/cloudnative/logging/Loki/87_LogQL" }, { "text": "知识点回顾", "link": "/cloudnative/logging/Loki/88_Loki_Review" } ] }, { "text": "EFK Stack", "collapsed": true, "items": [ { "text": "K8S日志收集架构", "link": "/cloudnative/logging/EFK/78_K8S_Logging_System" }, { "text": "搭建 EFK 日志系统", "link": "/cloudnative/logging/EFK/79_K8S_EFK_Stack" }, { "text": "使用Kafka优化EFK", "link": "/cloudnative/logging/EFK/80_Optimize_EFK_with_Kafka" }, { "text": "Fluentd", "link": "/cloudnative/logging/EFK/81_Fluentd" } ] } ] }, { "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": true, "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" } ] }, { "text": "Helm", "link": "/cicd/helm/55_Helm_Package_Management", "collapsed": true, "items": [ { "text": "包管理", "link": "/cicd/helm/55_Helm_Package_Management" }, { "text": "Charts", "link": "/cicd/helm/56_Helm_Charts" }, { "text": "模板开发1", "link": "/cicd/helm/57_Helm_Template_Development01" }, { "text": "模板开发2", "link": "/cicd/helm/58_Helm_Template_Development02" }, { "text": "Chart开发示例", "link": "/cicd/helm/59_Helm_Chart_Development_Examples" }, { "text": "测试与包共享", "link": "/cicd/helm/60_Helm_Testing_and_Package_Sharing" } ] } ] } ], "/go/basic/": [ { "text": "Go基础部分", "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": "数据结构", "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": "函数", "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": "结构体与接口", "collapsed": true, "items": [ { "text": "结构体", "collapsed": true, "link": "/go/basic/structs-and-interfaces/1-struct" }, { "text": "接口", "collapsed": true, "link": "/go/basic/structs-and-interfaces/2-interface" }, { "text": "错误处理", "link": "/go/basic/structs-and-interfaces/3-error", "collapsed": true }, { "text": "面向对象", "link": "/go/basic/structs-and-interfaces/4-object-oriented", "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": "使用tinyMediaManager遇到的各种问题和解决办法", "link": "/daily-notes/2025/2025-03-11" }, { "text": "搭建开源图片管理系统--Piwigo", "link": "/daily-notes/2025/2025-03-17" }, { "text": "更换奇安信VPN设备网关证书", "link": "/daily-notes/2025/2025-05-30" } ] }, { "text": "2024", "items": [ { "text": "Docusaurus 实现图片放大功能", "link": "/daily-notes/2024/2024-08-31" } ] }, { "text": "2023", "items": [ { "text": "在K8S环境中搭建Wiki知识库", "link": "/daily-notes/2023/2023-11-14" }, { "text": "美化服务器终端命令行显示", "link": "/daily-notes/2023/2023-05-25" } ] }, { "text": "2022", "items": [ { "text": "在Pod中增加本地域名解析", "link": "/daily-notes/2022/2022-10-04" } ] }, { "text": "2021", "items": [ { "text": "SSH Tunnel(SSH 隧道)", "link": "/daily-notes/2021/2021-11-20" } ] }, { "text": "2020", "items": [ { "text": "服务器如何对大于2T硬盘分区-GPT分区表格式", "link": "/daily-notes/2020/2020-02-14" } ] } ], "/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.