Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/@vuepress/plugin-blog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = (options, ctx) => {
const { layoutComponentMap } = ctx
const {
pageEnhancers = [],
postsDir = '_posts',
categoryIndexPageUrl = '/category/',
tagIndexPageUrl = '/tag/',
permalink = '/:year/:month/:day/:slug'
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions packages/docs/docs/plugin/official/plugin-blog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ module.exports = {

## Options

### postsDir

- Type: `string`
- Default: `_posts`

### categoryIndexPageUrl

- Type: `string`
Expand Down
11 changes: 11 additions & 0 deletions packages/docs/docs/zh/plugin/official/plugin-blog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ module.exports = {

## 选项

### postsDir

- 类型: `string`
- 默认值: `_posts`

### categoryIndexPageUrl

- 类型: `string`
Expand All @@ -33,3 +38,9 @@ module.exports = {
- 类型: `string`
- 默认值: `/tag/`

### permalink

- 类型: `string`
- 默认值: `/:year/:month/:day/:slug`

为博客文章设置永久链接。详情参考 [Permalinks](/zh/guide/permalinks.html#模板变量)。