Skip to content

使用 vitepress 生成网站

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:

Results

Theme Data

{
  "logo": "/huaji2.png",
  "siteTitle": "Hello World",
  "nav": [
    {
      "text": "主页",
      "link": "/"
    },
    {
      "text": "文章",
      "link": "/posts/"
    },
    {
      "text": "周报",
      "link": "/weekly/"
    }
  ],
  "sidebar": [
    {
      "collapsed": true,
      "text": "文章",
      "items": [
        {
          "text": "软件推荐",
          "link": "/posts/软件推荐"
        },
        {
          "text": "成长",
          "link": "/posts/成长"
        },
        {
          "text": "vitepress",
          "link": "/posts/vitepress"
        },
        {
          "text": "Markdown Extensions",
          "link": "/posts/Markdown Extensions"
        }
      ]
    },
    {
      "collapsed": true,
      "text": "周报",
      "items": [
        {
          "text": "2024-01-15",
          "link": "/weekly/2024-01-15"
        },
        {
          "text": "2023-12-25",
          "link": "/weekly/2023-12-25"
        },
        {
          "text": "2023-12-07",
          "link": "/weekly/2023-12-07"
        },
        {
          "text": "2023-11-10",
          "link": "/weekly/2023-11-10"
        },
        {
          "text": "2023-10-27",
          "link": "/weekly/2023-10-27"
        },
        {
          "text": "2023-10-20",
          "link": "/weekly/2023-10-20"
        }
      ]
    }
  ],
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/qianyanz"
    }
  ],
  "footer": {
    "message": "",
    "copyright": ""
  }
}

Page Data

{
  "title": "使用 vitepress 生成网站",
  "description": "",
  "frontmatter": {
    "outline": "deep"
  },
  "headers": [],
  "relativePath": "posts/vitepress.md",
  "filePath": "posts/vitepress.md"
}

Page Frontmatter

{
  "outline": "deep"
}

More

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