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
{ "versioning": { "text": "Version", "items": [ { "text": "12.x", "link": "/docs/12.x/" }, { "text": "11.x", "link": "/docs/11.x/" } ] }, "nav": [ { "text": "Home", "link": "/" } ], "sidebar": { "/docs/12.x/": [ { "text": "前言", "collapsed": false, "items": [ { "text": "版本說明", "link": "/docs/12.x/releases" }, { "text": "升級指南", "link": "/docs/12.x/upgrade" }, { "text": "貢獻指南", "link": "/docs/12.x/contributions" } ] }, { "text": "入門", "collapsed": false, "items": [ { "text": "安裝", "link": "/docs/12.x/installation" }, { "text": "設定", "link": "/docs/12.x/configuration" }, { "text": "目錄結構", "link": "/docs/12.x/structure" }, { "text": "前端", "link": "/docs/12.x/frontend" }, { "text": "入門套件", "link": "/docs/12.x/starter-kits" }, { "text": "部署", "link": "/docs/12.x/deployment" } ] }, { "text": "架構概念", "collapsed": false, "items": [ { "text": "請求生命週期", "link": "/docs/12.x/lifecycle" }, { "text": "服務容器", "link": "/docs/12.x/container" }, { "text": "服務提供者", "link": "/docs/12.x/providers" }, { "text": "Facades", "link": "/docs/12.x/facades" } ] }, { "text": "基礎功能", "collapsed": false, "items": [ { "text": "路由", "link": "/docs/12.x/routing" }, { "text": "中介層", "link": "/docs/12.x/middleware" }, { "text": "CSRF 保護", "link": "/docs/12.x/csrf" }, { "text": "控制器", "link": "/docs/12.x/controllers" }, { "text": "請求", "link": "/docs/12.x/requests" }, { "text": "回應", "link": "/docs/12.x/responses" }, { "text": "視圖", "link": "/docs/12.x/views" }, { "text": "Blade 模板", "link": "/docs/12.x/blade" }, { "text": "資源打包", "link": "/docs/12.x/vite" }, { "text": "URL 生成", "link": "/docs/12.x/urls" }, { "text": "會話", "link": "/docs/12.x/session" }, { "text": "驗證", "link": "/docs/12.x/validation" }, { "text": "錯誤處理", "link": "/docs/12.x/errors" }, { "text": "日誌", "link": "/docs/12.x/logging" } ] }, { "text": "深入探討", "collapsed": false, "items": [ { "text": "Artisan 主控台", "link": "/docs/12.x/artisan" }, { "text": "廣播", "link": "/docs/12.x/broadcasting" }, { "text": "快取", "link": "/docs/12.x/cache" }, { "text": "集合", "link": "/docs/12.x/collections" }, { "text": "併發", "link": "/docs/12.x/concurrency" }, { "text": "上下文", "link": "/docs/12.x/context" }, { "text": "契約", "link": "/docs/12.x/contracts" }, { "text": "事件", "link": "/docs/12.x/events" }, { "text": "檔案儲存", "link": "/docs/12.x/filesystem" }, { "text": "輔助函式", "link": "/docs/12.x/helpers" }, { "text": "HTTP 用戶端", "link": "/docs/12.x/http-client" }, { "text": "本地化", "link": "/docs/12.x/localization" }, { "text": "郵件", "link": "/docs/12.x/mail" }, { "text": "通知", "link": "/docs/12.x/notifications" }, { "text": "套件開發", "link": "/docs/12.x/packages" }, { "text": "程序", "link": "/docs/12.x/processes" }, { "text": "佇列", "link": "/docs/12.x/queues" }, { "text": "速率限制", "link": "/docs/12.x/rate-limiting" }, { "text": "字串", "link": "/docs/12.x/strings" }, { "text": "任務排程", "link": "/docs/12.x/scheduling" } ] }, { "text": "安全性", "collapsed": false, "items": [ { "text": "身份驗證", "link": "/docs/12.x/authentication" }, { "text": "授權", "link": "/docs/12.x/authorization" }, { "text": "電子郵件驗證", "link": "/docs/12.x/verification" }, { "text": "加密", "link": "/docs/12.x/encryption" }, { "text": "雜湊", "link": "/docs/12.x/hashing" }, { "text": "密碼重設", "link": "/docs/12.x/passwords" } ] }, { "text": "資料庫", "collapsed": false, "items": [ { "text": "入門", "link": "/docs/12.x/database" }, { "text": "查詢產生器", "link": "/docs/12.x/queries" }, { "text": "分頁", "link": "/docs/12.x/pagination" }, { "text": "遷移", "link": "/docs/12.x/migrations" }, { "text": "填充", "link": "/docs/12.x/seeding" }, { "text": "Redis", "link": "/docs/12.x/redis" }, { "text": "MongoDB", "link": "/docs/12.x/mongodb" } ] }, { "text": "Eloquent ORM", "collapsed": false, "items": [ { "text": "入門", "link": "/docs/12.x/eloquent" }, { "text": "關聯", "link": "/docs/12.x/eloquent-relationships" }, { "text": "集合", "link": "/docs/12.x/eloquent-collections" }, { "text": "修改器 / 型別轉換", "link": "/docs/12.x/eloquent-mutators" }, { "text": "API 資源", "link": "/docs/12.x/eloquent-resources" }, { "text": "序列化", "link": "/docs/12.x/eloquent-serialization" }, { "text": "工廠", "link": "/docs/12.x/eloquent-factories" } ] }, { "text": "測試", "collapsed": false, "items": [ { "text": "入門", "link": "/docs/12.x/testing" }, { "text": "HTTP 測試", "link": "/docs/12.x/http-tests" }, { "text": "主控台測試", "link": "/docs/12.x/console-tests" }, { "text": "瀏覽器測試", "link": "/docs/12.x/dusk" }, { "text": "資料庫", "link": "/docs/12.x/database-testing" }, { "text": "模擬", "link": "/docs/12.x/mocking" } ] }, { "text": "套件", "collapsed": false, "items": [ { "text": "Cashier (Stripe)", "link": "/docs/12.x/billing" }, { "text": "Cashier (Paddle)", "link": "/docs/12.x/cashier-paddle" }, { "text": "Dusk", "link": "/docs/12.x/dusk" }, { "text": "Envoy", "link": "/docs/12.x/envoy" }, { "text": "Fortify", "link": "/docs/12.x/fortify" }, { "text": "Folio", "link": "/docs/12.x/folio" }, { "text": "Homestead", "link": "/docs/12.x/homestead" }, { "text": "Horizon", "link": "/docs/12.x/horizon" }, { "text": "MCP", "link": "/docs/12.x/mcp" }, { "text": "Mix", "link": "/docs/12.x/mix" }, { "text": "Octane", "link": "/docs/12.x/octane" }, { "text": "Passport", "link": "/docs/12.x/passport" }, { "text": "Pennant", "link": "/docs/12.x/pennant" }, { "text": "Pint", "link": "/docs/12.x/pint" }, { "text": "Precognition", "link": "/docs/12.x/precognition" }, { "text": "Prompts", "link": "/docs/12.x/prompts" }, { "text": "Pulse", "link": "/docs/12.x/pulse" }, { "text": "Reverb", "link": "/docs/12.x/reverb" }, { "text": "Sail", "link": "/docs/12.x/sail" }, { "text": "Sanctum", "link": "/docs/12.x/sanctum" }, { "text": "Scout", "link": "/docs/12.x/scout" }, { "text": "Socialite", "link": "/docs/12.x/socialite" }, { "text": "Telescope", "link": "/docs/12.x/telescope" }, { "text": "Valet", "link": "/docs/12.x/valet" }, { "text": "API 文件", "link": "https://api.laravel.com/docs/12.x" } ] } ], "/docs/11.x/": [ { "text": "前言", "collapsed": false, "items": [ { "text": "版本說明", "link": "/docs/11.x/releases" }, { "text": "升級指南", "link": "/docs/11.x/upgrade" }, { "text": "貢獻指南", "link": "/docs/11.x/contributions" } ] }, { "text": "開始使用", "collapsed": false, "items": [ { "text": "安裝", "link": "/docs/11.x/installation" }, { "text": "設定", "link": "/docs/11.x/configuration" }, { "text": "目錄結構", "link": "/docs/11.x/structure" }, { "text": "前端", "link": "/docs/11.x/frontend" }, { "text": "入門套件", "link": "/docs/11.x/starter-kits" }, { "text": "部署", "link": "/docs/11.x/deployment" } ] }, { "text": "架構概念", "collapsed": false, "items": [ { "text": "請求生命週期", "link": "/docs/11.x/lifecycle" }, { "text": "服務容器", "link": "/docs/11.x/container" }, { "text": "服務提供者", "link": "/docs/11.x/providers" }, { "text": "Facades", "link": "/docs/11.x/facades" } ] }, { "text": "基礎概念", "collapsed": false, "items": [ { "text": "路由", "link": "/docs/11.x/routing" }, { "text": "中介層", "link": "/docs/11.x/middleware" }, { "text": "CSRF 保護", "link": "/docs/11.x/csrf" }, { "text": "控制器", "link": "/docs/11.x/controllers" }, { "text": "請求", "link": "/docs/11.x/requests" }, { "text": "回應", "link": "/docs/11.x/responses" }, { "text": "視圖", "link": "/docs/11.x/views" }, { "text": "Blade 模板", "link": "/docs/11.x/blade" }, { "text": "資源打包", "link": "/docs/11.x/vite" }, { "text": "URL 生成", "link": "/docs/11.x/urls" }, { "text": "Session", "link": "/docs/11.x/session" }, { "text": "驗證", "link": "/docs/11.x/validation" }, { "text": "錯誤處理", "link": "/docs/11.x/errors" }, { "text": "日誌", "link": "/docs/11.x/logging" } ] }, { "text": "深入探索", "collapsed": false, "items": [ { "text": "Artisan 主控台", "link": "/docs/11.x/artisan" }, { "text": "廣播", "link": "/docs/11.x/broadcasting" }, { "text": "快取", "link": "/docs/11.x/cache" }, { "text": "集合", "link": "/docs/11.x/collections" }, { "text": "並行處理", "link": "/docs/11.x/concurrency" }, { "text": "上下文", "link": "/docs/11.x/context" }, { "text": "契約", "link": "/docs/11.x/contracts" }, { "text": "事件", "link": "/docs/11.x/events" }, { "text": "檔案儲存", "link": "/docs/11.x/filesystem" }, { "text": "輔助函式", "link": "/docs/11.x/helpers" }, { "text": "HTTP 用戶端", "link": "/docs/11.x/http-client" }, { "text": "本地化", "link": "/docs/11.x/localization" }, { "text": "郵件", "link": "/docs/11.x/mail" }, { "text": "通知", "link": "/docs/11.x/notifications" }, { "text": "套件開發", "link": "/docs/11.x/packages" }, { "text": "程序", "link": "/docs/11.x/processes" }, { "text": "佇列", "link": "/docs/11.x/queues" }, { "text": "速率限制", "link": "/docs/11.x/rate-limiting" }, { "text": "字串", "link": "/docs/11.x/strings" }, { "text": "排程任務", "link": "/docs/11.x/scheduling" } ] }, { "text": "安全", "collapsed": false, "items": [ { "text": "身份驗證", "link": "/docs/11.x/authentication" }, { "text": "授權", "link": "/docs/11.x/authorization" }, { "text": "電子郵件驗證", "link": "/docs/11.x/verification" }, { "text": "加密", "link": "/docs/11.x/encryption" }, { "text": "雜湊", "link": "/docs/11.x/hashing" }, { "text": "密碼重設", "link": "/docs/11.x/passwords" } ] }, { "text": "資料庫", "collapsed": false, "items": [ { "text": "開始使用", "link": "/docs/11.x/database" }, { "text": "查詢產生器", "link": "/docs/11.x/queries" }, { "text": "分頁", "link": "/docs/11.x/pagination" }, { "text": "遷移", "link": "/docs/11.x/migrations" }, { "text": "資料填充", "link": "/docs/11.x/seeding" }, { "text": "Redis", "link": "/docs/11.x/redis" }, { "text": "MongoDB", "link": "/docs/11.x/mongodb" } ] }, { "text": "Eloquent ORM", "collapsed": false, "items": [ { "text": "開始使用", "link": "/docs/11.x/eloquent" }, { "text": "關聯", "link": "/docs/11.x/eloquent-relationships" }, { "text": "集合", "link": "/docs/11.x/eloquent-collections" }, { "text": "存取器/型別轉換", "link": "/docs/11.x/eloquent-mutators" }, { "text": "API 資源", "link": "/docs/11.x/eloquent-resources" }, { "text": "序列化", "link": "/docs/11.x/eloquent-serialization" }, { "text": "Factory", "link": "/docs/11.x/eloquent-factories" } ] }, { "text": "測試", "collapsed": false, "items": [ { "text": "開始使用", "link": "/docs/11.x/testing" }, { "text": "HTTP 測試", "link": "/docs/11.x/http-tests" }, { "text": "主控台測試", "link": "/docs/11.x/console-tests" }, { "text": "瀏覽器測試", "link": "/docs/11.x/dusk" }, { "text": "資料庫", "link": "/docs/11.x/database-testing" }, { "text": "Mocking", "link": "/docs/11.x/mocking" } ] }, { "text": "套件", "collapsed": false, "items": [ { "text": "Breeze", "link": "/docs/11.x/starter-kits#laravel-breeze" }, { "text": "Cashier (Stripe)", "link": "/docs/11.x/billing" }, { "text": "Cashier (Paddle)", "link": "/docs/11.x/cashier-paddle" }, { "text": "Dusk", "link": "/docs/11.x/dusk" }, { "text": "Envoy", "link": "/docs/11.x/envoy" }, { "text": "Fortify", "link": "/docs/11.x/fortify" }, { "text": "Folio", "link": "/docs/11.x/folio" }, { "text": "Homestead", "link": "/docs/11.x/homestead" }, { "text": "Horizon", "link": "/docs/11.x/horizon" }, { "text": "Jetstream", "link": "https://jetstream.laravel.com" }, { "text": "MCP", "link": "/docs/11.x/mcp" }, { "text": "Mix", "link": "/docs/11.x/mix" }, { "text": "Octane", "link": "/docs/11.x/octane" }, { "text": "Passport", "link": "/docs/11.x/passport" }, { "text": "Pennant", "link": "/docs/11.x/pennant" }, { "text": "Pint", "link": "/docs/11.x/pint" }, { "text": "Precognition", "link": "/docs/11.x/precognition" }, { "text": "Prompts", "link": "/docs/11.x/prompts" }, { "text": "Pulse", "link": "/docs/11.x/pulse" }, { "text": "Reverb", "link": "/docs/11.x/reverb" }, { "text": "Sail", "link": "/docs/11.x/sail" }, { "text": "Sanctum", "link": "/docs/11.x/sanctum" }, { "text": "Scout", "link": "/docs/11.x/scout" }, { "text": "Socialite", "link": "/docs/11.x/socialite" }, { "text": "Telescope", "link": "/docs/11.x/telescope" }, { "text": "Valet", "link": "/docs/11.x/valet" }, { "text": "API 文件", "link": "https://api.laravel.com/docs/11.x" } ] } ], "/": [ { "text": "Examples", "items": [ { "text": "開始閱讀", "link": "/docs/12.x/installation" }, { "text": "Runtime API Examples", "link": "/api-examples" } ] } ] }, "socialLinks": [ { "icon": "github", "link": "https://github.com/laradoc-trans-lab" } ] }
Page Data
{ "title": "Runtime API Examples", "description": "", "frontmatter": { "outline": "deep" }, "headers": [], "relativePath": "api-examples.md", "filePath": "api-examples.md" }
Page Frontmatter
{ "outline": "deep" }
More
Check out the documentation for the full list of runtime APIs.