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
{ "nav": [ { "text": "主页", "link": "/zh" }, { "text": "经纪商", "items": [ { "items": [ { "text": "Exness返佣", "link": "/zh/forex-brokers/exness/exness-rebates" }, { "text": "IC Markets返佣", "link": "/zh/forex-brokers/icmarkets/icmarkets-rebates" }, { "text": "XM返佣", "link": "/zh/forex-brokers/xm/xm-rebates" }, { "text": "TMGM返佣", "link": "/zh/forex-brokers/tmgm/tmgm-rebates" }, { "text": "TickMill返佣", "link": "/zh/forex-brokers/tickmill/tickmill-rebates" }, { "text": "Pepperstone返佣", "link": "/zh/forex-brokers/pepperstone/pepperstone-rebates" } ] } ] }, { "text": "关于我们", "link": "/zh/aboutus" }, { "text": "合作与推荐奖励", "link": "/zh/sponsorus" }, { "text": "联系我们", "link": "/zh/contactus" }, { "text": "博客", "items": [ { "text": "行业资讯", "link": "/zh/blog/forex-news/index" }, { "text": "技术分析", "link": "/zh/blog/technical-analysis/" }, { "text": "活动", "link": "/zh/blog/promotions/" } ] } ], "sidebar": { "/zh/blog/": [ { "text": "外汇资讯", "collapsible": true, "collapsed": true, "items": [ { "text": "2024.06", "collapsible": true, "collapsed": true, "items": [ { "text": "24", "link": "zh\\blog\\forex-news\\2024.06\\24.md" }, { "text": "6.19", "link": "zh\\blog\\forex-news\\2024.06\\6.19.md" } ] }, { "text": "2024.07", "collapsible": true, "collapsed": true, "items": [ { "text": "Impact of global elections on international financial markets in 2024", "link": "zh\\blog\\forex-news\\2024.07\\impact-of-global-elections-on-international-financial-markets-in-2024.md" } ] }, { "text": "Index", "link": "zh\\blog\\forex-news\\index.md" } ] }, { "text": "外汇交易教程", "collapsible": true, "collapsed": true, "items": [ { "text": "外汇交易简介", "link": "zh\\blog\\forex-trading-course\\1.introduction.md" }, { "text": "市场结构", "link": "zh\\blog\\forex-trading-course\\2.md" }, { "text": "技术指标", "link": "zh\\blog\\forex-trading-course\\3.md" }, { "text": "Forex Trading Course", "link": "zh\\blog\\forex-trading-course\\index.md" } ] }, { "text": "技术分析", "collapsible": true, "collapsed": true, "items": [ { "text": "2024.06", "collapsible": true, "collapsed": true, "items": [ { "text": "6.17", "link": "zh\\blog\\technical-analysis\\2024.06\\6.17.md" } ] } ] }, { "text": "优惠活动", "collapsible": true, "collapsed": true, "items": [ { "text": "Exness promotions", "link": "zh\\blog\\promotions\\exness-promotions.md" }, { "text": "Icmarkets promotions", "link": "zh\\blog\\promotions\\icmarkets-promotions.md" }, { "text": "活动", "link": "zh\\blog\\promotions\\index.md" }, { "text": "Pepperstone promotions", "link": "zh\\blog\\promotions\\pepperstone-promotions.md" }, { "text": "Tickmill promotions", "link": "zh\\blog\\promotions\\tickmill-promotions.md" }, { "text": "Xm promotions", "link": "zh\\blog\\promotions\\xm-promotions.md" } ] } ], "/zh/forex-brokers/": [ { "text": "经纪商列表", "items": [ { "text": "Exness返佣", "link": "/zh/forex-brokers/exness/exness-rebates" }, { "text": "IC Markets返佣", "link": "/zh/forex-brokers/icmarkets/icmarkets-rebates" }, { "text": "XM返佣", "link": "/zh/forex-brokers/xm/xm-rebates" }, { "text": "TMGM返佣", "link": "/zh/forex-brokers/tmgm/tmgm-rebates" }, { "text": "TickMill返佣", "link": "/zh/forex-brokers/tickmill/tickmill-rebates" }, { "text": "Pepperstone返佣", "link": "/zh/forex-brokers/pepperstone/pepperstone-rebates" } ] } ] }, "socialLinks": [ { "icon": { "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" class=\"bi bi-telegram\" viewBox=\"0 0 16 16\"><path d=\"M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M8.287 5.906q-1.168.486-4.666 2.01-.567.225-.595.442c-.03.243.275.339.69.47l.175.055c.408.133.958.288 1.243.294q.39.01.868-.32 3.269-2.206 3.374-2.23c.05-.012.12-.026.166.016s.042.12.037.141c-.03.129-1.227 1.241-1.846 1.817-.193.18-.33.307-.358.336a8 8 0 0 1-.188.186c-.38.366-.664.64.015 1.088.327.216.589.393.85.571.284.194.568.387.936.629q.14.092.27.187c.331.236.63.448.997.414.214-.02.435-.22.547-.82.265-1.417.786-4.486.906-5.751a1.4 1.4 0 0 0-.013-.315.34.34 0 0 0-.114-.217.53.53 0 0 0-.31-.093c-.3.005-.763.166-2.984 1.09\"/></svg>" }, "link": "https://t.me/fxcashbackrebate", "ariaLabel": "telegram link" }, { "icon": { "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" class=\"bi bi-skype\" viewBox=\"0 0 16 16\"><path d=\"M4.671 0c.88 0 1.733.247 2.468.702a7.42 7.42 0 0 1 6.02 2.118 7.37 7.37 0 0 1 2.167 5.215q0 .517-.072 1.026a4.66 4.66 0 0 1 .6 2.281 4.64 4.64 0 0 1-1.37 3.294A4.67 4.67 0 0 1 11.18 16c-.84 0-1.658-.226-2.37-.644a7.42 7.42 0 0 1-6.114-2.107A7.37 7.37 0 0 1 .529 8.035q0-.545.08-1.081a4.644 4.644 0 0 1 .76-5.59A4.68 4.68 0 0 1 4.67 0zm.447 7.01c.18.309.43.572.729.769a7 7 0 0 0 1.257.653q.737.308 1.145.523c.229.112.437.264.615.448.135.142.21.331.21.528a.87.87 0 0 1-.335.723c-.291.196-.64.289-.99.264a2.6 2.6 0 0 1-1.048-.206 11 11 0 0 1-.532-.253 1.3 1.3 0 0 0-.587-.15.72.72 0 0 0-.501.176.63.63 0 0 0-.195.491.8.8 0 0 0 .148.482 1.2 1.2 0 0 0 .456.354 5.1 5.1 0 0 0 2.212.419 4.6 4.6 0 0 0 1.624-.265 2.3 2.3 0 0 0 1.08-.801c.267-.39.402-.855.386-1.327a2.1 2.1 0 0 0-.279-1.101 2.5 2.5 0 0 0-.772-.792A7 7 0 0 0 8.486 7.3a1 1 0 0 0-.145-.058 18 18 0 0 1-1.013-.447 1.8 1.8 0 0 1-.54-.387.73.73 0 0 1-.2-.508.8.8 0 0 1 .385-.723 1.76 1.76 0 0 1 .968-.247c.26-.003.52.03.772.096q.412.119.802.293c.105.049.22.075.336.076a.6.6 0 0 0 .453-.19.7.7 0 0 0 .18-.496.72.72 0 0 0-.17-.476 1.4 1.4 0 0 0-.556-.354 3.7 3.7 0 0 0-.708-.183 6 6 0 0 0-1.022-.078 4.5 4.5 0 0 0-1.536.258 2.7 2.7 0 0 0-1.174.784 1.9 1.9 0 0 0-.45 1.287c-.01.37.076.736.25 1.063\"/></svg>" }, "link": "skype:live:.cid.5c511db31fdbbef7", "ariaLabel": "skype link" } ], "footer": { "message": "Sponsored by <a href=\"https://www.ex-markets.com/a/9134579\" rel=\"nofollow noopener\">Exness<a/>", "copyright": "版权所有 © 2019-2024 Fxcashbackrebate" }, "docFooter": { "prev": "上一页", "next": "下一页" }, "outline": { "label": "页面导航" }, "lastUpdated": { "text": "最后更新于", "formatOptions": { "dateStyle": "short", "timeStyle": "medium" } }, "langMenuLabel": "多语言", "returnToTopLabel": "回到顶部", "sidebarMenuLabel": "菜单", "darkModeSwitchLabel": "主题", "lightModeSwitchTitle": "切换到浅色模式", "darkModeSwitchTitle": "切换到深色模式" }
Page Data
{ "title": "Runtime API Examples", "description": "", "frontmatter": { "outline": "deep", "head": [ [ "link", { "rel": "alternate", "hreflang": "x-default", "href": "https://www.fxcashbackrebate.com/api-examples" } ], [ "link", { "rel": "alternate", "hreflang": "en", "href": "https://www.fxcashbackrebate.com/api-examples" } ], [ "link", { "rel": "alternate", "hreflang": "vi", "href": "https://www.fxcashbackrebate.com/vi/api-examples" } ], [ "link", { "rel": "alternate", "hreflang": "th", "href": "https://www.fxcashbackrebate.com/th/api-examples" } ], [ "link", { "rel": "alternate", "hreflang": "ja", "href": "https://www.fxcashbackrebate.com/ja/api-examples" } ], [ "link", { "rel": "alternate", "hreflang": "zh-hans", "href": "https://www.fxcashbackrebate.com/zh/api-examples" } ] ] }, "headers": [], "relativePath": "zh/api-examples.md", "filePath": "zh/api-examples.md", "lastUpdated": 1718870930000 }
Page Frontmatter
{ "outline": "deep", "head": [ [ "link", { "rel": "alternate", "hreflang": "x-default", "href": "https://www.fxcashbackrebate.com/api-examples" } ], [ "link", { "rel": "alternate", "hreflang": "en", "href": "https://www.fxcashbackrebate.com/api-examples" } ], [ "link", { "rel": "alternate", "hreflang": "vi", "href": "https://www.fxcashbackrebate.com/vi/api-examples" } ], [ "link", { "rel": "alternate", "hreflang": "th", "href": "https://www.fxcashbackrebate.com/th/api-examples" } ], [ "link", { "rel": "alternate", "hreflang": "ja", "href": "https://www.fxcashbackrebate.com/ja/api-examples" } ], [ "link", { "rel": "alternate", "hreflang": "zh-hans", "href": "https://www.fxcashbackrebate.com/zh/api-examples" } ] ] }
More
Check out the documentation for the full list of runtime APIs.