import{_ as n,c as h,ag as t,j as a,a as i,G as l,B as p,o as d}from"./chunks/framework.C1C4sYC0.js";const F=JSON.parse('{"title":"frontmatter 配置","description":"","frontmatter":{"outline":"deep"},"headers":[],"relativePath":"zh/reference/frontmatter-config.md","filePath":"zh/reference/frontmatter-config.md","lastUpdated":1719410492000}'),k={name:"zh/reference/frontmatter-config.md"},r={id:"hero",tabindex:"-1"},o={id:"features",tabindex:"-1"};function c(g,s,u,E,y,m){const e=p("Badge");return d(),h("div",null,[s[6]||(s[6]=t(`

frontmatter 配置

frontmatter 支持基于页面的配置。在每个 markdown 文件中,可以使用 frontmatter 配置来覆盖站点级别或主题级别的配置选项。此外,还有一些配置选项只能在 frontmatter 中定义。

示例用法:

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

可以通过 Vue 表达式中的 $frontmatter 全局变量访问 frontmatter 数据:

md
{{ $frontmatter.title }}

title

页面的标题。它与 config.title 相同,并且覆盖站点级配置。

yaml
---
title: VitePress
---

titleTemplate

标题的后缀。它与 config.titleTemplate 相同,它会覆盖站点级别的配置。

yaml
---
title: VitePress
titleTemplate: Vite & Vue powered static site generator
---

description

页面的描述。它与 config.description 相同,它会覆盖站点级别的配置。

yaml
---
description: VitePress
---

指定要为当前页面注入的额外 head 标签。将附加在站点级配置注入的头部标签之后。

yaml
---
head:
  - - meta
    - name: description
      content: hello
  - - meta
    - name: keywords
      content: super duper SEO
---
ts
type HeadConfig =
  | [string, Record<string, string>]
  | [string, Record<string, string>, string]

仅默认主题

以下 frontmatter 选项仅在使用默认主题时适用。

layout

指定页面的布局。

yaml
---
layout: doc
---
`,30)),a("h3",r,[s[0]||(s[0]=i("hero ")),l(e,{type:"info",text:"home page only"}),s[1]||(s[1]=i()),s[2]||(s[2]=a("a",{class:"header-anchor",href:"#hero","aria-label":'Permalink to "hero "'},"​",-1))]),s[7]||(s[7]=a("p",null,[i("当 "),a("code",null,"layout"),i(" 设置为 "),a("code",null,"home"),i(" 时,定义主页 hero 部分的内容。更多详细信息:"),a("a",{href:"./default-theme-home-page"},"默认主题:主页"),i("。")],-1)),a("h3",o,[s[3]||(s[3]=i("features ")),l(e,{type:"info",text:"home page only"}),s[4]||(s[4]=i()),s[5]||(s[5]=a("a",{class:"header-anchor",href:"#features","aria-label":'Permalink to "features "'},"​",-1))]),s[8]||(s[8]=t(`

定义当layout 设置为 home 时要在 features 部分中显示的项目。更多详细信息:默认主题:主页

是否显示导航栏

yaml
---
navbar: false
---

是否显示 侧边栏.

yaml
---
sidebar: false
---

aside

定义侧边栏组件在 doc 布局中的位置。

将此值设置为 false 可禁用侧边栏容器。
将此值设置为 true 会将侧边栏渲染到右侧。
将此值设置为 left 会将侧边栏渲染到左侧。

yaml
---
aside: false
---

outline

大纲中显示的标题级别。它与 config.themeConfig.outline.level 相同,它会覆盖站点级的配置。

lastUpdated

是否在当前页面的页脚中显示最后更新时间的文本。如果指定了日期时间,则会显示该日期时间而不是上次 git 修改的时间戳。

yaml
---
lastUpdated: false
---

是否在当前页的页脚显示编辑链接

yaml
---
editLink: false
---

是否显示页脚

yaml
---
footer: false
---

pageClass

将额外的类名称添加到特定页面。

yaml
---
pageClass: custom-page-class
---

然后可以在 .vitepress/theme/custom.css 文件中自定义该特定页面的样式:

css
.custom-page-class {
  /* 特定页面的样式 */
}
`,35))])}const f=n(k,[["render",c]]);export{F as __pageData,f as default};