mirror of https://github.com/vuejs/vitepress
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
193 lines
3.7 KiB
193 lines
3.7 KiB
2 years ago
|
# Frontmatter Config
|
||
3 years ago
|
|
||
2 years ago
|
Frontmatter enables page based configuration. In every markdown file, you can use frontmatter config to override app-level or theme config options. Also, there are config options which you can only define in frontmatter.
|
||
3 years ago
|
|
||
|
```yaml
|
||
|
---
|
||
|
title: Docs with VitePress
|
||
|
editLink: true
|
||
|
---
|
||
|
```
|
||
|
|
||
2 years ago
|
You can access frontmatter by `$frontmatter` helper inside any markdown file.
|
||
3 years ago
|
|
||
|
```md
|
||
|
{{ $frontmatter.title }}
|
||
|
```
|
||
|
|
||
|
## title
|
||
|
|
||
|
- Type: `string`
|
||
|
|
||
2 years ago
|
Title for the page. It's same as [config.title](../config/app-config#title), and it overrides the app config.
|
||
3 years ago
|
|
||
|
```yaml
|
||
|
---
|
||
|
title: VitePress
|
||
|
---
|
||
|
```
|
||
|
|
||
3 years ago
|
## titleTemplate
|
||
|
|
||
|
- Type: `string | boolean`
|
||
|
|
||
2 years ago
|
The suffix for the title. It's same as [config.titleTemplate](../config/app-config#titletemplate), and it overrides the app config.
|
||
3 years ago
|
|
||
|
```yaml
|
||
|
---
|
||
2 years ago
|
title: VitePress
|
||
|
titleTemplate: Vite & Vue powered static site generator
|
||
3 years ago
|
---
|
||
|
```
|
||
|
|
||
3 years ago
|
## description
|
||
|
|
||
|
- Type: `string`
|
||
|
|
||
2 years ago
|
Description for the page. It's same as [config.description](../config/app-config#description), and it overrides the app config.
|
||
3 years ago
|
|
||
|
```yaml
|
||
|
---
|
||
|
description: VitePress
|
||
|
---
|
||
|
```
|
||
|
|
||
2 years ago
|
## head
|
||
3 years ago
|
|
||
2 years ago
|
- Type: `HeadConfig[]`
|
||
3 years ago
|
|
||
|
Specify extra head tags to be injected:
|
||
|
|
||
|
```yaml
|
||
|
---
|
||
|
head:
|
||
|
- - meta
|
||
|
- name: description
|
||
|
content: hello
|
||
|
- - meta
|
||
|
- name: keywords
|
||
|
content: super duper SEO
|
||
|
---
|
||
|
```
|
||
|
|
||
|
```ts
|
||
2 years ago
|
type HeadConfig =
|
||
3 years ago
|
| [string, Record<string, string>]
|
||
|
| [string, Record<string, string>, string]
|
||
|
```
|
||
|
|
||
3 years ago
|
## lastUpdated
|
||
|
|
||
|
- Type: `boolean`
|
||
|
- Default: `true`
|
||
|
|
||
|
Whether to display [Last Updated](../guide/theme-last-updated) text in the current page.
|
||
|
|
||
|
```yaml
|
||
|
---
|
||
|
lastUpdated: false
|
||
|
---
|
||
|
```
|
||
|
|
||
3 years ago
|
## layout
|
||
|
|
||
|
- Type: `doc | home | page`
|
||
|
- Default: `doc`
|
||
|
|
||
|
Determines the layout of the page.
|
||
|
|
||
|
- `doc` - It applies default documentation styles to the markdown content.
|
||
2 years ago
|
- `home` - Special layout for "Home Page". You may add extra options such as `hero` and `features` to rapidly create beautiful landing page.
|
||
2 years ago
|
- `page` - Behave similar to `doc` but it applies no styles to the content. Useful when you want to create a fully custom page.
|
||
3 years ago
|
|
||
|
```yaml
|
||
|
---
|
||
3 years ago
|
layout: doc
|
||
3 years ago
|
---
|
||
|
```
|
||
|
|
||
|
## hero
|
||
|
|
||
|
- Type: `Hero`
|
||
|
|
||
2 years ago
|
This option only takes effect when `layout` is set to `home`.
|
||
3 years ago
|
|
||
|
It defines contents of home hero section.
|
||
|
|
||
|
```yaml
|
||
|
---
|
||
|
layout: home
|
||
|
|
||
|
hero:
|
||
2 years ago
|
name: VitePress
|
||
3 years ago
|
text: Vite & Vue powered static site generator.
|
||
|
tagline: Lorem ipsum...
|
||
3 years ago
|
actions:
|
||
|
- theme: brand
|
||
|
text: Get Started
|
||
|
link: /guide/what-is-vitepress
|
||
|
- theme: alt
|
||
|
text: View on GitHub
|
||
|
link: https://github.com/vuejs/vitepress
|
||
3 years ago
|
---
|
||
|
```
|
||
|
|
||
|
```ts
|
||
|
interface Hero {
|
||
3 years ago
|
// The string shown top of `text`. Comes with brand color
|
||
|
// and expected to be short, such as product name.
|
||
|
name?: string
|
||
3 years ago
|
|
||
3 years ago
|
// The main text for the hero section. This will be defined
|
||
|
// as `h1` tag.
|
||
3 years ago
|
text: string
|
||
|
|
||
|
// Tagline displayed below `text`.
|
||
3 years ago
|
tagline?: string
|
||
|
|
||
|
// Action buttons to display in home hero section.
|
||
|
actions?: HeroAction[]
|
||
|
}
|
||
|
|
||
|
interface HeroAction {
|
||
|
// Color theme of the button. Defaults to `brand`.
|
||
|
theme?: 'brand' | 'alt'
|
||
|
|
||
|
// Label of the button.
|
||
|
text: string
|
||
|
|
||
|
// Destination link of the button.
|
||
|
link: string
|
||
|
}
|
||
|
```
|
||
|
|
||
|
## features
|
||
|
|
||
|
- Type: `Feature[]`
|
||
|
|
||
2 years ago
|
This option only takes effect when `layout` is set to `home`.
|
||
3 years ago
|
|
||
|
It defines items to display in features section.
|
||
|
|
||
2 years ago
|
You may learn more about it in [Theme: Home Page](../guide/theme-home-page).
|
||
|
|
||
2 years ago
|
## aside
|
||
|
|
||
|
- Type: `boolean`
|
||
|
- Default: `true`
|
||
|
|
||
|
If you want the right aside component in `doc` layout not to be shown, set this option to `false`.
|
||
|
|
||
|
```yaml
|
||
|
---
|
||
|
aside: false
|
||
|
---
|
||
|
```
|
||
2 years ago
|
|
||
|
## outline
|
||
|
|
||
|
- Type: `number | [number, number] | 'deep' | false`
|
||
|
- Default: `2`
|
||
|
|
||
2 years ago
|
The levels of header in the outline to display for the page. It's same as [config.themeConfig.outline](../config/theme-config#outline), and it overrides the theme config.
|