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
{
"siteTitle": "ShiBin's Wiki",
"logo": "/icons8-github-copilot-3d-fluency-32.png",
"nav": [
{
"text": "Blogs",
"link": "/archives"
},
{
"text": "AI",
"items": [
{
"text": "Claude Code 教程",
"link": "/ai/claudecodenew/"
},
{
"text": "Claude Code 指南",
"link": "/ai/claudecode/"
}
]
},
{
"text": "CS Primer",
"items": [
{
"text": "OS",
"link": "/csprimer/os/"
},
{
"text": "Network",
"link": "/csprimer/network/"
},
{
"text": "Database",
"link": "/csprimer/database/"
},
{
"text": "Compiler",
"link": "/csprimer/compiler/"
}
]
},
{
"text": "Linux",
"items": [
{
"text": "Basic",
"link": "/linux/01basic/"
},
{
"text": "App",
"link": "/linux/02app/"
},
{
"text": "Kernel",
"link": "/linux/03kernel/"
}
]
},
{
"text": "Windows",
"items": [
{
"text": "系统编程",
"link": "/windows/system-programming/"
},
{
"text": "命令行",
"link": "/windows/cmd"
}
]
},
{
"text": "Language",
"items": [
{
"text": "Assembly",
"link": "/lang/assembly/"
},
{
"text": "C",
"link": "/lang/c/"
},
{
"text": "C++",
"link": "/lang/c++/"
},
{
"text": "Rust",
"link": "/lang/rust/"
},
{
"text": "JavaScript",
"link": "/lang/javacript/"
},
{
"text": "TypeScript",
"link": "/lang/typescript/"
}
]
},
{
"text": "Misc",
"items": [
{
"text": "CMake",
"link": "/misc/cmake/index"
},
{
"text": "Cheat Sheet",
"link": "/misc/cheatsheet/index"
},
{
"text": "Talks",
"link": "/misc/talks"
},
{
"text": "About Me",
"link": "/misc/about_me"
}
]
}
],
"sidebar": {
"/csprimer/": [
{
"text": "CS Primer",
"items": [
{
"text": "OS",
"link": "/csprimer/os/"
},
{
"text": "Network",
"link": "/csprimer/network/"
},
{
"text": "Database",
"link": "/csprimer/database/"
},
{
"text": "Compiler",
"link": "/csprimer/compiler/"
}
]
}
],
"/linux/": [
{
"text": "Basic",
"link": "/linux/01basic/",
"collapsed": true,
"items": [
{
"text": "Linux系统",
"link": "/linux/01basic/01_system"
},
{
"text": "Shell及常用命令",
"link": "/linux/01basic/02_shell"
}
]
},
{
"text": "App",
"collapsed": true,
"items": [
{
"text": "UNIX 基础",
"link": "/linux/02app/01_UNIX_System_Overview"
},
{
"text": "UNIX 标准及实现",
"link": "/linux/02app/02_UNIX_Standardization_and_Implementations"
},
{
"text": "文件 I/O",
"link": "/linux/02app/03_File_I_O"
},
{
"text": "文件和目录",
"link": "/linux/02app/04_Files_and_Directories"
},
{
"text": "标准 I/O 库",
"link": "/linux/02app/05_Standard_I_O_Library"
},
{
"text": "系统数据文件和信息",
"link": "/linux/02app/06_System_Data_Files_and_Information"
},
{
"text": "迸程环境",
"link": "/linux/02app/07_Process_Environment"
},
{
"text": "进程控制",
"link": "/linux/02app/08_Process_Control"
},
{
"text": "进程关系",
"link": "/linux/02app/09_Process_Relationships"
},
{
"text": "信号",
"link": "/linux/02app/10_Signals"
},
{
"text": "线程",
"link": "/linux/02app/11_Threads"
},
{
"text": "线程控制",
"link": "/linux/02app/12_Thread_Control"
},
{
"text": "守护进程",
"link": "/linux/02app/13_Daemon_Processes"
},
{
"text": "高级 I/O",
"link": "/linux/02app/14_Advanced_I_O"
},
{
"text": "迸程间通信",
"link": "/linux/02app/15_Interprocess_Communication"
},
{
"text": "网络 IPC :套接字",
"link": "/linux/02app/16_Network_IPC:_Sockets"
},
{
"text": "高级 IPC",
"link": "/linux/02app/17_Advanced_IPC"
},
{
"text": "终端 I/O",
"link": "/linux/02app/18_Terminal_I_O"
},
{
"text": "伪终端",
"link": "/linux/02app/19_Pseudo_Terminals"
},
{
"text": "数据库函数库",
"link": "/linux/02app/20_A_Database_Library"
},
{
"text": "与网络打印机通信",
"link": "/linux/02app/21_Communicating_with_a_Network_Printer"
}
]
},
{
"text": "Kernel",
"collapsed": true,
"link": "/linux/03kernel/"
}
],
"/windows/": [
{
"text": "Windows 10 系统编程",
"link": "/windows/system-programming/",
"collapsed": true,
"items": [
{
"text": "第1章:基础",
"link": "/windows/system-programming/01_fundamentals"
},
{
"text": "第2章:对象和句柄",
"link": "/windows/system-programming/02_objects_handles"
},
{
"text": "第3章:进程",
"link": "/windows/system-programming/03_processes"
},
{
"text": "第4章:作业",
"link": "/windows/system-programming/04_jobs"
},
{
"text": "第5章:线程基础",
"link": "/windows/system-programming/05_thread_basics"
},
{
"text": "第6章:线程调度",
"link": "/windows/system-programming/06_thread_scheduling"
},
{
"text": "第7章:线程同步(进程内)",
"link": "/windows/system-programming/07_sync_inprocess"
},
{
"text": "第8章:线程同步(进程间)",
"link": "/windows/system-programming/08_sync_interprocess"
},
{
"text": "第9章:线程池",
"link": "/windows/system-programming/09_thread_pool"
},
{
"text": "第10章:高级线程处理",
"link": "/windows/system-programming/10_advanced_threading"
},
{
"text": "第11章:文件和设备 I/O",
"link": "/windows/system-programming/11_file_io"
},
{
"text": "第12章:内存管理基础",
"link": "/windows/system-programming/12_memory_basics"
},
{
"text": "第13章:内存操作",
"link": "/windows/system-programming/13_memory_operations"
},
{
"text": "第14章:内存映射文件",
"link": "/windows/system-programming/14_memory_mapped_files"
},
{
"text": "第15章:动态链接库",
"link": "/windows/system-programming/15_dll"
},
{
"text": "第16章:安全性",
"link": "/windows/system-programming/16_security"
},
{
"text": "第17章:注册表",
"link": "/windows/system-programming/17_registry"
}
]
},
{
"text": "命令行",
"link": "/windows/cmd/",
"collapsed": true,
"items": []
}
],
"/lang/": [
{
"text": "RISC-V 汇编",
"link": "/lang/assembly/",
"collapsed": true,
"items": [
{
"text": "总览",
"link": "/lang/assembly/"
},
{
"text": "第一篇:基础篇",
"collapsed": true,
"items": [
{
"text": "第1章 为什么要学 RISC-V 汇编",
"link": "/lang/assembly/01_why_riscv"
},
{
"text": "第2章 数制与数据表示",
"link": "/lang/assembly/02_number_systems"
},
{
"text": "第3章 RISC-V 体系结构概览",
"link": "/lang/assembly/03_architecture"
},
{
"text": "第4章 第一个 RISC-V 程序",
"link": "/lang/assembly/04_first_program"
}
]
},
{
"text": "第二篇:指令篇",
"collapsed": true,
"items": [
{
"text": "第5章 算术与逻辑运算",
"link": "/lang/assembly/05_arithmetic_logic"
},
{
"text": "第6章 立即数操作与移位",
"link": "/lang/assembly/06_immediates_shifts"
},
{
"text": "第7章 数据加载与存储",
"link": "/lang/assembly/07_load_store"
},
{
"text": "第8章 分支与条件控制",
"link": "/lang/assembly/08_branches_jumps"
},
{
"text": "第9章 伪指令与汇编器魔法",
"link": "/lang/assembly/09_pseudo_instructions"
}
]
},
{
"text": "第三篇:系统篇",
"collapsed": true,
"items": [
{
"text": "第10章 栈与内存布局",
"link": "/lang/assembly/10_stack_memory_layout"
},
{
"text": "第11章 函数调用约定",
"link": "/lang/assembly/11_calling_convention"
},
{
"text": "第12章 系统调用",
"link": "/lang/assembly/12_system_calls"
},
{
"text": "第13章 汇编器、链接器与 ELF",
"link": "/lang/assembly/13_assembler_linker_elf"
}
]
},
{
"text": "第四篇:扩展篇",
"collapsed": true,
"items": [
{
"text": "第14章 M 扩展:乘除法指令",
"link": "/lang/assembly/14_m_extension"
},
{
"text": "第15章 A 扩展:原子操作指令",
"link": "/lang/assembly/15_a_extension"
},
{
"text": "第16章 F 与 D 扩展:浮点指令",
"link": "/lang/assembly/16_f_d_extension"
},
{
"text": "第17章 C 扩展:压缩指令",
"link": "/lang/assembly/17_c_extension"
}
]
},
{
"text": "第五篇:实战篇",
"collapsed": true,
"items": [
{
"text": "第18章 与 C 语言互操作",
"link": "/lang/assembly/18_c_interop"
},
{
"text": "第19章 综合实战:交互式计算器",
"link": "/lang/assembly/19_calculator_project"
}
]
},
{
"text": "第六篇:特权架构篇",
"collapsed": true,
"items": [
{
"text": "第20章 特权级别与 CSR",
"link": "/lang/assembly/20_privilege_csr"
},
{
"text": "第21章 异常与中断",
"link": "/lang/assembly/21_exceptions_interrupts"
},
{
"text": "第22章 页表与虚拟内存",
"link": "/lang/assembly/22_virtual_memory"
}
]
},
{
"text": "附录",
"collapsed": true,
"items": [
{
"text": "A. RV64I 基础指令速查表",
"link": "/lang/assembly/appendix_a_rv64i_reference"
},
{
"text": "B. 扩展指令速查表",
"link": "/lang/assembly/appendix_b_extensions_reference"
},
{
"text": "C. 伪指令速查表",
"link": "/lang/assembly/appendix_c_pseudo_instructions"
},
{
"text": "D. 寄存器 ABI 速查",
"link": "/lang/assembly/appendix_d_register_abi"
},
{
"text": "E. 工具与资源索引",
"link": "/lang/assembly/appendix_e_tools_resources"
}
]
}
]
},
{
"text": "C",
"link": "/lang/c/",
"collapsed": true,
"items": [
{
"text": "基础",
"link": "/lang/c/00_basics"
},
{
"text": "关键字",
"link": "/lang/c/01_keywords"
},
{
"text": "内存",
"link": "/lang/c/02_memory"
},
{
"text": "指针",
"link": "/lang/c/03_pointer"
},
{
"text": "标准库",
"link": "/lang/c/04_stdlib"
},
{
"text": "string及其源码",
"link": "/lang/c/05_string"
}
]
},
{
"text": "C++",
"link": "/lang/c++/"
},
{
"text": "Rust",
"link": "/lang/rust/",
"collapsed": true,
"items": [
{
"text": "第1章 为什么是 Rust",
"link": "/lang/rust/01_why_rust"
},
{
"text": "第2章 Rust 概览",
"link": "/lang/rust/02_tour"
},
{
"text": "第3章 基本类型",
"link": "/lang/rust/03_basic_types"
},
{
"text": "第4章 所有权与 Move",
"link": "/lang/rust/04_ownership"
},
{
"text": "第5章 引用与借用",
"link": "/lang/rust/05_references"
},
{
"text": "第6章 表达式",
"link": "/lang/rust/06_expressions"
},
{
"text": "第7章 错误处理",
"link": "/lang/rust/07_error_handling"
},
{
"text": "第8章 Crate 与模块",
"link": "/lang/rust/08_crates_modules"
},
{
"text": "第9章 结构体",
"link": "/lang/rust/09_structs"
},
{
"text": "第10章 枚举与模式",
"link": "/lang/rust/10_enums_patterns"
},
{
"text": "第11章 Trait 与泛型",
"link": "/lang/rust/11_traits_generics"
},
{
"text": "第12章 运算符重载",
"link": "/lang/rust/12_operator_overload"
},
{
"text": "第13章 实用 Trait",
"link": "/lang/rust/13_utility_traits"
},
{
"text": "第14章 闭包",
"link": "/lang/rust/14_closures"
},
{
"text": "第15章 迭代器",
"link": "/lang/rust/15_iterators"
},
{
"text": "第16章 集合",
"link": "/lang/rust/16_collections"
},
{
"text": "第17章 字符串与文本",
"link": "/lang/rust/17_strings_text"
},
{
"text": "第18章 输入输出",
"link": "/lang/rust/18_io"
},
{
"text": "第19章 并发编程",
"link": "/lang/rust/19_concurrency"
},
{
"text": "第20章 异步编程",
"link": "/lang/rust/20_async"
},
{
"text": "第21章 宏",
"link": "/lang/rust/21_macros"
},
{
"text": "第22章 Unsafe 代码",
"link": "/lang/rust/22_unsafe"
},
{
"text": "第23章 外部函数",
"link": "/lang/rust/23_ffi"
}
]
},
{
"text": "JavaScript",
"link": "/lang/javascript/",
"collapsed": true,
"items": []
},
{
"text": "TypeScript",
"link": "/lang/typescript/",
"collapsed": true,
"items": [
{
"text": "The Basics",
"link": "/lang/typescript/01 The Basics"
},
{
"text": "Everyday Types",
"link": "/lang/typescript/02 Everyday Types"
},
{
"text": "Narrowing",
"link": "/lang/typescript/03 Narrowing"
},
{
"text": "More on Functions",
"link": "/lang/typescript/04 More on Functions"
},
{
"text": "Object Types",
"link": "/lang/typescript/05 Object Types"
},
{
"text": "Type Manipulation",
"link": "/lang/typescript/06 Type Manipulation",
"items": [
{
"text": "Generics",
"link": "/lang/typescript/06.01 Generics"
},
{
"text": "Keyof Type Operator",
"link": "/lang/typescript/06.02 Keyof Type Operator"
},
{
"text": "Typeof Type Operator",
"link": "/lang/typescript/06.03 Typeof Type Operator"
},
{
"text": "Indexed Access Types",
"link": "/lang/typescript/06.04 Indexed Access Types"
},
{
"text": "Conditional Types",
"link": "/lang/typescript/06.04 Conditional Types"
}
]
},
{
"text": "Classes",
"link": "/lang/typescript/07 Classes"
},
{
"text": "Error Handling",
"link": "/lang/typescript/Error handling"
}
]
}
],
"/misc/cmake/": [
{
"text": "CMake",
"items": [
{
"text": "Overview",
"link": "/misc/cmake/index"
},
{
"text": "Hello World",
"link": "/misc/cmake/01_helloworld"
},
{
"text": "CMake 常用脚本命令",
"link": "/misc/cmake/02_common_script_commands"
},
{
"text": "Targets",
"link": "/misc/cmake/03_target"
},
{
"text": "模块",
"link": "/misc/cmake/04_modules"
},
{
"text": "引入三方库",
"link": "/misc/cmake/05_thirty_part_library"
},
{
"text": "交叉编译",
"link": "/misc/cmake/06_cross_compiling"
},
{
"text": "安装、打包",
"link": "/misc/cmake/07_install_pack"
}
]
}
],
"/misc/cheatsheet/": [
{
"text": "Cheat Sheet",
"items": [
{
"text": "macOS",
"link": "/misc/cheatsheet/macos"
},
{
"text": "macOS Apps",
"link": "/misc/cheatsheet/macos_apps"
},
{
"text": "Vim",
"link": "/misc/cheatsheet/vim"
},
{
"text": "VSCode",
"link": "/misc/cheatsheet/vscode"
},
{
"text": "Git",
"link": "/misc/cheatsheet/git"
},
{
"text": "GCC",
"link": "/misc/cheatsheet/gcc"
},
{
"text": "GDB",
"link": "/misc/cheatsheet/gdb"
},
{
"text": "Final Cut Pro",
"link": "/misc/cheatsheet/final_cut_pro"
}
]
}
],
"/ai/": [
{
"text": "AI & LLM 概念地图",
"collapsed": false,
"items": [
{
"text": "AI & LLM 概念地图:给新手的漫游指南",
"link": "/ai/ai-llm-concepts-map"
}
]
},
{
"text": "Claude Code 学习教程",
"collapsed": false,
"items": [
{
"text": "概述",
"link": "/ai/claudecodenew/"
},
{
"text": "第一篇:入门篇",
"collapsed": true,
"items": [
{
"text": "第1章 AI编程时代的到来",
"link": "/ai/claudecodenew/01-ai-coding-era"
},
{
"text": "第2章 Agent与模型",
"link": "/ai/claudecodenew/02-agent-and-model"
},
{
"text": "第3章 环境搭建",
"link": "/ai/claudecodenew/03-environment-setup"
},
{
"text": "第4章 平台生态概览",
"link": "/ai/claudecodenew/04-platform-ecosystem"
}
]
},
{
"text": "第二篇:基础篇",
"collapsed": true,
"items": [
{
"text": "第5章 对话与代码理解",
"link": "/ai/claudecodenew/05-chat-and-understanding"
},
{
"text": "第6章 代码编辑与重构",
"link": "/ai/claudecodenew/06-code-editing"
},
{
"text": "第7章 终端命令执行",
"link": "/ai/claudecodenew/07-terminal-execution"
},
{
"text": "第8章 Git集成",
"link": "/ai/claudecodenew/08-git-integration"
},
{
"text": "第9章 模式切换",
"link": "/ai/claudecodenew/09-mode-switching"
}
]
},
{
"text": "第三篇:进阶篇",
"collapsed": true,
"items": [
{
"text": "第10章 工作原理",
"link": "/ai/claudecodenew/10-how-it-works"
},
{
"text": "第11章 上下文管理",
"link": "/ai/claudecodenew/11-context-management"
},
{
"text": "第12章 CLAUDE.md",
"link": "/ai/claudecodenew/12-claude-md"
},
{
"text": "第13章 配置体系",
"link": "/ai/claudecodenew/13-config-system"
},
{
"text": "第14章 权限与安全",
"link": "/ai/claudecodenew/14-permissions-and-security"
}
]
},
{
"text": "第四篇:生态篇",
"collapsed": true,
"items": [
{
"text": "第15章 MCP协议与服务器",
"link": "/ai/claudecodenew/15-mcp-protocol"
},
{
"text": "第16章 插件系统",
"link": "/ai/claudecodenew/16-plugins"
},
{
"text": "第17章 Skills技能系统",
"link": "/ai/claudecodenew/17-skills"
},
{
"text": "第18章 Hooks钩子系统",
"link": "/ai/claudecodenew/18-hooks"
},
{
"text": "第19章 命令系统进阶",
"link": "/ai/claudecodenew/19-command-system"
}
]
},
{
"text": "第五篇:实战篇",
"collapsed": true,
"items": [
{
"text": "第20章 理解陌生项目",
"link": "/ai/claudecodenew/20-scenario-understand-project"
},
{
"text": "第21章 从零搭建新功能",
"link": "/ai/claudecodenew/21-scenario-new-feature"
},
{
"text": "第22章 大规模重构",
"link": "/ai/claudecodenew/22-scenario-refactoring"
},
{
"text": "第23章 调试与排错",
"link": "/ai/claudecodenew/23-scenario-debugging"
},
{
"text": "第24章 Code Review",
"link": "/ai/claudecodenew/24-scenario-code-review"
},
{
"text": "第25章 测试编写",
"link": "/ai/claudecodenew/25-scenario-testing"
},
{
"text": "第26章 文档生成",
"link": "/ai/claudecodenew/26-scenario-documentation"
},
{
"text": "第27章 CI/CD集成",
"link": "/ai/claudecodenew/27-scenario-cicd"
}
]
},
{
"text": "第六篇:方法论篇",
"collapsed": true,
"items": [
{
"text": "第28章 Prompt工程",
"link": "/ai/claudecodenew/28-prompt-engineering"
},
{
"text": "第29章 让AI理解你的项目",
"link": "/ai/claudecodenew/29-ai-friendly-project"
},
{
"text": "第30章 人机协作模式",
"link": "/ai/claudecodenew/30-human-ai-collaboration"
},
{
"text": "第31章 效率优化策略",
"link": "/ai/claudecodenew/31-efficiency-optimization"
}
]
},
{
"text": "第七篇:精通篇",
"collapsed": true,
"items": [
{
"text": "第32章 高级工作流",
"link": "/ai/claudecodenew/32-advanced-workflows"
},
{
"text": "第33章 自定义扩展开发",
"link": "/ai/claudecodenew/33-custom-extensions"
},
{
"text": "第34章 团队推广指南",
"link": "/ai/claudecodenew/34-team-adoption"
},
{
"text": "第35章 模型深度对比",
"link": "/ai/claudecodenew/35-model-comparison"
},
{
"text": "第36章 前沿探索与趋势",
"link": "/ai/claudecodenew/36-frontier-and-trends"
}
]
},
{
"text": "第八篇:贯穿项目 —— SmartTodo 全栈实战",
"collapsed": true,
"items": [
{
"text": "第37章 项目启动",
"link": "/ai/claudecodenew/37-project-init"
},
{
"text": "第38章 后端开发",
"link": "/ai/claudecodenew/38-backend-development"
},
{
"text": "第39章 前端开发",
"link": "/ai/claudecodenew/39-frontend-development"
},
{
"text": "第40章 部署与运维",
"link": "/ai/claudecodenew/40-deployment-and-ops"
}
]
},
{
"text": "附录",
"collapsed": true,
"items": [
{
"text": "A. Cheatsheet",
"link": "/ai/claudecodenew/appendix-a-cheatsheet"
},
{
"text": "B. settings.json参考",
"link": "/ai/claudecodenew/appendix-b-settings-reference"
},
{
"text": "C. 环境变量参考",
"link": "/ai/claudecodenew/appendix-c-env-vars"
},
{
"text": "D. Prompt模板",
"link": "/ai/claudecodenew/appendix-d-prompt-templates"
},
{
"text": "E. cc-switch配置速查",
"link": "/ai/claudecodenew/appendix-e-cc-switch"
},
{
"text": "F. 常见问题排查",
"link": "/ai/claudecodenew/appendix-f-troubleshooting"
},
{
"text": "G. 术语表",
"link": "/ai/claudecodenew/appendix-g-glossary"
}
]
}
]
},
{
"text": "Claude Code 培训指南",
"collapsed": true,
"items": [
{
"text": "概述",
"link": "/ai/claudecode/"
},
{
"text": "安装与设置",
"link": "/ai/claudecode/01-installation"
},
{
"text": "工作原理",
"link": "/ai/claudecode/02-how-it-works"
},
{
"text": "核心功能",
"link": "/ai/claudecode/03-core-features"
},
{
"text": "生态与社区",
"link": "/ai/claudecode/04-ecosystem"
},
{
"text": "实战工作流",
"link": "/ai/claudecode/05-workflows"
},
{
"text": "角色转变与局限",
"link": "/ai/claudecode/06-mindset"
},
{
"text": "Cheatsheet",
"link": "/ai/claudecode/cheatsheet"
}
]
}
],
"/misc/examples/": [
{
"text": "Examples",
"items": [
{
"text": "Examples",
"link": "/markdown-examples"
},
{
"text": "API Examples",
"link": "/api-examples"
}
]
}
]
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/WShiBin"
}
],
"footer": {
"copyright": "Copyright © 2017-2026 Shi Bin"
},
"search": {
"provider": "local"
},
"outline": {
"level": [
2,
3
]
},
"lastUpdated": {
"text": "Updated at",
"formatOptions": {
"dateStyle": "full",
"timeStyle": "medium"
}
}
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep",
"layout": "doc",
"prev": false,
"next": false,
"sidebar": true
},
"headers": [],
"relativePath": "examples/api-examples.md",
"filePath": "examples/api-examples.md",
"lastUpdated": 1714231035000
}Page Frontmatter
{
"outline": "deep",
"layout": "doc",
"prev": false,
"next": false,
"sidebar": true
}More
Check out the documentation for the full list of runtime APIs.