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": "Examples",
"link": "/markdown-examples"
},
{
"text": "登录",
"target": "_self",
"link": "http://localhost:8080/wechat-oplatform/website/authorize/wxbb243b39b1454e00?binding=redirectUrl=http://localhost:5173/docker"
}
],
"logo": "/logo.png",
"sidebar": [
{
"text": "容器虚拟化",
"items": [
{
"text": "Docker",
"link": "/docker"
}
]
},
{
"text": "Redis",
"items": [
{
"text": "Redis客户端比较",
"link": "/code/redis/redis"
}
]
},
{
"text": "Docs",
"items": [
{
"text": "Docs",
"link": "/introduction/docs"
}
]
},
{
"text": "Dev",
"items": [
{
"text": "nvm",
"link": "/dev/nvm"
},
{
"text": "MacOs",
"link": "/dev/mac-mingling"
}
]
},
{
"text": "Clear",
"items": [
{
"text": "构建产物清理",
"link": "/code/clear/fileClear"
}
]
},
{
"text": "Java",
"items": [
{
"text": "Java",
"link": "/introduction/java-version"
},
{
"text": "BigDecimal序列化为数字",
"link": "/code/java/example/1_BigDecimalSerializer"
},
{
"text": "Deploy",
"link": "/code/java/deploy"
},
{
"text": "Jar包反编译",
"link": "/code/java/jar-decompile"
},
{
"text": "java程序诊断",
"link": "/code/java/jvm"
}
]
},
{
"text": "Spring",
"items": [
{
"text": "Spring Listener",
"link": "/code/java/spring/spring-listener"
},
{
"text": "SpringBoot 构建打包时间",
"link": "/code/java/springboot/maven-version"
}
]
},
{
"text": "CI / CD",
"items": [
{
"text": "gitlab",
"link": "/cicd/gitlab/"
},
{
"text": "nexus",
"link": "/cicd/nexus/"
}
]
},
{
"text": "System Os",
"items": [
{
"text": "Code",
"link": "/linux/code"
},
{
"text": "Debian",
"link": "/linux/debian"
}
]
},
{
"text": "software",
"items": [
{
"text": "nginx源码编译",
"link": "/software/nginx/compile"
}
]
},
{
"text": "Proxy",
"items": [
{
"text": "openvpn",
"link": "/proxy/openvpn"
}
]
}
],
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/vuejs/vitepress"
}
]
}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.
