Skip to content

Commit 078696e

Browse files
committed
feat($plugin-blog): correct Layout for index page and one-level page
1 parent 20d612c commit 078696e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Diff for: packages/@vuepress/plugin-blog/index.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const path = require('path')
2+
13
module.exports = (options, ctx) => ({
24
extendPageData (pageCtx) {
35
const {
@@ -16,15 +18,24 @@ module.exports = (options, ctx) => ({
1618
const isLayoutExists = name => layoutComponentMap[name] !== undefined
1719
const getLayout = name => isLayoutExists(name) ? name : 'Layout'
1820

21+
const isDirectChild = regularPath => path.parse(regularPath).dir === '/'
1922
const enhancers = [
2023
{
21-
when: ({ regularPath }) => regularPath === '/category/',
24+
when: ({ regularPath }) => isDirectChild(regularPath),
25+
frontmatter: { layout: getLayout('Page') }
26+
},
27+
{
28+
when: ({ regularPath }) => regularPath === '/category.html',
2229
frontmatter: { layout: getLayout('Category') }
2330
},
2431
{
25-
when: ({ regularPath }) => regularPath === '/tags/',
32+
when: ({ regularPath }) => regularPath === '/tags.html',
2633
frontmatter: { layout: getLayout('Tag') }
2734
},
35+
{
36+
when: ({ regularPath }) => regularPath === '/',
37+
frontmatter: { layout: getLayout('Layout') }
38+
},
2839
{
2940
when: ({ regularPath }) => regularPath.startsWith('/_posts/'),
3041
frontmatter: {

Diff for: packages/@vuepress/plugin-blog/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@vuepress/plugin-blog",
33
"version": "1.0.0",
4-
"description": "theme plugin for vuepress",
4+
"description": "blog plugin for vuepress",
55
"main": "index.js",
66
"publishConfig": {
77
"access": "public"

0 commit comments

Comments
 (0)