-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
fix(@plugin-blog): fix blog layout rendering error (close: #1073) #1095
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, just some small tweaks
@@ -111,7 +111,7 @@ module.exports = class AppContext { | |||
}) | |||
) | |||
|
|||
await this.pluginAPI.options.ready.apply() | |||
await this.pluginAPI.options.ready.asyncApply() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the apply method of a asynchronous option was a alias of asyncApply
: https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/core/lib/plugin-api/abstract/AsyncOption.js#L93
|
||
if (typeof this.frontmatter.layout === 'string') { | ||
this._hasInitLayout = true | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use datatypes: { isString }
from shared-utils
directly.
rawFrontmatter[key] = rawFrontmatter[key] || frontmatter[key] | ||
if (!pageCtx._hasInitLayout) { | ||
rawFrontmatter[key] = frontmatter[key] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would block the apply of other attrs (e.g. permalink
) in frontmatter ? actually I think the following override strategy should be right —— we should respect all the attrs which has been set in user's frontmatter.
if (!frontmatter[key]) {
rawFrontmatter[key] = frontmatter[key]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I ignored this question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vuepress/packages/@vuepress/plugin-blog/index.js
Lines 68 to 70 in e01e60a
if (!frontmatter[key]) { | |
rawFrontmatter[key] || frontmatter[key] | |
} |
Is this setting a bit problematic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= instead of ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I corrected this by the way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool
Another FYI, actually the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
What kind of change does this PR introduce? (check at least one)
If changing the UI of default theme, please provide the before/after screenshot:
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
fix #xxx[,#xxx]
, where "xxx" is the issue number)You have tested in the following browsers: (Providing a detailed version will be better.)
If adding a new feature, the PR's description includes:
To avoid wasting your time, it's best to open a feature request issue first and wait for approval before working on it.
Other information:
The new page of the blog plugin cannot be used because the getSiteData method has been executed before the plugin ready.