feat($plugin-blog): add postsDir option (#998)

This commit is contained in:
Liu Xinyu
2018-11-13 08:52:08 -06:00
committed by ULIVZ
parent 2256326292
commit ecb1920a9e
3 changed files with 18 additions and 1 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ module.exports = (options, ctx) => {
const { layoutComponentMap } = ctx
const {
pageEnhancers = [],
postsDir = '_posts',
categoryIndexPageUrl = '/category/',
tagIndexPageUrl = '/tag/',
permalink = '/:year/:month/:day/:slug'
@@ -40,7 +41,7 @@ module.exports = (options, ctx) => {
frontmatter: { layout: getLayout('Layout') }
},
{
when: ({ regularPath }) => regularPath.startsWith('/_posts/'),
when: ({ regularPath }) => regularPath.startsWith(`/${postsDir}/`),
frontmatter: {
layout: getLayout('Post', 'Page'),
permalink: permalink
@@ -23,6 +23,11 @@ module.exports = {
## Options
### postsDir
- Type: `string`
- Default: `_posts`
### categoryIndexPageUrl
- Type: `string`
@@ -23,6 +23,11 @@ module.exports = {
## 选项
### postsDir
- 类型: `string`
- 默认值: `_posts`
### categoryIndexPageUrl
- 类型: `string`
@@ -33,3 +38,9 @@ module.exports = {
- 类型: `string`
- 默认值: `/tag/`
### permalink
- 类型: `string`
- 默认值: `/:year/:month/:day/:slug`
为博客文章设置永久链接。详情参考 [Permalinks](/zh/guide/permalinks.html#模板变量)。