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.
222 lines
4.2 KiB
222 lines
4.2 KiB
2 years ago
|
---
|
||
|
outline: deep
|
||
|
---
|
||
|
|
||
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 site-level or theme-level config options. Also, there are config options which you can only define in frontmatter.
|
||
3 years ago
|
|
||
2 years ago
|
Example usage:
|
||
|
|
||
|
```md
|
||
3 years ago
|
---
|
||
|
title: Docs with VitePress
|
||
|
editLink: true
|
||
|
---
|
||
|
```
|
||
|
|
||
2 years ago
|
You can access frontmatter data via the `$frontmatter` global in Vue expressions:
|
||
3 years ago
|
|
||
|
```md
|
||
|
{{ $frontmatter.title }}
|
||
|
```
|
||
|
|
||
|
## title
|
||
|
|
||
|
- Type: `string`
|
||
|
|
||
2 years ago
|
Title for the page. It's same as [config.title](./site-config#title), and it overrides the site-level 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](./site-config#titletemplate), and it overrides the site-level 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](./site-config#description), and it overrides the site-level config.
|
||
3 years ago
|
|
||
|
```yaml
|
||
|
---
|
||
|
description: VitePress
|
||
|
---
|
||
|
```
|
||
|
|
||
2 years ago
|
## head
|
||
3 years ago
|
|
||
2 years ago
|
- Type: `HeadConfig[]`
|
||
3 years ago
|
|
||
2 years ago
|
Specify extra head tags to be injected for the current page. Will be appended after head tags injected by site-level config.
|
||
3 years ago
|
|
||
|
```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]
|
||
|
```
|
||
|
|
||
2 years ago
|
## Default Theme Only
|
||
2 years ago
|
|
||
2 years ago
|
The following frontmatter options are only applicable when using the default theme.
|
||
2 years ago
|
|
||
1 year ago
|
### layout
|
||
3 years ago
|
|
||
|
- 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
|
---
|
||
|
```
|
||
|
|
||
1 year ago
|
### hero <Badge type="info" text="home page only" />
|
||
3 years ago
|
|
||
2 years ago
|
Defines contents of home hero section when `layout` is set to `home`. More details in [Default Theme: Home Page](./default-theme-home-page).
|
||
3 years ago
|
|
||
1 year ago
|
### features <Badge type="info" text="home page only" />
|
||
3 years ago
|
|
||
2 years ago
|
Defines items to display in features section when `layout` is set to `home`. More details in [Default Theme: Home Page](./default-theme-home-page).
|
||
2 years ago
|
|
||
1 year ago
|
### navbar
|
||
1 year ago
|
|
||
|
- Type: `boolean`
|
||
|
- Default: `true`
|
||
|
|
||
|
Whether to display [navbar](./default-theme-nav).
|
||
|
|
||
|
```yaml
|
||
|
---
|
||
|
navbar: false
|
||
|
---
|
||
|
```
|
||
|
|
||
1 year ago
|
### sidebar
|
||
1 year ago
|
|
||
|
- Type: `boolean`
|
||
|
- Default: `true`
|
||
|
|
||
|
Whether to display [sidebar](./default-theme-sidebar).
|
||
|
|
||
|
```yaml
|
||
|
---
|
||
|
sidebar: false
|
||
|
---
|
||
|
```
|
||
|
|
||
1 year ago
|
### aside
|
||
2 years ago
|
|
||
2 years ago
|
- Type: `boolean | 'left'`
|
||
2 years ago
|
- Default: `true`
|
||
|
|
||
2 years ago
|
Defines the location of the aside component in the `doc` layout.
|
||
|
|
||
|
Setting this value to `false` prevents rendering of aside container.\
|
||
|
Setting this value to `true` renders the aside to the right.\
|
||
|
Setting this value to `'left'` renders the aside to the left.
|
||
2 years ago
|
|
||
|
```yaml
|
||
|
---
|
||
|
aside: false
|
||
|
---
|
||
|
```
|
||
2 years ago
|
|
||
1 year ago
|
### outline
|
||
2 years ago
|
|
||
|
- Type: `number | [number, number] | 'deep' | false`
|
||
|
- Default: `2`
|
||
|
|
||
1 year ago
|
The levels of header in the outline to display for the page. It's same as [config.themeConfig.outline.level](./default-theme-config#outline), and it overrides the value set in site-level config.
|
||
2 years ago
|
|
||
1 year ago
|
### lastUpdated
|
||
2 years ago
|
|
||
1 year ago
|
- Type: `boolean | Date`
|
||
2 years ago
|
- Default: `true`
|
||
|
|
||
1 year ago
|
Whether to display [last updated](./default-theme-last-updated) text in the footer of the current page. If a datetime is specified, it will be displayed instead of the last git modified timestamp.
|
||
2 years ago
|
|
||
|
```yaml
|
||
|
---
|
||
|
lastUpdated: false
|
||
|
---
|
||
|
```
|
||
2 years ago
|
|
||
1 year ago
|
### editLink
|
||
2 years ago
|
|
||
|
- Type: `boolean`
|
||
|
- Default: `true`
|
||
|
|
||
1 year ago
|
Whether to display [edit link](./default-theme-edit-link) in the footer of the current page.
|
||
2 years ago
|
|
||
|
```yaml
|
||
|
---
|
||
|
editLink: false
|
||
|
---
|
||
|
```
|
||
1 year ago
|
|
||
1 year ago
|
### footer
|
||
1 year ago
|
|
||
|
- Type: `boolean`
|
||
|
- Default: `true`
|
||
|
|
||
1 year ago
|
Whether to display [footer](./default-theme-footer).
|
||
1 year ago
|
|
||
|
```yaml
|
||
|
---
|
||
|
footer: false
|
||
|
---
|
||
1 year ago
|
```
|
||
1 year ago
|
|
||
|
### pageClass
|
||
|
|
||
|
- Type: `string`
|
||
|
|
||
|
Add extra class name to a specific page.
|
||
|
|
||
|
```yaml
|
||
|
---
|
||
|
pageClass: custom-page-class
|
||
|
---
|
||
|
```
|
||
|
|
||
|
Then you can customize styles of this specific page in `.vitepress/theme/custom.css` file:
|
||
|
|
||
|
```css
|
||
|
.custom-page-class {
|
||
5 months ago
|
/* page-specific styles */
|
||
1 year ago
|
}
|
||
|
```
|