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": "ETS2LA 中文维基",
"logo": "/image/svg/logo.svg",
"nav": [
{
"text": "主页",
"link": "/"
},
{
"text": "文档",
"items": [
{
"text": "基础",
"link": "/docs/base/install"
},
{
"items": [
{
"text": "进阶",
"link": "/docs/advanced/manual-install"
}
]
}
]
},
{
"text": "作者",
"link": "/author/"
},
{
"text": "赞助名单",
"link": "/sponsored/"
}
],
"sidebar": {
"/docs/base/": [
{
"text": "自动安装",
"link": "/docs/base//install.md"
},
{
"text": "页面介绍",
"link": "/docs/base//page.md"
},
{
"text": "插件介绍",
"link": "/docs/base//plugins.md"
},
{
"text": "基础使用",
"link": "/docs/base//use.md"
}
],
"/docs/advanced/": [
{
"text": "手动安装",
"link": "/docs/advanced//manual-install.md"
},
{
"text": "地图数据提取",
"link": "/docs/advanced//map_data_extract.md"
},
{
"text": "mobile",
"collapsible": true,
"items": [
{
"text": "浏览器查看",
"link": "/docs/advanced//mobile/browser.md"
},
{
"text": "软件查看",
"link": "/docs/advanced//mobile/software.md"
}
]
}
],
"/author/": [],
"/sponsored/": [],
"/": [
{
"text": ".edgeone",
"collapsible": true,
"items": []
},
{
"text": ".git",
"collapsible": true,
"items": [
{
"text": "branches",
"collapsible": true,
"items": []
},
{
"text": "hooks",
"collapsible": true,
"items": []
},
{
"text": "info",
"collapsible": true,
"items": []
},
{
"text": "logs",
"collapsible": true,
"items": [
{
"text": "refs",
"collapsible": true,
"items": [
{
"text": "heads",
"collapsible": true,
"items": []
},
{
"text": "remotes",
"collapsible": true,
"items": [
{
"text": "origin",
"collapsible": true,
"items": []
}
]
}
]
}
]
},
{
"text": "objects",
"collapsible": true,
"items": [
{
"text": "info",
"collapsible": true,
"items": []
},
{
"text": "pack",
"collapsible": true,
"items": []
}
]
},
{
"text": "refs",
"collapsible": true,
"items": [
{
"text": "heads",
"collapsible": true,
"items": []
},
{
"text": "remotes",
"collapsible": true,
"items": [
{
"text": "origin",
"collapsible": true,
"items": []
}
]
},
{
"text": "tags",
"collapsible": true,
"items": []
}
]
}
]
},
{
"text": ".github",
"collapsible": true,
"items": [
{
"text": "workflows",
"collapsible": true,
"items": []
}
]
},
{
"text": ".vscode",
"collapsible": true,
"items": []
},
{
"text": "README.md",
"link": "/README.md"
},
{
"text": "api-examples.md",
"link": "/api-examples.md"
},
{
"text": "作者",
"collapsible": true,
"items": [
{
"text": "作者",
"link": "/author/index.md"
}
]
},
{
"text": "使用",
"collapsible": true,
"items": [
{
"text": "advanced",
"collapsible": true,
"items": [
{
"text": "手动安装",
"link": "/docs/advanced/manual-install.md"
},
{
"text": "地图数据提取",
"link": "/docs/advanced/map_data_extract.md"
},
{
"text": "mobile",
"collapsible": true,
"items": [
{
"text": "浏览器查看",
"link": "/docs/advanced/mobile/browser.md"
},
{
"text": "软件查看",
"link": "/docs/advanced/mobile/software.md"
}
]
}
]
},
{
"text": "base",
"collapsible": true,
"items": [
{
"text": "自动安装",
"link": "/docs/base/install.md"
},
{
"text": "页面介绍",
"link": "/docs/base/page.md"
},
{
"text": "插件介绍",
"link": "/docs/base/plugins.md"
},
{
"text": "基础使用",
"link": "/docs/base/use.md"
}
]
},
{
"text": "使用",
"link": "/docs/index.md"
}
]
},
{
"text": "markdown-examples.md",
"link": "/markdown-examples.md"
},
{
"text": "public",
"collapsible": true,
"items": [
{
"text": "image",
"collapsible": true,
"items": [
{
"text": "author",
"collapsible": true,
"items": []
},
{
"text": "svg",
"collapsible": true,
"items": []
}
]
}
]
},
{
"text": "赞助名单",
"collapsible": true,
"items": [
{
"text": "赞助名单",
"link": "/sponsored/index.md"
}
]
}
]
},
"outline": "deep",
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/ETS2LA/Euro-Truck-Simulator-2-Lane-Assist"
},
{
"icon": "discord",
"link": "https://ets2la.com/discord"
},
{
"icon": {
"svg": "<svg t=\"1764297309339\" class=\"icon\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"4765\" width=\"200\" height=\"200\"><path d=\"M153.930323 0L0 724.067097l56.485161 108.345806h370.621936l86.214193 166.152258h83.571613l36.005162-166.152258h229.24387l150.95742-719.44258L952.980645 0H153.930323z m45.584516 706.56L328.010323 114.952258h190.926451l-32.701935 152.609032 141.047742-158.224516h185.64129l-14.534194 79.27742-214.709677 249.393548 115.612903 202.157419-16.516129 66.394839h-176.392258l-84.892903-157.894194-27.086452 157.894194h-194.890322z\" p-id=\"4766\"></path></svg>"
},
"link": "https://www.kookapp.cn/app/invite/VZaUPP",
"ariaLabel": "kook link"
},
{
"icon": {
"svg": "<svg t=\"1764297464837\" class=\"icon\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"6582\" width=\"200\" height=\"200\"><path d=\"M789 610.3c-38.7-12.9-90.7-32.7-148.5-53.6 34.8-60.3 62.5-129 80.7-203.6H530.5v-68.6h233.6v-38.3H530.5V132h-95.4c-16.7 0-16.7 16.5-16.7 16.5v97.8H182.2v38.3h236.3v68.6H223.4v38.3h378.4c-13.8 47.6-32.4 92.3-54.5 132.9-122.8-40.4-253.8-73.2-336.1-53-52.6 13-86.5 36.1-106.5 60.3-91.4 111-25.9 279.6 167.2 279.6C386 811.2 496 747.6 581.2 643 708.3 704 960 808.7 960 808.7V659.4s-31.6-2.5-171-49.1zM253.9 746.6c-150.5 0-195-118.3-120.6-183.1 24.8-21.9 70.2-32.6 94.4-35 89.4-8.8 172.2 25.2 269.9 72.8-68.8 89.5-156.3 145.3-243.7 145.3z\" p-id=\"6583\"></path></svg>"
},
"link": "/image/sponsor.png",
"ariaLabel": "alipay link"
}
],
"footer": {
"message": "<a href=\"https://beian.miit.gov.cn/\" target=\"_blank\" rel=\"noopener\">苏ICP备2025160641号-3</a> | <a href=\"https://www.beian.gov.cn/portal/registerSystemInfo?recordcode=32120202010796\" target=\"_blank\" rel=\"noopener\">苏公网安备32120202010796号</a>"
}
}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.