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

{
  "logo": {
    "src": "/head-portrait-image.png",
    "width": 24,
    "height": 24,
    "alt": "My Logo"
  },
  "nav": [
    {
      "text": "首页",
      "link": "/"
    },
    {
      "text": "博客",
      "link": "/2024-05-30_sched_init"
    },
    {
      "text": "底层探秘",
      "link": "/cs/network/cs-network-01-layer"
    },
    {
      "text": "人工智能",
      "link": "/ai/deepseek-01-what"
    },
    {
      "text": "Java面试",
      "link": "/java/java-interview-hj-01"
    },
    {
      "text": "Rust教程",
      "link": "/rust/rust-axum-web-01"
    },
    {
      "text": "技术文章",
      "link": "/articles/git-commit-log-conventional_commits"
    }
  ],
  "sidebar": {
    "/ai/": [
      {
        "text": "DeepSeek系列",
        "items": [
          {
            "text": "1.算法炼金术-什么是DeepSeek?",
            "link": "/ai/deepseek-01-what"
          },
          {
            "text": "2.星辰与代码:DeepSeek的发展历程",
            "link": "/ai/deepseek-02-development-history"
          }
        ]
      }
    ],
    "/rust/": [
      {
        "text": "Axum高性能web系列",
        "items": [
          {
            "text": "1.从入门到速通教程",
            "link": "/rust/rust-axum-web-01"
          },
          {
            "text": "2.集成日志功能Tracing",
            "link": "/rust/rust-axum-web-02-log-tracing"
          },
          {
            "text": "3.多种方式读取配置文件",
            "link": "/rust/rust-axum-web-03-read-config"
          }
        ]
      }
    ],
    "/java/": [
      {
        "text": "夯实基础",
        "items": [
          {
            "text": "Java基础面试题集(2025版,1.8万字)",
            "link": "/java/java-interview-hj-01"
          }
        ]
      }
    ],
    "/cs/": [
      {
        "text": "计算机网络",
        "items": [
          {
            "text": "化繁为简:计算机网络分层的详解",
            "link": "/cs/network/cs-network-01-layer"
          },
          {
            "text": "互联网下的隐藏\"坐标\":IP 地址到底是什么?",
            "link": "/cs/network/cs-network-40-ip-address"
          },
          {
            "text": "TCP为什么握手要3回,挥手4次?深入浅出给你图解",
            "link": "/cs/network/cs-network-50-tcp-handshake-take-3-times-and-wave-4-times"
          },
          {
            "text": "什么是http协议,从http0.9到http3.0发展历程的回首",
            "link": "/cs/network/cs-network-70-http-development"
          }
        ]
      }
    ],
    "/articles/": [
      {
        "items": [
          {
            "text": "告别fix bug!拯救Git Commit Log的规范",
            "link": "/articles/git-commit-log-conventional_commits"
          },
          {
            "text": "Linux用户必备:Ubuntu如何快速查看版本",
            "link": "/articles/ubuntu/ubuntu-01-version-check"
          }
        ]
      }
    ],
    "/": [
      {
        "items": [
          {
            "text": "linux0.12内核源码解读(12)-任务调度初始化sched_init",
            "link": "2024-05-30_sched_init"
          },
          {
            "text": "能够自我检错并纠错的编码-校验码",
            "link": "2024-04-28_Check_Code"
          },
          {
            "text": "引入缓存竟然会带来这么多问题??!",
            "link": "2024-04-03_Why_does_introducing_caching_bring_so_many_problems"
          },
          {
            "text": "如何快速弄懂缓存穿透、缓存击穿、缓存雪崩之间的区别?",
            "link": "2024-03-19_Cache_penetration_cache avalanche_cache_breakdown"
          },
          {
            "text": "tty是什么?聊聊linux0.12中tty与time的初始化",
            "link": "2024-02-29_linux0.12_tty_time"
          },
          {
            "text": "git + hooks+shell 实现服务器自动部署vuepress项目",
            "link": "2024-02-22_git_hooks_shell_project"
          },
          {
            "text": "你了解计算机中大端小端之分吗?",
            "link": "2024-01-18_large_and_small_terminals_in_computers"
          },
          {
            "text": "什么是系统调用机制?结合Linux0.12源码图解",
            "link": "2023-12-26_What_is_a_system_call_mechanism"
          },
          {
            "text": "从HTTP0.9到HTTP3.0发展历程的万字回首与展望",
            "link": "2023-12-04_http_http0.9_to_http3.0"
          },
          {
            "text": "Linux0.12内核源码解读(9)-blk_dev_init和chr_dev_init",
            "link": "2023-11-16_Linux0.12-blk_dev_init_and_chr_dev_init"
          },
          {
            "text": "如何利用缓存,让CPU更有效率地执行代码?",
            "link": "2023-11-01_How_to_utilize_cache_to_make_CPU_execute_code_more_efficiently"
          },
          {
            "text": "图解计算机中断",
            "link": "2023-10-17_graphic_computer_interrupt"
          },
          {
            "text": "CPU Cache是如何保证缓存一致性?",
            "link": "2023-09-29_How_ does_CPU_Cache_ensure_cache_consistency"
          },
          {
            "text": "Linux0.12内核源码解读(7)-陷阱门初始化",
            "link": "2023-09-17_Linux0.12_trap_init"
          },
          {
            "text": "CPU Cache是如何映射与寻址的?",
            "link": "2023-09-01_CPU_Cache_Mapping_and_Addressing"
          },
          {
            "text": "Linux0.12内核源码解读(6)-main.c",
            "link": "2023-08-14_Linux0.12_main"
          },
          {
            "text": "AQS源码解析(2)-共享锁的获取与释放",
            "link": "2023-08-02_AQS_about_share_lock"
          },
          {
            "text": "突破计算机性能瓶颈的利器CPU Cache",
            "link": "2023-07-14_CPU_Cache_01"
          },
          {
            "text": "Linux0.12内核源码解读(5)-head.s",
            "link": "2023-07-02_Linux0.12_head.s"
          },
          {
            "text": "图解ReentrantLock的基石AQS源码-独占锁的获取与释放",
            "link": "2023-06-21_AQS-Acquisition_and_Release_of_Exclusive_Locks"
          },
          {
            "text": "图解CPU的实模式与保护模式",
            "link": "2023-05-26_Diagram_real_mode_and_protected_mode_of_CPU"
          },
          {
            "text": "Linux0.12内核源码解读(3)-Setup.S",
            "link": "2023-05-04_Linux0.12_Setup"
          }
        ]
      }
    ]
  },
  "sidebarMenuLabel": "目录",
  "outline": {
    "level": [
      2,
      6
    ],
    "label": "本页目录"
  },
  "footer": {
    "message": "<a href=\"https://beian.miit.gov.cn/\" target=\"_blank\">苏ICP备2021011886号-1</a>",
    "copyright": "Copyright © 2020-present xiaoniuhululu"
  },
  "lastUpdatedText": "最后更新",
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/xiaoniuhululu"
    }
  ],
  "search": {
    "provider": "local"
  },
  "returnToTopLabel": "返回顶部"
}

Page Data

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

Page Frontmatter

{
  "outline": "deep"
}

More

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