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": "/logo-icon.png",
  "nav": [
    {
      "text": "Início",
      "link": "/"
    },
    {
      "text": "Serviços",
      "link": "/servicos"
    },
    {
      "text": "Segurança",
      "link": "/seguranca"
    },
    {
      "text": "Monitoramento",
      "link": "/monitoramento"
    }
  ],
  "sidebar": [
    {
      "text": "SSSI - Processos",
      "items": [
        {
          "text": "Gestão de Mudanças",
          "link": "/processos/gestao-mudancas"
        }
      ]
    },
    {
      "text": "SSSI - Serviços e Identidade",
      "items": [
        {
          "text": "Active Directory",
          "link": "/servicos/active-directory"
        },
        {
          "text": "Keycloak",
          "link": "/servicos/keycloak"
        },
        {
          "text": "Gestão de Identidades",
          "link": "/servicos/gestao-identidades"
        }
      ]
    },
    {
      "text": "SSSI - Plataformas e Ambientes",
      "items": [
        {
          "text": "Kubernetes (k8s)",
          "link": "/servicos/kubernetes"
        },
        {
          "text": "Máquinas Virtuais",
          "link": "/servicos/maquinas-virtuais"
        },
        {
          "text": "Redes e VLANs",
          "link": "/servicos/vlans"
        },
        {
          "text": "Microsoft Exchange",
          "link": "/servicos/exchange"
        },
        {
          "text": "Controle de Versão (GitLab)",
          "link": "/servicos/gitlab"
        },
        {
          "text": "Proxy Reverso Nginx",
          "link": "/servicos/nginx"
        },
        {
          "text": "MariaDB Galera Cluster",
          "link": "/servicos/mariadb"
        },
        {
          "text": "Visão Geral do File Server",
          "link": "/servicos/visao-geral-file-server"
        },
        {
          "text": "File Server (DFS)",
          "link": "/servicos/dfs"
        },
        {
          "text": "Estrutura do File Server",
          "link": "/servicos/file-server"
        },
        {
          "text": "GPO - Mapeamento de Unidades",
          "link": "/servicos/gpo-file-server"
        },
        {
          "text": "Print Server",
          "link": "/servicos/print-server"
        },
        {
          "text": "Serviço Voluntário Gratificado (SVG)",
          "link": "/servicos/svg"
        }
      ]
    },
    {
      "text": "SSSI - Segurança e Monitoramento",
      "items": [
        {
          "text": "Firewall Checkpoint",
          "link": "/seguranca/checkpoint"
        },
        {
          "text": "Zabbix",
          "link": "/monitoramento/zabbix"
        },
        {
          "text": "Wazuh",
          "link": "/monitoramento/wazuh"
        }
      ]
    },
    {
      "text": "SSSI - Documentação Linux",
      "items": [
        {
          "text": "Configuração Inicial",
          "link": "/linux/ServidoresUbuntu"
        },
        {
          "text": "Template Padrão",
          "link": "/linux/TemplateServidoresUbuntu"
        },
        {
          "text": "Template com Docker",
          "link": "/linux/TemplateServidoresUbuntuComDocker"
        },
        {
          "text": "Instalação do Docker",
          "link": "/linux/docker"
        }
      ]
    },
    {
      "text": "Examples",
      "items": [
        {
          "text": "Markdown Examples",
          "link": "/markdown-examples"
        },
        {
          "text": "Runtime API Examples",
          "link": "/api-examples"
        }
      ]
    }
  ],
  "search": {
    "provider": "local",
    "options": {
      "translations": {
        "button": {
          "buttonText": "Buscar",
          "buttonAriaLabel": "Buscar documentos"
        },
        "modal": {
          "noResultsText": "Nenhum resultado encontrado",
          "resetButtonTitle": "Limpar busca",
          "footer": {
            "selectText": "para selecionar",
            "navigateText": "para navegar",
            "closeText": "para fechar"
          }
        }
      }
    }
  },
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/vuejs/vitepress"
    }
  ]
}

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.