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": {
    "src": "/img/logo/logo.svg",
    "alt": "Logo VSC"
  },
  "siteTitle": "VSC Guide",
  "nav": [
    {
      "text": "Beranda",
      "link": "/"
    },
    {
      "text": "Panduan",
      "link": "/panduan/mengenal-vsc-erp"
    },
    {
      "text": "Modul",
      "link": "/modul/dashboard"
    },
    {
      "text": "Data Referensi",
      "link": "/referensi-data/overview"
    }
  ],
  "sidebar": [
    {
      "text": "Panduan Awal",
      "items": [
        {
          "text": "Perkenalan",
          "link": "/panduan/mengenal-vsc-erp"
        },
        {
          "text": "Memulai",
          "link": "/panduan/mulai-cepat"
        }
      ]
    },
    {
      "text": "Area Utama",
      "items": [
        {
          "text": "Dashboard",
          "link": "/modul/dashboard"
        },
        {
          "text": "Approval",
          "link": "/modul/approval"
        },
        {
          "text": "Sales",
          "link": "/modul/sales"
        },
        {
          "text": "Purchasing",
          "link": "/modul/purchasing"
        },
        {
          "text": "Inventory",
          "link": "/modul/inventory"
        },
        {
          "text": "Production",
          "link": "/modul/production"
        }
      ]
    },
    {
      "text": "Keuangan",
      "items": [
        {
          "text": "Account Payable",
          "link": "/modul/account-payable"
        },
        {
          "text": "Account Receivable",
          "link": "/modul/account-receivable"
        },
        {
          "text": "Accounting",
          "link": "/modul/accounting"
        }
      ]
    },
    {
      "text": "Laporan & Tim",
      "items": [
        {
          "text": "Human Resource",
          "link": "/modul/human-resource"
        },
        {
          "text": "Report",
          "link": "/modul/report"
        }
      ]
    },
    {
      "text": "Administrasi Sistem",
      "items": [
        {
          "text": "IAM",
          "link": "/admin/iam"
        },
        {
          "text": "Settings",
          "link": "/admin/settings"
        },
        {
          "text": "Utility",
          "link": "/admin/utility"
        },
        {
          "text": "Activity",
          "link": "/admin/activity"
        }
      ]
    },
    {
      "text": "Pendukung Transaksi",
      "items": [
        {
          "text": "Data Referensi",
          "link": "/referensi-data/overview"
        }
      ]
    }
  ],
  "search": {
    "provider": "local"
  },
  "outline": {
    "label": "Di halaman ini",
    "level": [
      2,
      3
    ]
  },
  "docFooter": {
    "prev": "Sebelumnya",
    "next": "Berikutnya"
  },
  "returnToTopLabel": "Kembali ke atas",
  "sidebarMenuLabel": "Menu",
  "darkModeSwitchLabel": "Tema",
  "lightModeSwitchTitle": "Beralih ke tema terang",
  "darkModeSwitchTitle": "Beralih ke tema gelap"
}

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.