Frontmatter

任何包含YAML frontmatter块的Markdown文件都将由gray-matter处理。Frontmatter块必须位于在Markdown文件的顶部,必须是有效的YAML格式,放置在三点划线之间。例如:

---
title: Docs with VitePress
editLink: true
---

在三点划线之间,你可以设置预定义变量,甚至可以创建自定义变量。这些变量可以通过$frontmatter调用。

这是一个如何在Markdown文件使用预定义变量的例子:

---
title: Docs with VitePress
editLink: true
---

# {{ $frontmatter.title }}

Guide content

其他格式的 frontmatter

VitePress也支持JSON格式的frontmatter,需要以花括号开始和结尾。

---
{
  "title": "Blogging Like a Hacker",
  "editLink": true
}
---

预定义变量

title

  • Type: string
  • Default: h1_title || siteData.title

当前页面的标题

  • Type: array
  • Default: undefined

定义额外的需要注入的head标签。

---
head:
  - - meta
    - name: description
      content: hello
  - - meta
    - name: keywords
      content: super duper SEO
---

  • Type: boolean
  • Default: undefined

你可以通过在特定的页面上设置navbar:false来禁用导航。

  • Type: boolean|'auto'
  • Default: undefined

你可以通过在特定页面上设置 sidebar: auto来显示侧边栏,或通过sidebar: false来禁用侧边栏。

  • Type: boolean
  • Default: undefined

决定当前页面是否包含编辑链接。