diff --git a/package.json b/package.json index 180e22b813..39d6660a9c 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "dev": "yarn tsc && yarn workspace docs dev", "build": "yarn tsc && yarn workspace docs build", "show-help": "yarn workspace docs show-help", - "dev:blog": "yarn workspace blog dev", - "build:blog": "yarn workspace blog build", + "dev:blog": "yarn tsc && yarn workspace blog dev", + "build:blog": "yarn tsc && yarn workspace blog build", "register-vuepress": "lerna exec --scope vuepress -- yarn link", "lint": "eslint packages --fix --ext .js,.vue", "release": "yarn --pure-lockfile && yarn tsc && node scripts/release.js", diff --git a/packages/@vuepress/core/lib/plugin-api/constants.js b/packages/@vuepress/core/lib/plugin-api/constants.js index 155472ffea..d9fee97d1a 100644 --- a/packages/@vuepress/core/lib/plugin-api/constants.js +++ b/packages/@vuepress/core/lib/plugin-api/constants.js @@ -2,7 +2,7 @@ const PLUGIN_OPTION_META_MAP = { // hooks - READY: { name: 'ready', types: [Function] }, + READY: { name: 'ready', types: [Function], async: true }, COMPILED: { name: 'compiled', types: [Function] }, UPDATED: { name: 'updated', types: [Function] }, GENERATED: { name: 'generated', types: [Function], async: true }, diff --git a/packages/@vuepress/plugin-blog/index.js b/packages/@vuepress/plugin-blog/index.js index c339e64465..bc9ca9d268 100644 --- a/packages/@vuepress/plugin-blog/index.js +++ b/packages/@vuepress/plugin-blog/index.js @@ -16,26 +16,21 @@ module.exports = (options, ctx) => { const enhancers = [ { - when: ({ regularPath }) => isDirectChild(regularPath), - frontmatter: { layout: getLayout('Page', 'Layout') }, - data: { type: 'page' } + when: ({ regularPath }) => regularPath === categoryIndexPageUrl, + frontmatter: { layout: getLayout('Categories', 'Page') } }, { when: ({ regularPath }) => regularPath.startsWith('/category/'), frontmatter: { layout: getLayout('Category', 'Page') } }, { - when: ({ regularPath }) => regularPath === categoryIndexPageUrl, - frontmatter: { layout: getLayout('Categories', 'Page') } + when: ({ regularPath }) => regularPath === tagIndexPageUrl, + frontmatter: { layout: getLayout('Tags', 'Page') } }, { when: ({ regularPath }) => regularPath.startsWith('/tag/'), frontmatter: { layout: getLayout('Tag', 'Page') } }, - { - when: ({ regularPath }) => regularPath === tagIndexPageUrl, - frontmatter: { layout: getLayout('Tags', 'Page') } - }, { when: ({ regularPath }) => regularPath === '/', frontmatter: { layout: getLayout('Layout') } @@ -48,7 +43,12 @@ module.exports = (options, ctx) => { }, data: { type: 'post' } }, - ...pageEnhancers + ...pageEnhancers, + { + when: ({ regularPath }) => isDirectChild(regularPath), + frontmatter: { layout: getLayout('Page', 'Layout') }, + data: { type: 'page' } + } ] return { @@ -65,8 +65,8 @@ module.exports = (options, ctx) => { }) => { if (when(pageCtx)) { Object.keys(frontmatter).forEach(key => { - if (!frontmatter[key]) { - rawFrontmatter[key] || frontmatter[key] + if (!rawFrontmatter[key]) { + rawFrontmatter[key] = frontmatter[key] } }) Object.assign(pageCtx, data) @@ -77,7 +77,7 @@ module.exports = (options, ctx) => { /** * Create tag page and category page. */ - ready () { + async ready () { const { pages } = ctx const tagMap = {} const categoryMap = {} @@ -142,7 +142,7 @@ module.exports = (options, ctx) => { frontmatter: { title: `${categoryName} | Category` } })) ] - extraPages.forEach(page => ctx.addPage(page)) + await Promise.all(extraPages.map(page => ctx.addPage(page))) }, /** diff --git a/packages/@vuepress/theme-blog/layouts/Tags.vue b/packages/@vuepress/theme-blog/layouts/Tags.vue new file mode 100644 index 0000000000..6b3ff61c34 --- /dev/null +++ b/packages/@vuepress/theme-blog/layouts/Tags.vue @@ -0,0 +1,5 @@ +