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

{
  "footer": {
    "message": "<span>Connect with me via <a href=\"mailto:rowan.christmas@mentorcg.com\">email</a> or <a href=\"https://calendly.com/rowan-christmas-mentorcg\" target=\"_\">schedule a time</a> on my calendar.</span>",
    "copyright": "Copyright © 2024-present Rowan Christmas"
  },
  "nav": [
    {
      "text": "Product Research",
      "link": "/ProductResearch/product-research.md"
    },
    {
      "text": "Design & Development",
      "link": "/DesignAndDev/design-and-dev.md"
    },
    {
      "text": "Financial Modeling",
      "link": "/FinancialModeling/financial-modeling.md"
    },
    {
      "text": "AI & Big Enterprise",
      "link": "/Enterprise/enterprise.md"
    }
  ],
  "sidebar": [
    {
      "text": "Product Research",
      "collapsed": false,
      "items": [
        {
          "text": "Overview",
          "link": "/ProductResearch/product-research.md"
        },
        {
          "text": "Conjoint Analysis",
          "link": "/ProductResearch/conjoint-analysis.md"
        },
        {
          "text": "Relative Weights",
          "link": "/ProductResearch/relative-weights.md"
        },
        {
          "text": "MaxDiff",
          "link": "/ProductResearch/max-diff.md"
        }
      ]
    },
    {
      "text": "Design & Development",
      "collapsed": false,
      "items": [
        {
          "text": "Overview",
          "link": "/DesignAndDev/design-and-dev.md"
        },
        {
          "text": "Why JavaScript?",
          "link": "/DesignAndDev/why-javascript.md"
        },
        {
          "text": "Developer Experience",
          "link": "/DesignAndDev/developer-experience.md"
        }
      ]
    },
    {
      "text": "Financial Modeling",
      "collapsed": false,
      "items": [
        {
          "text": "Overview",
          "link": "/Financial/financial-modeling.md"
        },
        {
          "text": "Understand the \"Why?\"",
          "link": "/FinancialModeling/understand-why.md"
        },
        {
          "text": "Design your spreadsheet",
          "link": "/FinancialModeling/design-your-spreadsheet.md"
        }
      ]
    },
    {
      "text": "AI & Big Enterprise",
      "collapsed": false,
      "items": [
        {
          "text": "Overview",
          "link": "/Enterprise/enterprise.md"
        },
        {
          "text": "What is Salesforce",
          "link": "/Enterprise/what-is-salesforce.md"
        }
      ]
    }
  ],
  "socialLinks": [
    {
      "icon": "linkedin",
      "link": "https://www.linkedin.com/in/rowanchristmas/"
    }
  ]
}

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.

Connect with me via email or schedule a time on my calendar.