Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 50abb08

Browse files
feat: generate content title from frontmatter (#51)
BREAKING CHANGE: Require title in front matter
1 parent 0d0c00b commit 50abb08

19 files changed

+64
-45
lines changed

components/Toc.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export default {
142142
max-height 100vh
143143
max-width 220px
144144
overflow-y auto
145-
padding-top $navbarHeight
145+
padding-top 5rem
146146
top 0
147147
right 10px
148148
box-sizing border-box

docs/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,15 @@ From now on, you can run `yarn dev` or `npm run dev` and head `localhost:8080` t
133133

134134
The `_posts` folder is where your blog posts live. You can simply write blog posts in Markdown.
135135

136-
All blog post files can begin with front matter which is typically used to set a layout or other meta data:
136+
All blog post files can begin with front matter. Only `title` is required, but we recommend you define all frontmatter variables as below. They'll be used to set the corresponding layout. Check out [frontmatter](config/front-matter) for more details. Here's an example:
137137
```md
138138
---
139+
title: Hello World
139140
date: 2020-01-11
140141
author: Billyyyyy3320
141142
location: Taipei
142143
---
143144

144-
# Hello World
145-
146145
> This is official blog theme.
147146

148147
My content.
@@ -161,8 +160,9 @@ It helps you organize and will be use as permalink by default. For example:
161160
By default, Navigate to `/tag/`, you'll see the tag entry page.
162161
You can set you own tags in front matter, and they'll automatically be classified:
163162

164-
```yaml{3-5}
163+
```yaml{4-6}
165164
---
165+
title: Hello World
166166
date: 2020-01-11
167167
tag:
168168
- JavaScript

docs/config/front-matter.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
# Front Matter
22

3+
## title
4+
5+
- Type: `string`
6+
- Default: `undefined`
7+
- Required: `true`
8+
9+
The title for the page and content.
10+
11+
e.g.
12+
13+
```markdown
14+
---
15+
title: Hello World
16+
---
17+
```
18+
319
## tag/tags
420

521
- Type: `string|string[]`
622
- Default: `undefined`
23+
- Required: `false`
724

825
The key to classifier pages.
926

@@ -18,7 +35,14 @@ tags:
1835
```
1936

2037
## date
21-
Date for the post. This will be used for permalink and displayed in the layout:
38+
39+
- Type: `YYYY-MM-DD`
40+
- Default: `undefined`
41+
- Required: `false`
42+
43+
Our recommended format is `YYYY-MM-DD`, but it actually accepts multi formats. VuePress is using `js-yaml` which follows standard yaml types, so you can find all available formats [here](https://yaml.org/type/timestamp.html).
44+
45+
Date for the post. This will be used for permalink, sorting and displayed in the layout:
2246

2347
![Date](../assets/date.png)
2448

@@ -31,6 +55,10 @@ date: 2016-10-20
3155

3256
## author
3357

58+
- Type: `string`
59+
- Default: `undefined`
60+
- Required: `false`
61+
3462
Author for the post. This will be displayed in the layout:
3563

3664
![Author](../assets/author.png)
@@ -45,6 +73,10 @@ author: ULIVZ
4573

4674
## location
4775

76+
- Type: `string`
77+
- Default: `undefined`
78+
- Required: `false`
79+
4880
Location for the post. This will be displayed in the layout:
4981

5082
![Location](../assets/location.png)
@@ -59,6 +91,10 @@ location: Hangzhou
5991

6092
## summary
6193

94+
- Type: `string`
95+
- Default: `undefined`
96+
- Required: `false`
97+
6298
Summary for the post. This will be displayed in the layout:
6399

64100
![Summary](../assets/summary.png)

docs/config/palette.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ $footerColor = #828282
2222
$newsletterBgColor = #f8f8f8
2323
2424
// layout
25-
$navbarHeight = 5rem
2625
$contentWidth = 740px
2726
2827
// responsive breakpoints

example/.vuepress/styles/palette.styl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
// $newsletterBgColor = #f8f8f8
1919

2020
// layout
21-
// $navbarHeight = 5rem
2221
// $contentWidth = 740px
2322

2423
// responsive breakpoints

example/_posts/2018-11-7-frontmatter-in-vuepress-2.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
title: frontmatter in vuepress 2
23
date: 2018-11-7
34
tag:
45
- frontmatter
@@ -7,8 +8,6 @@ author: ULIVZ
78
location: Hangzhou
89
---
910

10-
# Front Matter in VuePress
11-
1211
Any markdown file that contains a YAML front matter block will be processed by [gray-matter](https://github.com/jonschlinkert/gray-matter). The front matter must be the first thing in the markdown file and must take the form of valid YAML set between triple-dashed lines. Here is a basic example:
1312

1413
```markdown

example/_posts/2018-11-7-frontmatter-in-vuepress-3.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
title: frontmatter in vuepress 3
23
date: 2018-11-7
34
tag:
45
- frontmatter
@@ -7,8 +8,6 @@ author: ULIVZ
78
location: Hangzhou
89
---
910

10-
# Front Matter in VuePress
11-
1211
Any markdown file that contains a YAML front matter block will be processed by [gray-matter](https://github.com/jonschlinkert/gray-matter). The front matter must be the first thing in the markdown file and must take the form of valid YAML set between triple-dashed lines. Here is a basic example:
1312

1413
```markdown

example/_posts/2018-11-7-frontmatter-in-vuepress.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
title: frontmatter in vuepress 1
23
date: 2018-11-7
34
tag:
45
- frontmatter
@@ -7,8 +8,6 @@ author: ULIVZ
78
location: Hangzhou
89
---
910

10-
# Front Matter in VuePress
11-
1211
Any markdown file that contains a YAML front matter block will be processed by [gray-matter](https://github.com/jonschlinkert/gray-matter). The front matter must be the first thing in the markdown file and must take the form of valid YAML set between triple-dashed lines. Here is a basic example:
1312

1413
```markdown

example/_posts/2019-2-26-markdown-slot-2.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
title: Markdown Slot 2
23
date: 2019-2-26
34
tag:
45
- markdown
@@ -7,8 +8,6 @@ author: ULIVZ
78
location: Hangzhou
89
---
910

10-
# Markdown Slot
11-
1211
VuePress implements a content distribution API for Markdown. With this feature, you can split your document into multiple fragments to facilitate flexible composition in the layout component.
1312

1413
## Why do I need Markdown Slot?

example/_posts/2019-2-26-markdown-slot-3.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
title: Markdown Slot 3
23
date: 2019-2-26
34
tag:
45
- markdown
@@ -7,8 +8,6 @@ author: ULIVZ
78
location: Hangzhou
89
---
910

10-
# Markdown Slot
11-
1211
VuePress implements a content distribution API for Markdown. With this feature, you can split your document into multiple fragments to facilitate flexible composition in the layout component.
1312

1413
## Why do I need Markdown Slot?

0 commit comments

Comments
 (0)