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

{
  "siteTitle": false,
  "search": {
    "provider": "local",
    "options": {
      "translations": {
        "button": {
          "buttonText": "Search",
          "buttonAriaLabel": "Search"
        },
        "modal": {
          "displayDetails": "Show details",
          "resetButtonTitle": "Reset",
          "backButtonTitle": "Back",
          "noResultsText": "No results for",
          "footer": {
            "selectText": "to select",
            "selectKeyAriaLabel": "to select",
            "navigateText": "to navigate",
            "navigateUpKeyAriaLabel": "up",
            "navigateDownKeyAriaLabel": "down",
            "closeText": "to close",
            "closeKeyAriaLabel": "to close"
          }
        }
      }
    }
  },
  "logo": {
    "light": "/assets/logo_dark.svg",
    "dark": "/assets/logo_light.svg"
  },
  "nav": [
    {
      "text": "Home",
      "link": "/"
    },
    {
      "text": "Documentation",
      "link": "/job-alerts/"
    },
    {
      "text": "Getting Started",
      "link": "/job-alerts/guides/getting-started/"
    },
    {
      "text": "Links",
      "items": [
        {
          "text": "Zenfl Website",
          "link": "https://zenfl.pro"
        },
        {
          "text": "Telegram Bot",
          "link": "https://t.me/ZenflUpworkBot"
        },
        {
          "text": "Support Chat",
          "link": "https://t.me/zenflbotchat"
        },
        {
          "text": "Changelog",
          "link": "https://t.me/zenflbotchangelog"
        },
        {
          "text": "Status",
          "link": "https://status.zenfl.pro"
        }
      ]
    }
  ],
  "sidebar": [
    {
      "text": "Job alerts",
      "items": [
        {
          "text": "Overview",
          "link": "/job-alerts/"
        },
        {
          "text": "Guides",
          "items": [
            {
              "text": "Getting Started",
              "link": "/job-alerts/guides/getting-started/"
            },
            {
              "text": "Usage Tips",
              "link": "/job-alerts/guides/usage-tips/"
            },
            {
              "text": "FAQ",
              "link": "/job-alerts/guides/faq/"
            },
            {
              "text": "Troubleshooting",
              "link": "/job-alerts/guides/troubleshooting/"
            }
          ]
        },
        {
          "text": "Reference",
          "link": "/job-alerts/reference/"
        },
        {
          "text": "Recipes",
          "items": [
            {
              "text": "Professional Examples",
              "link": "/job-alerts/recipes/"
            }
          ]
        },
        {
          "text": "Features",
          "link": "/job-alerts/features/",
          "items": [
            {
              "text": "AI Feed Optimization",
              "link": "/job-alerts/features/fix-feed/"
            },
            {
              "text": "Webhooks Integration",
              "link": "/job-alerts/features/webhooks/"
            }
          ]
        }
      ]
    }
  ],
  "footer": {
    "copyright": "Copyright © 2024-present <a href=\"https://zenfl.pro\" target=\"_blank\">Zenfl</a>"
  },
  "lastUpdated": {
    "text": "Updated"
  },
  "outline": {
    "label": "On this page"
  },
  "docFooter": {
    "prev": "Previous page",
    "next": "Next page"
  },
  "darkModeSwitchLabel": "Theme",
  "lightModeSwitchTitle": "Switch to light theme",
  "darkModeSwitchTitle": "Switch to dark theme",
  "sidebarMenuLabel": "Menu",
  "returnToTopLabel": "Back to top",
  "langMenuLabel": "Change language"
}

Page Data

{
  "title": "Runtime API Examples",
  "description": "",
  "frontmatter": {
    "outline": "deep",
    "head": [
      [
        "link",
        {
          "rel": "canonical",
          "href": "https://docs.zenfl.pro/api-examples/"
        }
      ],
      [
        "meta",
        {
          "property": "og:title",
          "content": "Runtime API Examples • Zenfl Docs"
        }
      ]
    ]
  },
  "headers": [],
  "relativePath": "api-examples.md",
  "filePath": "api-examples.md",
  "lastUpdated": null
}

Page Frontmatter

{
  "outline": "deep",
  "head": [
    [
      "link",
      {
        "rel": "canonical",
        "href": "https://docs.zenfl.pro/api-examples/"
      }
    ],
    [
      "meta",
      {
        "property": "og:title",
        "content": "Runtime API Examples • Zenfl Docs"
      }
    ]
  ]
}

More

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