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>
<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

{
  "siteTitle": "PixPin",
  "logo": "/logo.png",
  "logoLink": "https://pixpin.com/",
  "nav": [
    {
      "text": "Home",
      "link": "https://pixpin.com"
    },
    {
      "text": "Documentation",
      "link": "/start/what-is-pixpin"
    },
    {
      "text": "Feedback",
      "link": "/about/aboutus#contact"
    }
  ],
  "sidebar": {
    "/": [
      {
        "text": "Start",
        "items": [
          {
            "text": "What is PixPin",
            "link": "/start/what-is-pixpin"
          },
          {
            "text": "Quick Start",
            "link": "/start/quick-start"
          },
          {
            "text": "Membership Features",
            "link": "/start/pro-features"
          },
          {
            "text": "FAQ",
            "link": "/start/faq"
          }
        ]
      },
      {
        "text": "Capture",
        "collapsed": false,
        "items": [
          {
            "text": "Static Capture",
            "link": "/capture/static-capture"
          },
          {
            "text": "Scrolling Screenshot",
            "link": "/capture/long-capture"
          },
          {
            "text": "GIF Capture",
            "link": "/capture/gif-capture2"
          }
        ]
      },
      {
        "text": "Pin",
        "collapsed": false,
        "items": [
          {
            "text": "Basic Usage",
            "link": "/pin/base-use"
          },
          {
            "text": "Image",
            "link": "/pin/image"
          },
          {
            "text": "Text",
            "link": "/pin/text"
          },
          {
            "text": "File",
            "link": "/pin/file"
          },
          {
            "text": "Color",
            "link": "/pin/color"
          },
          {
            "text": "LaTeX",
            "link": "/pin/latex"
          },
          {
            "text": "Pin Group",
            "link": "/pin/pin-group"
          }
        ]
      },
      {
        "text": "Annotate",
        "collapsed": true,
        "items": [
          {
            "text": "Basic Usage",
            "link": "/mark/base-use"
          },
          {
            "text": "Rectangle/Ellipse",
            "link": "/mark/geo"
          },
          {
            "text": "Line/Polyline",
            "link": "/mark/line"
          },
          {
            "text": "Arrow",
            "link": "/mark/arrow"
          },
          {
            "text": "Serial Number",
            "link": "/mark/serial"
          },
          {
            "text": "Pencil",
            "link": "/mark/pencil"
          },
          {
            "text": "Highlighter",
            "link": "/mark/mark-pencil"
          },
          {
            "text": "Mosaic/Blur/Smart Eraser",
            "link": "/mark/mosaic"
          },
          {
            "text": "Text",
            "link": "/mark/text"
          },
          {
            "text": "Eraser",
            "link": "/mark/erase"
          },
          {
            "text": "Spotlight",
            "link": "/mark/highlight"
          },
          {
            "text": "Watermark",
            "link": "/mark/watermark"
          },
          {
            "text": "Magnifier",
            "link": "/mark/magnifier"
          }
        ]
      },
      {
        "text": "Config",
        "collapsed": true,
        "items": [
          {
            "text": "System",
            "link": "/configuration/system"
          },
          {
            "text": "Appearance",
            "link": "/configuration/appearance"
          },
          {
            "text": "Screenshot",
            "link": "/configuration/screenshot"
          },
          {
            "text": "Pin",
            "link": "/configuration/pin"
          },
          {
            "text": "Save",
            "link": "/configuration/save"
          },
          {
            "text": "Annotate",
            "link": "/configuration/mark"
          },
          {
            "text": "Shortcut/Action",
            "link": "/configuration/actions"
          },
          {
            "text": "Built-in Shortcut",
            "link": "/configuration/built-in-shortcut"
          },
          {
            "text": "Mouse",
            "link": "/configuration/mouse"
          },
          {
            "text": "Global Mouse",
            "link": "/configuration/global-mouse"
          },
          {
            "text": "Customized Toolbar",
            "link": "/configuration/customized-toolbar"
          },
          {
            "text": "Translate Settings",
            "link": "/configuration/translate-key"
          },
          {
            "text": "Script",
            "link": "/configuration/script"
          }
        ]
      },
      {
        "text": "Other Features",
        "collapsed": true,
        "items": [
          {
            "text": "Formula Recognition",
            "link": "/other/formula"
          },
          {
            "text": "Translate",
            "link": "/other/translate"
          }
        ]
      },
      {
        "text": "Changelog",
        "collapsed": true,
        "items": [
          {
            "text": "3.1.4",
            "link": "/official-log/3-1-4-0"
          },
          {
            "text": "3.0.8",
            "link": "/official-log/3-0-8-0"
          },
          {
            "text": "2.4.9",
            "link": "/official-log/2-4-9-6"
          },
          {
            "text": "2.3.8",
            "link": "/official-log/2-3-8-0"
          }
        ]
      },
      {
        "text": "Beta Changelog",
        "collapsed": true,
        "items": [
          {
            "text": "Beta Instructions",
            "link": "/change-log/instructions"
          },
          {
            "text": "3.2.2",
            "link": "/change-log/3-2-2-3"
          },
          {
            "text": "3.2.1",
            "link": "/change-log/3-2-1-3"
          },
          {
            "text": "3.1.4",
            "link": "/change-log/3-1-4-0"
          },
          {
            "text": "3.1.3",
            "link": "/change-log/3-1-3-1"
          },
          {
            "text": "2.4.9",
            "link": "/change-log/2-4-9-6"
          },
          {
            "text": "2.3.7",
            "link": "/change-log/2-3-7-0"
          },
          {
            "text": "2.3.3",
            "link": "/change-log/2-3-3-0"
          }
        ]
      },
      {
        "text": "About Us",
        "link": "/about/aboutus"
      }
    ]
  },
  "socialLinks": []
}

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.