Skip to content

Commit ecb1920

Browse files
meteorlxyulivz
authored andcommitted
feat($plugin-blog): add postsDir option (#998)
1 parent 2256326 commit ecb1920

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

packages/@vuepress/plugin-blog/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = (options, ctx) => {
44
const { layoutComponentMap } = ctx
55
const {
66
pageEnhancers = [],
7+
postsDir = '_posts',
78
categoryIndexPageUrl = '/category/',
89
tagIndexPageUrl = '/tag/',
910
permalink = '/:year/:month/:day/:slug'
@@ -40,7 +41,7 @@ module.exports = (options, ctx) => {
4041
frontmatter: { layout: getLayout('Layout') }
4142
},
4243
{
43-
when: ({ regularPath }) => regularPath.startsWith('/_posts/'),
44+
when: ({ regularPath }) => regularPath.startsWith(`/${postsDir}/`),
4445
frontmatter: {
4546
layout: getLayout('Post', 'Page'),
4647
permalink: permalink

packages/docs/docs/plugin/official/plugin-blog.md

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ module.exports = {
2323

2424
## Options
2525

26+
### postsDir
27+
28+
- Type: `string`
29+
- Default: `_posts`
30+
2631
### categoryIndexPageUrl
2732

2833
- Type: `string`

packages/docs/docs/zh/plugin/official/plugin-blog.md

+11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ module.exports = {
2323

2424
## 选项
2525

26+
### postsDir
27+
28+
- 类型: `string`
29+
- 默认值: `_posts`
30+
2631
### categoryIndexPageUrl
2732

2833
- 类型: `string`
@@ -33,3 +38,9 @@ module.exports = {
3338
- 类型: `string`
3439
- 默认值: `/tag/`
3540

41+
### permalink
42+
43+
- 类型: `string`
44+
- 默认值: `/:year/:month/:day/:slug`
45+
46+
为博客文章设置永久链接。详情参考 [Permalinks](/zh/guide/permalinks.html#模板变量)

0 commit comments

Comments
 (0)