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
{
"logo": "https://cdn.jsdelivr.net/gh/hypocritical-jiang/blog-assets@main/images/icons8-worldwide-delivery-96.png",
"nav": [
{
"text": "首页",
"link": "/"
},
{
"text": "归档",
"link": "/archives/"
},
{
"text": "分类",
"link": "/categories/"
},
{
"text": "标签",
"link": "/tags/"
},
{
"text": "关于我",
"items": [
{
"text": "github",
"link": ""
},
{
"text": "bilibili",
"link": ""
}
]
}
],
"sidebar": [
{
"text": "学习笔记",
"collapsed": true,
"items": [
{
"text": "AI和深度学习",
"collapsed": true,
"items": [
{
"text": "1 AI和机器学习",
"link": "/posts/durham_study/Aritifical_intelligence/1"
},
{
"text": "2 机器学习基础",
"link": "/posts/durham_study/Aritifical_intelligence/2"
}
]
},
{
"text": "先进电子",
"collapsed": true,
"items": [
{
"text": "lecture 15 自组装与薄膜制造",
"link": "/posts/durham_study/advanced_electronics/15"
}
]
},
{
"text": "先进电子测量",
"collapsed": true,
"items": [
{
"text": "1 MIMO 无线通信",
"link": "/posts/durham_study/advanced_electronics_Measurements/1"
},
{
"text": "2 无线电传播信号",
"link": "/posts/durham_study/advanced_electronics_Measurements/2"
},
{
"text": "3 无线电传播信号",
"link": "/posts/durham_study/advanced_electronics_Measurements/3"
},
{
"text": "1 多径传输与信道建模",
"link": "/posts/durham_study/advanced_electronics_Measurements/summary_1"
},
{
"text": "2 多径信道的参数分析",
"link": "/posts/durham_study/advanced_electronics_Measurements/summary_2"
},
{
"text": "3 小尺度衰落的分类",
"link": "/posts/durham_study/advanced_electronics_Measurements/summary_3"
}
]
},
{
"text": "通信网络",
"collapsed": true,
"items": [
{
"text": "17 网络层协议",
"link": "/posts/durham_study/communication_networks/17"
}
]
},
{
"text": "光子学",
"collapsed": true,
"items": [
{
"text": "0 基础知识复习",
"link": "/posts/durham_study/phontonics/0"
},
{
"text": "1 无损传输线模型",
"link": "/posts/durham_study/phontonics/1"
},
{
"text": "2 有限传输线模型",
"link": "/posts/durham_study/phontonics/2"
},
{
"text": "3 有损传输线模型",
"link": "/posts/durham_study/phontonics/3"
},
{
"text": "4 麦克斯韦方程",
"link": "/posts/durham_study/phontonics/4"
},
{
"text": "Devices 0 课程先导",
"link": "/posts/durham_study/phontonics/5"
}
]
},
{
"text": "无线电与电子通信",
"collapsed": true,
"items": [
{
"text": "Radio Part 5",
"link": "/posts/durham_study/radio_and_digital_communication/Radio_part_5"
}
]
}
]
},
{
"text": "前端",
"collapsed": true,
"items": []
},
{
"text": "机器学习",
"collapsed": true,
"items": []
}
],
"outline": {
"level": [
1,
4
]
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/vuejs/vitepress"
}
]
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "categories/index.md",
"filePath": "categories/index.md"
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.