Skip to content

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

{
  "appearance": false,
  "siteTitle": "阿健的学习小站",
  "logo": "/image/me.jpg",
  "logoAlt": "English Course Logo",
  "nav": [
    {
      "text": "个人主页",
      "link": "/"
    },
    {
      "text": "",
      "link": "/markdown-examples"
    },
    {
      "text": "话题口语",
      "link": "/40topic/00-口语课程"
    },
    {
      "text": "英语四级",
      "items": [
        {
          "text": "四级翻译",
          "link": "/Band4/translation/test"
        },
        {
          "text": "四级写作",
          "link": "/Band4/composition/test"
        }
      ]
    },
    {
      "text": "英语六级",
      "items": [
        {
          "items": [
            {
              "text": "2024年下",
              "link": "/Band4/composition/2024-12/test1"
            },
            {
              "text": "2024年上",
              "link": "/Band4/composition/2024-6/test1"
            }
          ]
        }
      ]
    }
  ],
  "sidebar": {
    "/40topic": [
      {
        "text": "00 口语课程",
        "link": "/40topic/00-口语课程"
      },
      {
        "text": "01 weather",
        "link": "/40topic/01-weather"
      },
      {
        "text": "02 shopping",
        "link": "/40topic/02-shopping"
      },
      {
        "text": "03 family",
        "link": "/40topic/03-family"
      },
      {
        "text": "04 health and fitness",
        "link": "/40topic/04-health-and-fitness"
      },
      {
        "text": "05 education",
        "link": "/40topic/05-education"
      },
      {
        "text": "06 technology",
        "link": "/40topic/06-technology"
      },
      {
        "text": "07 hobbies",
        "link": "/40topic/07-hobbies"
      },
      {
        "text": "08 holidays and celebrations",
        "link": "/40topic/08-holidays-and-celebrations"
      },
      {
        "text": "09 relationships",
        "link": "/40topic/09-relationships"
      },
      {
        "text": "10 nature and enviroment",
        "link": "/40topic/10-nature-and-enviroment"
      },
      {
        "text": "11 transportation",
        "link": "/40topic/11-transportation"
      },
      {
        "text": "12 festivals and traditions",
        "link": "/40topic/12-festivals-and-traditions"
      },
      {
        "text": "13 sports and games",
        "link": "/40topic/13-sports-and-games"
      },
      {
        "text": "14 house and home",
        "link": "/40topic/14-house-and-home"
      },
      {
        "text": "15 art and creativity",
        "link": "/40topic/15-art-and-creativity"
      },
      {
        "text": "16 fashion and style",
        "link": "/40topic/16-fashion-and-style"
      },
      {
        "text": "17 finance and budgeting",
        "link": "/40topic/17-finance-and-budgeting"
      },
      {
        "text": "18 news and current events",
        "link": "/40topic/18-news-and-current-events"
      },
      {
        "text": "19 movies and entertainment",
        "link": "/40topic/19-movies-and-entertainment"
      },
      {
        "text": "20 social media",
        "link": "/40topic/20-social-media"
      },
      {
        "text": "21 music and instruments",
        "link": "/40topic/21-music-and-instruments"
      },
      {
        "text": "22 future and goals",
        "link": "/40topic/22-future-and-goals"
      },
      {
        "text": "23 friendship",
        "link": "/40topic/23-friendship"
      },
      {
        "text": "24 pets and animals",
        "link": "/40topic/24-pets-and-animals"
      },
      {
        "text": "25 travel experience",
        "link": "/40topic/25-travel-experience"
      },
      {
        "text": "26 food and cooking",
        "link": "/40topic/26-food-and-cooking"
      },
      {
        "text": "27 memories and experiences",
        "link": "/40topic/27-memories-and-experiences"
      },
      {
        "text": "28 personal development",
        "link": "/40topic/28-personal-development"
      },
      {
        "text": "29 culture and diversity",
        "link": "/40topic/29-culture-and-diversity"
      },
      {
        "text": "30 work and career",
        "link": "/40topic/30-work-and-career"
      },
      {
        "text": "31 social issue",
        "link": "/40topic/31-social-issue"
      },
      {
        "text": "32 technology and innovation",
        "link": "/40topic/32-technology-and-innovation"
      },
      {
        "text": "33 school life",
        "link": "/40topic/33-school-life"
      },
      {
        "text": "34 idols and pop culture",
        "link": "/40topic/34-idols-and-pop-culture"
      },
      {
        "text": "35 nature and environment",
        "link": "/40topic/35-nature-and-environment"
      },
      {
        "text": "36 clothes and accessories",
        "link": "/40topic/36-clothes-and-accessories"
      },
      {
        "text": "37 technology and social change",
        "link": "/40topic/37-technology-and-social-change"
      },
      {
        "text": "38 local communities",
        "link": "/40topic/38-local-communities"
      },
      {
        "text": "39 daily routine",
        "link": "/40topic/39-daily-routine"
      },
      {
        "text": "40 motivation and discipline",
        "link": "/40topic/40-motivation-and-discipline"
      },
      {
        "text": "41 self care",
        "link": "/40topic/41-self-care"
      }
    ],
    "/Band4": [
      {
        "text": "test",
        "link": "/Band4/composition/test"
      },
      {
        "text": "20241201Translation",
        "link": "/Band4/translation/20241201Translation"
      },
      {
        "text": "test",
        "link": "/Band4/translation/test"
      }
    ]
  },
  "outline": {
    "label": "Lesson Contents"
  },
  "docFooter": {
    "prev": "Previous Lesson",
    "next": "Next Lesson"
  },
  "socialLinks": [
    {
      "icon": "zhihu",
      "link": "https://www.zhihu.com/people/gaojianweb"
    },
    {
      "icon": "wechat",
      "link": "https://www.zhihu.com/people/gaojianweb"
    }
  ],
  "footer": {
    "message": "Copyright © 2025 gaojian.site All rights reserved",
    "copyright": "<a href=\"https://beian.miit.gov.cn/\" target=\"_blank\">鲁ICP备2025161131号-1</a><img src=\"/beian_icon.png\" style=\"display: inline; margin: 5px;width: 16px\"   /><a href=\"https://beian.mps.gov.cn/#/query/webSearch?code=37021202001716\" rel=\"noreferrer\" target=\"_blank\">鲁公网安备37021202001716号</a>"
  },
  "search": {
    "provider": "local"
  }
}

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.