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 โ€‹

{
  "search": {
    "provider": "local",
    "options": {
      "detailedView": true,
      "miniSearch": {
        "searchOptions": {
          "fuzzy": 0.2,
          "prefix": true
        }
      },
      "translations": {
        "button": {
          "buttonText": "Search Documentation",
          "buttonAriaLabel": "Search Documentation"
        },
        "modal": {
          "displayDetails": "Display detailed list",
          "noResultsText": "No results for",
          "resetButtonTitle": "Reset search",
          "footer": {
            "selectText": "to select",
            "navigateText": "to navigate",
            "closeText": "to close"
          }
        }
      }
    }
  },
  "logo": {
    "src": "/asset/inaidle.webp"
  },
  "nav": [
    {
      "text": "Home",
      "link": "/"
    }
  ],
  "sidebar": [
    {
      "text": "",
      "items": [
        {
          "text": "โšก Quick Start",
          "link": "/index"
        },
        {
          "text": "๐Ÿ†โ€‹ Sport",
          "link": "/sub/z3.sports"
        },
        {
          "text": "๐Ÿชš SuperCut",
          "link": "/sub/z1.supercut"
        },
        {
          "text": "๐Ÿ”ฎ Megathread",
          "link": "/sub/z2.megathread"
        },
        {
          "text": "๐Ÿ’ป PC Setup",
          "link": "/sub/z5.PC-Setup"
        },
        {
          "text": "๐Ÿ”— KH ISP",
          "link": "/sub/z7.isp-kh.html"
        },
        {
          "text": "๐Ÿงบ Shops",
          "link": "/sub/z4.online-shops"
        },
        {
          "text": "๐Ÿงช Temp",
          "link": "/sub/z10.temp"
        }
      ]
    },
    {
      "text": "๐Ÿ’ฒ MMO",
      "collapsed": false,
      "items": [
        {
          "text": "Quickstart",
          "link": "/mmo/a1.mmo-qs"
        },
        {
          "text": "How to",
          "link": "/mmo/a2.howto"
        },
        {
          "text": "Monetize",
          "link": "/mmo/a3.monetize"
        }
      ]
    },
    {
      "text": "๐Ÿ› ๏ธ Technical",
      "collapsed": true,
      "items": [
        {
          "text": "IP",
          "link": "/mmo/ip"
        },
        {
          "text": "IP Archive",
          "link": "/mmo/ip-old"
        },
        {
          "text": "Tools & Software",
          "link": "/mmo/tools"
        },
        {
          "text": "Devices",
          "link": "/mmo/devices"
        },
        {
          "text": "Youtube",
          "link": "/mmo/youtube"
        },
        {
          "text": "Facebook",
          "link": "/mmo/facebook"
        }
      ]
    },
    {
      "text": "๐Ÿค– AI",
      "collapsed": true,
      "items": [
        {
          "text": "AI",
          "link": "/mmo/ai"
        },
        {
          "text": "Media",
          "link": "/mmo/media-editing"
        }
      ]
    },
    {
      "text": "๐Ÿ“‚ ID Folder",
      "collapsed": true,
      "items": [
        {
          "text": "Mail & SMS",
          "link": "/mmo/mail-sms"
        },
        {
          "text": "ID",
          "link": "/mmo/idfolder"
        }
      ]
    },
    {
      "text": "๐Ÿงบ Farmer Market",
      "collapsed": true,
      "items": [
        {
          "text": "Shoppy",
          "link": "/mmo/shoppy"
        },
        {
          "text": "Forum & Community",
          "link": "/mmo/forum"
        }
      ]
    },
    {
      "text": "๐Ÿ“ฆ Collapsed",
      "collapsed": true,
      "items": [
        {
          "text": "๐Ÿ“ markdown-examples",
          "link": "/markdown-examples"
        },
        {
          "text": "๐Ÿ”Œ api-examples",
          "link": "/api-examples"
        },
        {
          "text": "โ” Guide",
          "link": "/sub/z6.guides"
        }
      ]
    }
  ]
}

Page Data โ€‹

{
  "title": "Runtime API Examples",
  "description": "",
  "frontmatter": {
    "outline": "deep"
  },
  "headers": [],
  "relativePath": "api-examples.md",
  "filePath": "api-examples.md",
  "lastUpdated": 1772039502000
}

Page Frontmatter โ€‹

{
  "outline": "deep"
}

More โ€‹

Check out the documentation for the full list of runtime APIs.