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

{
  "nav": [
    {
      "text": "Home",
      "link": "/"
    },
    {
      "text": "Examples",
      "link": "/markdown-examples"
    }
  ],
  "siteTitle": false,
  "logo": {
    "light": "/logow.svg",
    "dark": "/logo.svg"
  },
  "sidebar": [
    {
      "text": "소개",
      "items": [
        {
          "text": "단체 소개",
          "link": "/introduction"
        },
        {
          "text": "사업 소개",
          "items": [
            {
              "text": "교육 사업",
              "link": "/edu-intro"
            },
            {
              "text": "출판 사업",
              "link": "/pub-intro"
            }
          ]
        },
        {
          "text": "참여하기",
          "link": "/join"
        }
      ]
    },
    {
      "text": "출판 사업",
      "items": [
        {
          "text": "단체 소개",
          "link": "/introduction"
        },
        {
          "text": "사업 소개",
          "items": [
            {
              "text": "교육 사업",
              "link": "/edu-intro"
            },
            {
              "text": "출판 사업",
              "link": "/pub-intro"
            }
          ]
        }
      ]
    }
  ],
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/vuejs/vitepress"
    }
  ],
  "footer": {
    "message": "린티넥스트 | 대표자: 이서준 | 사업자등록번호: 220-82-77190 | <a target=\"_blank\" href=\"https://www.hongseong.go.kr/\">홍성군청</a>, <a target=\"_blank\" href=\"https://www.nts.go.kr/\">국세청</a> | 본 사이트는 VitePress를 이용해 서비스됩니다.",
    "copyright": "Copyright © 2019 린티넥스트"
  }
}

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.

린티넥스트 | 대표자: 이서준 | 사업자등록번호: 220-82-77190 | 홍성군청, 국세청 | 본 사이트는 VitePress를 이용해 서비스됩니다.