Skip to content

Commit

Permalink
fix(@plugin-blog): fix blog layout rendering error (close: #1073)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrminfive committed Dec 12, 2018
1 parent a56c3b4 commit bc170f9
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 --fix packages/**/*.js packages/**/*.vue packages/**/bin/*",
"release": "yarn --pure-lockfile && yarn tsc && node scripts/release.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/core/lib/plugin-api/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/core/lib/prepare/AppContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module.exports = class AppContext {
})
)

await this.pluginAPI.options.ready.apply()
await this.pluginAPI.options.ready.asyncApply()
await Promise.all([
this.pluginAPI.options.clientDynamicModules.apply(this),
this.pluginAPI.options.enhanceAppFiles.apply(this),
Expand Down
4 changes: 4 additions & 0 deletions packages/@vuepress/core/lib/prepare/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ module.exports = class Page {
layout: this.key
}, data)
}

if (typeof this.frontmatter.layout === 'string') {
this._hasInitLayout = true
}
}

// resolve i18n
Expand Down
8 changes: 5 additions & 3 deletions packages/@vuepress/plugin-blog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ module.exports = (options, ctx) => {
}) => {
if (when(pageCtx)) {
Object.keys(frontmatter).forEach(key => {
rawFrontmatter[key] = rawFrontmatter[key] || frontmatter[key]
if (!pageCtx._hasInitLayout) {
rawFrontmatter[key] = frontmatter[key]
}
})
Object.assign(pageCtx, data)
}
Expand All @@ -75,7 +77,7 @@ module.exports = (options, ctx) => {
/**
* Create tag page and category page.
*/
ready () {
async ready () {
const { pages } = ctx
const tagMap = {}
const categoryMap = {}
Expand Down Expand Up @@ -140,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)))
},

/**
Expand Down
5 changes: 5 additions & 0 deletions packages/@vuepress/theme-blog/layouts/Tags.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div class="container">
<h2>Now is Tags Page</h2>
</div>
</template>

0 comments on commit bc170f9

Please sign in to comment.