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": "Data Collection", "link": "/pages_datacollection.md" }, { "text": "Data Cleaning", "link": "/pages_datacleaning.md" }, { "text": "Data Analysis Samples", "link": "/pages_dataanalysis_samples.md" }, { "text": "Datasets Intro", "link": "/pages_datasets_intro.md" }, { "text": "Data Scraping", "items": [ { "text": "Apple Store", "link": "/pages_datascraping_applestore.md" }, { "text": "Google News", "link": "/pages_datascraping_googlenews.md" }, { "text": "Mastodon", "link": "/pages_datascraping_mastodon.md" }, { "text": "Social Media", "link": "/pages_datascraping_socialmedia.md" }, { "text": "Twitter", "link": "/pages_datascraping_twitter.md" }, { "text": "YouTube", "link": "/pages_datascraping_youtube.md" } ] }, { "text": "Skills", "items": [ { "text": "1.0 VPN Client", "link": "/pages_skills1_0_VPNclient.md" }, { "text": "1.1 DSRI", "link": "/pages_skills1_1_DSRI.md" }, { "text": "1.2 Scrape Apple Reviews", "link": "/pages_skills1_2_scrapeAPPLEreviews.md" }, { "text": "1.3 OpenRefine", "link": "/pages_skills1_3_OpenRefine.md" }, { "text": "1.4 Batch Download", "link": "/pages_skills1-4_batchdownload.md" }, { "text": "2.2 Case Study", "link": "/pages_skills2-2_casestudy.md" }, { "text": "2.1 Voyant Tools", "link": "/pages_skills2_1_VoyantTools.md" }, { "text": "3. Presentations", "link": "/pages_skills3_presentations.md" } ] }, { "text": "Task Sheets", "items": [ { "text": "Elon Musk", "link": "/pages_tasksheet_elonmusk.md" }, { "text": "Girlboss", "link": "/pages_tasksheet_girlboss.md" }, { "text": "Menstruation", "link": "/pages_tasksheet_menstruation.md" }, { "text": "Miley Cyrus", "link": "/pages_tasksheet_mileycyrus.md" }, { "text": "Seretse Khama", "link": "/pages_tasksheet_seretsekhama.md" }, { "text": "Slavery", "link": "/pages_tasksheet_slavery.md" }, { "text": "Soraya Esfandiary", "link": "/pages_tasksheet_sorayaesfandiary.md" }, { "text": "True Crime", "link": "/pages_tasksheet_truecrime.md" }, { "text": "Witchcraft", "link": "/pages_tasksheet_witchcraft.md" } ] } ], "sidebar": [ { "text": "Examples", "items": [ { "text": "Markdown Examples", "link": "/markdown-examples" }, { "text": "Runtime API Examples", "link": "/api-examples" } ] } ], "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.