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": "Home",
"link": "/"
},
{
"text": "Pages",
"link": "/pages/"
},
{
"text": "Pics",
"link": "/pics/"
},
{
"text": "Text",
"link": "/text/"
}
],
"sidebar": {
"/pages/": [
{
"text": "Pages",
"link": "/pages/",
"items": [
{
"text": "Cloud",
"link": "/pages/#cloud",
"items": [
{
"text": "Cloudflare R2 ストレージを使ってみた",
"link": "/pages/cloud/cloudflare-r2/"
}
]
},
{
"text": "デバイス",
"link": "/pages/#デバイス",
"items": [
{
"text": "Windows をちょっとカッコよく使うTips",
"link": "/pages/device/windows-tips/"
},
{
"text": "iPad32GB の呪いから逃れる方法 ",
"link": "/pages/device/ipad-storage/"
}
]
},
{
"text": "Google Workspace",
"link": "/pages/#google-workspace",
"items": [
{
"text": "Googleスプレッドシートで文字がうまく打てない時の対処法",
"link": "/pages/gw/sheet-text-err/"
},
{
"text": "GoogleClassroomに参加する",
"link": "/pages/gw/classroom-login/"
}
]
},
{
"text": "JavaScript",
"link": "/pages/#javascript",
"items": [
{
"text": "JavaScript 備忘録集",
"link": "/pages/js/biboroku/"
},
{
"text": "ユーザー設定を保存するのに localforage が便利だよって話",
"link": "/pages/js/localforage/"
}
]
},
{
"text": "HTML",
"link": "/pages/#html",
"items": [
{
"text": "はじめてのWebサイト制作",
"link": "/pages/html/first-checklist/"
},
{
"text": "HTML 備忘録集",
"link": "/pages/html/biboroku/"
}
]
},
{
"text": "Python",
"link": "/pages/#python",
"items": [
{
"text": "Pythonに浸かる生活 ~入門編~",
"link": "/pages/python/tkr1/"
}
]
},
{
"text": "Vitepress",
"link": "/pages/#vitepress",
"items": [
{
"text": "Markdown Template",
"link": "/pages/vitepress/markdown-template/"
},
{
"text": "Markdown Examples",
"link": "/pages/vitepress/markdown-examples/"
},
{
"text": "Runtime API Examples",
"link": "/pages/vitepress/api-examples/"
}
]
}
]
}
]
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/famisics"
},
{
"icon": "twitter",
"link": "https://twitter.com/famisics"
},
{
"icon": "discord",
"link": "https://discordapp.com/users/953221656485171210"
}
],
"search": {
"provider": "local"
},
"footer": {
"message": "Hope your world",
"copyright": "© 2023 Setsuna Project"
},
"lastUpdated": true
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "pages/vitepress/api-examples/index.md",
"filePath": "pages/vitepress/api-examples/index.md",
"lastUpdated": 1766912935000
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.