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

{
  "logo": {
    "light": "/logo-text-light.svg",
    "dark": "/logo-text-dark.svg"
  },
  "siteTitle": false,
  "lightModeSwitchTitle": "切换到浅色模式",
  "darkModeSwitchTitle": "切换到深色模式",
  "darkModeSwitchLabel": "主题模式",
  "nav": [
    {
      "text": "首页",
      "link": "/"
    },
    {
      "text": "PUMP狙击",
      "link": "/pump-sniper/"
    },
    {
      "text": "PUMP迁移买入",
      "link": "/pump-migrate/"
    },
    {
      "text": "Moonit狙击",
      "link": "/moonit-sniper/"
    },
    {
      "text": "新币监控",
      "link": "/monitor-new-coin/"
    }
  ],
  "sidebar": {
    "/moonit-sniper/": [
      {
        "text": "Moonit代币狙击",
        "items": [
          {
            "text": "Index",
            "link": "/config/"
          },
          {
            "text": "Three",
            "link": "/config/three"
          },
          {
            "text": "Four",
            "link": "/config/four"
          }
        ]
      }
    ],
    "/pump-migrate/": [
      {
        "text": "PUMP代币迁移",
        "items": [
          {
            "text": "Index",
            "link": "/config/"
          },
          {
            "text": "Three",
            "link": "/config/three"
          },
          {
            "text": "Four",
            "link": "/config/four"
          }
        ]
      }
    ],
    "/pump-sniper/": [
      {
        "text": "PUMP代币狙击",
        "items": [
          {
            "text": "Index",
            "link": "/config/"
          },
          {
            "text": "Three",
            "link": "/config/three"
          },
          {
            "text": "Four",
            "link": "/config/four"
          }
        ]
      }
    ]
  },
  "socialLinks": [
    {
      "icon": "x",
      "link": "https://x.com/dsc_web"
    },
    {
      "icon": "telegram",
      "link": "https://t.me/web_dsc"
    }
  ],
  "footer": {
    "message": "加油!陌生人",
    "copyright": "<span class=\"bg-linear-to-r from-blue-400 via-purple-500 to-pink-500 bg-clip-text text-transparent\">© 2025 www.dashachun.com</span>"
  },
  "notFound": {
    "title": "找不到页面",
    "quote": "页面不见了,也许它去找寻新的冒险了!",
    "linkLabel": "返回首页重新探索",
    "linkText": "返回首页",
    "code": "404"
  }
}

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.

加油!陌生人