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>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Results
Theme Data
{ "logo": { "src": "/linux.svg", "width": 20, "height": 20 }, "editLink": { "pattern": "https://github.com/hyuuko1/blog/edit/main/:path" }, "nav": [ { "text": "内存管理", "link": "/mm/index", "activeMatch": "/mm/" }, { "text": "网络", "link": "/net/index", "activeMatch": "/net/" }, { "text": "存储", "link": "/storage/index", "activeMatch": "/storage/" }, { "text": "进程", "link": "/process/index", "activeMatch": "/process/" }, { "text": "中断", "link": "/irq/index", "activeMatch": "/irq/" }, { "text": "体系结构", "link": "/arch/index", "activeMatch": "/arch/" }, { "text": "调试", "link": "/debug/index", "activeMatch": "/debug/" }, { "text": "虚拟化", "link": "/virtualization/index", "activeMatch": "/virtualization/" }, { "text": "杂项", "items": [ { "text": "其他", "link": "/other/index", "activeMatch": "/other/" }, { "text": "初始化", "link": "/init/index", "activeMatch": "/init/" }, { "text": "电源管理", "link": "/pm/index", "activeMatch": "/pm/" } ] } ], "sidebar": { "/mm/": { "base": "/mm/", "items": [ { "text": "前言", "collapsed": false, "items": [ { "text": "🚧 《Understanding the Linux Virtual Memory Manager》Linux 2.6", "link": "gorman_book" } ] }, { "text": "描述物理内存", "collapsed": false, "items": [ { "text": "内存布局", "link": "layout" }, { "text": "e820", "link": "e820" }, { "text": "node", "link": "node" }, { "text": "zone", "link": "zone" }, { "text": "struct page/folio 详解", "link": "folio" }, { "text": "pfn_to_page() 的原理:mem_section 与 vmemmap", "link": "vmemmap" } ] }, { "text": "虚拟内存映射", "collapsed": false, "items": [ { "text": "rmap 反向映射", "link": "rmap" }, { "text": "vma", "link": "vma" }, { "text": "mmap", "link": "mmap" }, { "text": "page fault", "link": "pagefault" }, { "text": "🚧 page table", "link": "page_table" }, { "text": "🚧 ioremap", "link": "ioremap" }, { "text": "🚧 fixmap", "link": "fixmap" }, { "text": "🚧 highmem 高端内存", "link": "highmem" }, { "text": "🚧 GUP (Get User Page)", "link": "gup" }, { "text": "🚧 GFP (Get Free Page)", "link": "gfp" }, { "text": "🚧 CoW (Copy on Write)", "link": "cow" }, { "text": "🚧 UFFD (userfaultfd)", "link": "uffd" }, { "text": "🚧 share memory", "link": "shmem" }, { "text": "🚧 mlock", "link": "mlock" }, { "text": "🚧 tlb", "link": "tlb" }, { "text": "🚧 dma-buf", "link": "dma_buf" } ] }, { "text": "内存分配", "collapsed": false, "items": [ { "text": "vmalloc: 不连续物理内存分配与 vmap", "link": "vmalloc" }, { "text": "per-cpu 变量的静态和动态分配", "link": "percpu" }, { "text": "Buddy System 伙伴系统: 物理页面分配", "link": "buddy" }, { "text": "OOM (Out Of Memory) Killer", "link": "oom" }, { "text": "SLUB 内存分配器", "link": "slub" }, { "text": "CMA 连续内存分配器", "link": "cma" }, { "text": "🚧 早期内存分配器 memblock", "link": "memblock" }, { "text": "🚧 页面回收和交换", "link": "swap" }, { "text": "🚧 KSM (Kernel Samepage Merging)", "link": "ksm" }, { "text": "🚧 hotplug", "link": "hotplug" }, { "text": "🚧 virtio mem", "link": "virtio_mem" }, { "text": "🚧 virtio pmem", "link": "virtio_pmem" }, { "text": "🚧 virtio balloon", "link": "virtio_balloon" } ] }, { "text": "大页", "collapsed": false, "items": [ { "text": "HugeTLB 标准大页", "link": "hugetlb" }, { "text": "THP (Transparent Huge Page) 透明大页", "link": "thp" }, { "text": "mTHP (Multi-size Transparent Huge Page)", "link": "mthp" } ] }, { "text": "内存反碎片", "collapsed": false, "items": [ { "text": "🚧 内存反碎片", "link": "anti-fragmentation" }, { "text": "🚧 内存规整", "link": "compaction" }, { "text": "🚧 页面迁移", "link": "page_migration" }, { "text": "🚧 内存回收", "link": "reclaim" }, { "text": "🚧 swap", "link": "swap" } ] }, { "text": "其他", "collapsed": false, "items": [ { "text": "🚧 pageflags", "link": "pageflags" } ] }, { "text": "Non-Uniform Memory Access architecture", "collapsed": false, "items": [ { "text": "🚧 Memory Policy 内存策略", "link": "mempolicy" } ] }, { "text": "内存管理与文件系统", "collapsed": false, "items": [ { "text": "🚧 readahead 预读", "link": "../storage/readahead" }, { "text": "🚧 page cache", "link": "../storage/pagecache" }, { "text": "🚧 page writeback", "link": "../storage/page_writeback" }, { "text": "🚧 tmpfs", "link": "../storage/tmpfs" }, { "text": "🚧 ramfs", "link": "../storage/ramfs" } ] } ] }, "/net/": { "base": "/net/", "items": [ { "text": "TCP/IP", "collapsed": false, "items": [ { "text": "收包流程", "link": "rx" }, { "text": "发包流程", "link": "tx" } ] } ] }, "/storage/": { "base": "/storage/", "items": [ { "text": "Linux 内核文件系统", "collapsed": false, "items": [ { "text": "🚧 page cache", "link": "pagecache" }, { "text": "🚧 readahead 预读", "link": "readahead" }, { "text": "🚧 VFS", "link": "vfs" }, { "text": "🚧 tmpfs", "link": "tmpfs" }, { "text": "🚧 ramfs", "link": "ramfs" } ] } ] }, "/process/": { "base": "/process/", "items": [ { "text": "调度", "collapsed": false, "items": [ { "text": "CFS", "link": "CFS" }, { "text": "EEVDF", "link": "EEVDF" } ] } ] }, "/irq/": { "base": "/irq/", "items": [ { "text": "Linux IRQ", "collapsed": false, "items": [ { "text": "Linux IRQ", "link": "irq" }, { "text": "MSI-X", "link": "msix" } ] } ] }, "/arch/": { "base": "/arch/", "items": [ { "text": "x86", "collapsed": false, "base": "/arch/x86/" }, { "text": "ARM", "collapsed": false, "base": "/arch/arm/", "items": [ { "text": "AArch64虚拟内存系统架构", "link": "virtual_memory" } ] } ] }, "/debug/": { "base": "/debug/", "items": [ { "text": "Debug", "collapsed": false, "items": [ { "text": "Tips & Tricks", "link": "tips" }, { "text": "vscode + gdb 调试 Linux 内核", "link": "vscode-gdb" }, { "text": "GDB 用法", "link": "gdb" } ] }, { "text": "Tracing", "collapsed": false, "items": [ { "text": "bpftrace 用法", "link": "bpf/bpftrace" } ] } ] }, "/virtualization/": { "base": "/virtualization/", "items": [ { "text": "QEMU-KVM", "collapsed": false, "items": [ { "text": "事件循环", "link": "mainloop" }, { "text": "内存虚拟化", "link": "mm" } ] }, { "text": "VFIO", "collapsed": false, "items": [ { "text": "vfio-pci", "link": "vfio-pci" }, { "text": "vfio-mdev", "link": "vfio-mdev" } ] } ] }, "/other/": { "base": "/other/", "items": [ { "text": "其他", "collapsed": false, "items": [ { "text": "Linux 设备模型", "link": "device_model" }, { "text": "内核模块", "link": "module" } ] } ] }, "/init/": { "base": "/init/", "items": [ { "text": "Linux 内核初始化", "collapsed": false, "items": [ { "text": "initcall", "link": "initcall" } ] } ] }, "/pm/": { "base": "/pm/", "items": [ { "text": "Linux 电源管理", "collapsed": false, "items": [ { "text": "ACPI", "link": "acpi" }, { "text": "CPU 管理", "link": "cpu" }, { "text": "CPU 热插拔", "link": "cpu_hotplug" } ] } ] } }, "search": { "provider": "local", "options": { "detailedView": true, "locales": { "root": { "translations": { "button": { "buttonText": "搜索文档", "buttonAriaLabel": "搜索文档" }, "modal": { "displayDetails": "显示详细列表", "resetButtonTitle": "清除查询条件", "noResultsText": "无法找到相关结果", "footer": { "selectText": "选择", "navigateText": "切换", "closeText": "关闭" } } } } } } }, "socialLinks": [ { "icon": "github", "link": "https://github.com/hyuuko1/blog" } ], "footer": { "message": "Licensed under MIT", "copyright": "Copyright © 2024-2025 HYUUKO" }, "docFooter": { "prev": "上一页", "next": "下一页" }, "outline": { "level": "deep", "label": "目录" }, "lastUpdated": { "text": "最后更新于", "formatOptions": { "dateStyle": "short", "timeStyle": "medium" } }, "externalLinkIcon": true, "langMenuLabel": "多语言", "returnToTopLabel": "回到顶部", "sidebarMenuLabel": "菜单", "darkModeSwitchLabel": "主题", "lightModeSwitchTitle": "切换到浅色模式", "darkModeSwitchTitle": "切换到深色模式" }
Page Data
{ "title": "Runtime API Examples", "description": "", "frontmatter": { "outline": "deep", "head": [ [ "meta", { "property": "og:title", "content": "Runtime API Examples | Blog" } ] ] }, "headers": [], "relativePath": "api-examples.md", "filePath": "api-examples.md", "lastUpdated": 1750001289000 }
Page Frontmatter
{ "outline": "deep", "head": [ [ "meta", { "property": "og:title", "content": "Runtime API Examples | Blog" } ] ] }
More
Check out the documentation for the full list of runtime APIs.