Skip to content

Contoh API Runtime

Halaman ini menunjukkan penggunaan beberapa API runtime yang disediakan oleh VitePress.

API useData() utama dapat digunakan untuk mengakses data situs, tema, dan halaman untuk halaman saat ini. Ia berfungsi di file .md dan .vue:

md
<script setup>
import { useData } from 'vitepress';

const { theme, page, frontmatter } = useData();
</script>

## Hasil

### Data Tema
<pre>{{ theme }}</pre>

### Data Halaman
<pre>{{ page }}</pre>

### Halaman Frontmatter
<pre>{{ frontmatter }}</pre>

Hasil

Data Tema

{
  "editLink": {
    "text": "Sunting halaman ini",
    "pattern": "https://github.com/VenityNetwork/support-page/edit/master/docs/:path"
  },
  "search": {
    "provider": "local"
  },
  "docFooter": {
    "prev": "Sebelumnya",
    "next": "Selanjutnya"
  },
  "outline": {
    "label": "Halaman ini"
  },
  "lastUpdated": {
    "text": "Diperbarui",
    "formatOptions": {
      "dateStyle": "short",
      "timeStyle": "medium"
    }
  },
  "langMenuLabel": "Ganti bahasa",
  "returnToTopLabel": "Kembali ke atas",
  "darkModeSwitchLabel": "Tema",
  "lightModeSwitchTitle": "Ubah ke mode terang",
  "darkModeSwitchTitle": "Ubah ke mode gelap",
  "sidebar": [
    {
      "text": "Tutorial",
      "items": [
        {
          "text": "Vote Server",
          "link": "/id/voting-for-the-server"
        }
      ]
    },
    {
      "text": "Informasi in-game",
      "items": [
        {
          "text": "Sistem Guild",
          "link": "/id/guilds-system"
        }
      ]
    },
    {
      "text": "Kebijakan",
      "items": [
        {
          "text": "Ketentuan Layanan",
          "link": "/id/terms-of-service"
        },
        {
          "text": "Kebijakan Privasi",
          "link": "/id/privacy-policy"
        }
      ]
    },
    {
      "text": "Rekrutmen",
      "items": [
        {
          "text": "Pekerjaan",
          "link": "/id/jobs"
        }
      ]
    },
    {
      "text": "Untuk Penulis",
      "items": [
        {
          "text": "Contoh Markdown",
          "link": "/id/markdown-examples"
        },
        {
          "text": "Contoh API Runtime",
          "link": "/id/api-examples"
        }
      ]
    }
  ],
  "nav": [
    {
      "text": "Beranda",
      "link": "https://www.venitymc.com"
    },
    {
      "text": "Discord",
      "link": "https://discord.gg/HTPg36hRU6"
    },
    {
      "text": "Store",
      "link": "https://store.venitymc.com"
    }
  ]
}

Data Halaman

{
  "title": "Contoh API Runtime",
  "description": "",
  "frontmatter": {
    "outline": "deep"
  },
  "headers": [],
  "relativePath": "id/api-examples.md",
  "filePath": "id/api-examples.md"
}

Halaman Frontmatter

{
  "outline": "deep"
}

Lagi

Lihat dokumentasi untuk daftar lengkap API runtime.