diff --git a/docs/guide/custom-themes.md b/docs/guide/custom-themes.md
index 75aeaefc8d..e1b38a2973 100644
--- a/docs/guide/custom-themes.md
+++ b/docs/guide/custom-themes.md
@@ -54,6 +54,10 @@ If the user provided `themeConfig` in `.vuepress/config.js`, it will also be ava
Finally, don't forget that `this.$route` and `this.$router` are also available as part of Vue Router's API.
+## Content Excerpt
+
+If a markdown file contains a `` comment, any content above the comment will be extracted and exposed as `$page.excerpt`. If you are building custom theme for blogging, this data can be used to render a post list with excerpts.
+
## Content Outlet
The compiled content of the current `.md` file being rendered will be available as a special `` global component. You will need to render it somewhere in your layout in order to display the content of the page. The simplest theme can be just a single `Layout.vue` component with the following content:
diff --git a/docs/zh/guide/custom-themes.md b/docs/zh/guide/custom-themes.md
index d74ea39426..bb69e82ddb 100644
--- a/docs/zh/guide/custom-themes.md
+++ b/docs/zh/guide/custom-themes.md
@@ -54,6 +54,10 @@ VuePress 使用单文件组件来构建自定义主题。想要开发一个自
最后,别忘了,作为 Vue Router API 的一部分,`this.$route` 和 `this.$router` 同样可以使用。
+## 内容摘抄
+
+如果一个 markdown 文件中有一个 `` 注释,则该注释之前的内容会被抓取并暴露在 `$page.excerpt` 属性中。如果你在开发一个博客主题,你可以用这个属性来渲染一个带摘抄的文章列表。
+
## 获取渲染内容
当前的 `.md` 文件渲染的内容,可以作为一个独特的全局组件 `` 来使用,你可能想要它显示在页面中的某个地方。一个最简单的主题,可以是一个唯一的 `Layout.vue` 组件,并包含以下内容:
diff --git a/lib/prepare.js b/lib/prepare.js
index c2c7a66d1d..00b7a63faf 100644
--- a/lib/prepare.js
+++ b/lib/prepare.js
@@ -187,10 +187,12 @@ async function resolveOptions (sourceDir) {
if (headers.length) {
data.headers = headers
}
- delete frontmatter.content
if (Object.keys(frontmatter.data).length) {
data.frontmatter = frontmatter.data
}
+ if (frontmatter.excerpt) {
+ data.excerpt = frontmatter.excerpt
+ }
return data
}))
diff --git a/lib/util/index.js b/lib/util/index.js
index 5f6bf82ca5..01ef6ac77f 100644
--- a/lib/util/index.js
+++ b/lib/util/index.js
@@ -48,6 +48,7 @@ exports.parseFrontmatter = content => {
const toml = require('toml')
return matter(content, {
+ excerpt_separator: '',
engines: {
toml: toml.parse.bind(toml),
excerpt: false