Skip to content

Resources

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": {
    "copyright": "Copyright © 2024 CloseX"
  },
  "nav": [
    {
      "text": "Guildlines",
      "link": "/guidelines"
    },
    {
      "text": "Resources",
      "link": "/resources"
    },
    {
      "text": "More",
      "items": [
        {
          "text": "Privacy Policy",
          "link": "/privacy"
        },
        {
          "text": "Release Notes",
          "link": "/release-note"
        },
        {
          "text": "Blog",
          "link": "https://blog.closex.org"
        },
        {
          "text": "CloseX",
          "link": "https://closex.org"
        },
        {
          "text": "Contact Us",
          "link": "mailto:fusion-x-one@outlook.com"
        }
      ]
    }
  ],
  "search": {
    "provider": "local",
    "options": {
      "locales": {
        "zh": {
          "translations": {
            "button": {
              "buttonText": "搜索文档",
              "buttonAriaLabel": "搜索文档"
            },
            "modal": {
              "noResultsText": "无法找到相关结果",
              "resetButtonTitle": "清除查询条件",
              "footer": {
                "selectText": "选择",
                "navigateText": "切换",
                "closeText": "关闭"
              }
            }
          }
        },
        "ja": {
          "translations": {
            "button": {
              "buttonText": "文書の検索",
              "buttonAriaLabel": "文書の検索"
            },
            "modal": {
              "noResultsText": "関連する結果が見つかりませんでした",
              "resetButtonTitle": "クエリ条件をクリアする",
              "footer": {
                "selectText": "選ぶ",
                "navigateText": "スイッチ",
                "closeText": "閉鎖"
              }
            }
          }
        }
      }
    }
  },
  "logo": "/img/logo.webp",
  "sidebar": [
    {
      "text": "Platforms",
      "collapsed": true,
      "items": [
        {
          "text": "Designing for Desktop",
          "link": "/guidelines/platforms/designing-for-desktop"
        },
        {
          "text": "Designing for Mobile",
          "link": "/guidelines/platforms/designing-for-mobile"
        },
        {
          "text": "Designing for Tablet",
          "link": "/guidelines/platforms/designing-for-tablet"
        },
        {
          "text": "Designing for Safari",
          "link": "/guidelines/platforms/designing-for-safari"
        },
        {
          "text": "Designing for Chrome",
          "link": "/guidelines/platforms/designing-for-chrome"
        },
        {
          "text": "Designing for LLMs",
          "link": "/guidelines/platforms/designing-for-llms"
        }
      ]
    },
    {
      "text": "Foundations",
      "collapsed": true,
      "items": [
        {
          "text": "Branding",
          "link": "/guidelines/foundations/branding"
        },
        {
          "text": "Layout",
          "link": "/guidelines/foundations/layout"
        },
        {
          "text": "Typography",
          "link": "/guidelines/foundations/typography"
        },
        {
          "text": "Image",
          "link": "/guidelines/foundations/image"
        },
        {
          "text": "Color",
          "link": "/guidelines/foundations/color"
        },
        {
          "text": "Dark Mode",
          "link": "/guidelines/foundations/dark-mode"
        }
      ]
    },
    {
      "text": "Components",
      "collapsed": true,
      "items": [
        {
          "text": "Content",
          "link": "/guidelines/components/content"
        },
        {
          "text": "Charting Data",
          "link": "/guidelines/components/charting-data"
        },
        {
          "text": "Loading",
          "link": "/guidelines/components/loading"
        },
        {
          "text": "Input",
          "link": "/guidelines/components/input"
        },
        {
          "text": "Search",
          "link": "/guidelines/components/search"
        },
        {
          "text": "Menu",
          "link": "/guidelines/components/menu"
        }
      ]
    },
    {
      "text": "Writing",
      "collapsed": true,
      "items": [
        {
          "text": "Markdown",
          "link": "/guidelines/writing/markdown"
        },
        {
          "text": "Frontmatter",
          "link": "/guidelines/writing/frontmatter"
        },
        {
          "text": "Using Code in Markdown",
          "link": "/guidelines/writing/using-code-in-markdown"
        },
        {
          "text": "Asset Handling",
          "link": "/guidelines/writing/asset-handling"
        },
        {
          "text": "Voice",
          "link": "/guidelines/writing/voice"
        },
        {
          "text": "Internationalization",
          "link": "/guidelines/writing/internationalization"
        }
      ]
    },
    {
      "text": "Performance",
      "collapsed": true,
      "items": [
        {
          "text": "Deploy",
          "link": "/guidelines/performance/deploy"
        },
        {
          "text": "SpeedTest",
          "link": "/guidelines/performance/speedtest"
        },
        {
          "text": "SEO",
          "link": "/guidelines/performance/seo"
        },
        {
          "text": "User Experience",
          "link": "/guidelines/performance/user-experience"
        }
      ]
    },
    {
      "text": "Customization",
      "collapsed": true,
      "items": [
        {
          "text": "Profile",
          "link": "/guidelines/customization/profile"
        },
        {
          "text": "CSS",
          "link": "/guidelines/customization/css"
        },
        {
          "text": "Javascript",
          "link": "/guidelines/customization/javascript"
        },
        {
          "text": "Friendlink",
          "link": "/guidelines/customization/friendlink"
        },
        {
          "text": "Footer",
          "link": "/guidelines/customization/footer"
        },
        {
          "text": "Navigation Bar",
          "link": "/guidelines/customization/navigation-bar"
        }
      ]
    }
  ]
}

Page Data

{
  "title": "Resources",
  "description": "",
  "frontmatter": {
    "outline": false,
    "sidebar": false,
    "aside": false
  },
  "headers": [],
  "relativePath": "resources.md",
  "filePath": "resources.md"
}

Page Frontmatter

{
  "outline": false,
  "sidebar": false,
  "aside": false
}

More

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