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": "/logo.png",
  "search": {
    "provider": "local"
  },
  "nav": [
    {
      "text": "Home",
      "link": "/"
    },
    {
      "text": "Notion",
      "items": [
        {
          "text": "Oh My Agents Config",
          "link": "/notion/Oh My Agents Config"
        },
        {
          "text": "公共免费 Webhook 接收端工具全指南",
          "link": "/notion/公共免费 Webhook 接收端工具全指南"
        },
        {
          "text": "公共免费 Webhook 接收端盘点:从在线调试到本地开发",
          "link": "/notion/公共免费 Webhook 接收端盘点:从在线调试到本地开发"
        },
        {
          "text": "大模型的“工作记忆”:上下文窗口容量究竟意味着什么?",
          "link": "/notion/大模型的“工作记忆”:上下文窗口容量究竟意味着什么?"
        },
        {
          "text": "读懂大模型上下文容量:从4K到1M Token的AI记忆革命",
          "link": "/notion/读懂大模型上下文容量:从4K到1M Token的AI记忆革命"
        }
      ]
    },
    {
      "text": "Shopify",
      "items": [
        {
          "text": "shopify",
          "link": "/shopify/shopify"
        }
      ]
    }
  ],
  "sidebar": {
    "/notion/": [
      {
        "text": "Notion",
        "collapsed": true,
        "items": [
          {
            "text": "Oh My Agents Config",
            "link": "/notion/Oh My Agents Config"
          },
          {
            "text": "公共免费 Webhook 接收端工具全指南",
            "link": "/notion/公共免费 Webhook 接收端工具全指南"
          },
          {
            "text": "公共免费 Webhook 接收端盘点:从在线调试到本地开发",
            "link": "/notion/公共免费 Webhook 接收端盘点:从在线调试到本地开发"
          },
          {
            "text": "大模型的“工作记忆”:上下文窗口容量究竟意味着什么?",
            "link": "/notion/大模型的“工作记忆”:上下文窗口容量究竟意味着什么?"
          },
          {
            "text": "读懂大模型上下文容量:从4K到1M Token的AI记忆革命",
            "link": "/notion/读懂大模型上下文容量:从4K到1M Token的AI记忆革命"
          }
        ]
      }
    ],
    "/shopify/": [
      {
        "text": "Shopify",
        "collapsed": true,
        "items": [
          {
            "text": "shopify",
            "link": "/shopify/shopify"
          }
        ]
      }
    ]
  },
  "outline": {
    "level": [
      2,
      4
    ],
    "label": "目录"
  },
  "editLink": {
    "pattern": "https://github.com/kenis1108/kenis1108.github.io/blob/vitepress/:path",
    "text": "在GitHub编辑本页"
  },
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/kenis1108"
    }
  ]
}

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.