diff --git a/packages/@vuepress/plugin-blog/index.js b/packages/@vuepress/plugin-blog/index.js index e02dc10430..00a4d870f2 100644 --- a/packages/@vuepress/plugin-blog/index.js +++ b/packages/@vuepress/plugin-blog/index.js @@ -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 diff --git a/packages/docs/docs/plugin/official/plugin-blog.md b/packages/docs/docs/plugin/official/plugin-blog.md index bca2ec1593..c1965706c7 100644 --- a/packages/docs/docs/plugin/official/plugin-blog.md +++ b/packages/docs/docs/plugin/official/plugin-blog.md @@ -23,6 +23,11 @@ module.exports = { ## Options +### postsDir + +- Type: `string` +- Default: `_posts` + ### categoryIndexPageUrl - Type: `string` diff --git a/packages/docs/docs/zh/plugin/official/plugin-blog.md b/packages/docs/docs/zh/plugin/official/plugin-blog.md index 09a82c41cf..86c4f20165 100644 --- a/packages/docs/docs/zh/plugin/official/plugin-blog.md +++ b/packages/docs/docs/zh/plugin/official/plugin-blog.md @@ -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#模板变量)。