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 支持基于页面的配置。在每个 markdown 文件中,可以使用 frontmatter 配置来覆盖站点级别或主题级别的配置选项。此外,还有一些配置选项只能在 frontmatter 中定义。
示例用法:
---
title: Docs with VitePress
editLink: true
---可以通过 Vue 表达式中的 $frontmatter 全局变量访问 frontmatter 数据:
{{ $frontmatter.title }}string页面的标题。它与 config.title 相同,并且覆盖站点级配置。
---
title: VitePress
---string | boolean标题的后缀。它与 config.titleTemplate 相同,它会覆盖站点级别的配置。
---
title: VitePress
titleTemplate: Vite & Vue powered static site generator
---string页面的描述。它与 config.description 相同,它会覆盖站点级别的配置。
---
description: VitePress
---HeadConfig[]指定要为当前页面注入的额外 head 标签。将附加在站点级配置注入的头部标签之后。
---
head:
- - meta
- name: description
content: hello
- - meta
- name: keywords
content: super duper SEO
---type HeadConfig =
| [string, Record<string, string>]
| [string, Record<string, string>, string]以下 frontmatter 选项仅在使用默认主题时适用。
doc | home | pagedoc指定页面的布局。
doc——它将默认文档样式应用于 markdown 内容。home——“主页”的特殊布局。可以添加额外的选项,例如 hero 和 features,以快速创建漂亮的落地页。page——表现类似于 doc,但它不对内容应用任何样式。当想创建一个完全自定义的页面时很有用。---
layout: doc
---定义当layout 设置为 home 时要在 features 部分中显示的项目。更多详细信息:默认主题:主页。
booleantrue是否显示导航栏。
---
navbar: false
---booleantrue是否显示 侧边栏.
---
sidebar: false
---boolean | 'left'true定义侧边栏组件在 doc 布局中的位置。
将此值设置为 false 可禁用侧边栏容器。
将此值设置为 true 会将侧边栏渲染到右侧。
将此值设置为 left 会将侧边栏渲染到左侧。
---
aside: false
---number | [number, number] | 'deep' | false2大纲中显示的标题级别。它与 config.themeConfig.outline.level 相同,它会覆盖站点级的配置。
boolean | Datetrue是否在当前页面的页脚中显示最后更新时间的文本。如果指定了日期时间,则会显示该日期时间而不是上次 git 修改的时间戳。
---
lastUpdated: false
---booleantrue是否在当前页的页脚显示编辑链接。
---
editLink: false
---booleantrue是否显示页脚。
---
footer: false
---string将额外的类名称添加到特定页面。
---
pageClass: custom-page-class
---然后可以在 .vitepress/theme/custom.css 文件中自定义该特定页面的样式:
.custom-page-class {
/* 特定页面的样式 */
}