-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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: 'optional_updated' option #3887
Conversation
@@ -17,7 +17,6 @@ module.exports = ctx => { | |||
}, | |||
updated: { | |||
type: Moment, | |||
default: moment, |
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.
This is necessary to allow page.updated
to be null.
data.comments.should.be.true; | ||
data.layout.should.eql('post'); | ||
data._content.should.eql(''); | ||
data.link.should.eql(''); | ||
data.raw.should.eql(''); | ||
data.published.should.be.true; | ||
should.not.exist(data.updated); |
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.
In actual use, data.updated
won't be null (if optional_updated
is disabled, which is the default), thanks to
hexo/lib/plugins/processor/post.js
Line 90 in 2146a03
data.updated = stats.mtime; |
Enabling this config will break themes/plugins that assume So far, I notice hexo-generator-sitemap is compatible, but not hexo-generator-feed. I also tried to minimize the breaking change by retaining this line, then set |
8ecb782
to
26133ca
Compare
I'm not very keen |
If the Breaking Changes is inevitable, then we might move it to Hexo 5.0.0. Also an idea is to merge |
Added to v5 milestone
+1, I'll create |
Superseded by #4278. |
What does it do?
Continuation of #3235, specifically #3235 (comment).
User may prefer to have full control on value of
post.updated
and not use file modification time. Currently for my blog, I have to use a new variablelastUpdated
as a workaround; since that variable is not recognized by many plugins, I have to fork many plugins.With this PR,
config.optional_updated
can be enabled (disabled by default), to leavepost.updated
to be empty ifupdated:
is not set in the front-matter.Breaking changes
Post
andPage
model no longer assign defaultmoment()
value toupdated
property.optional_updated
(because the option is not passed to the model), assuming all the following conditions exist:Post
/Page
model (example)post.updated
/page.updated
variable (example)post.updated
/page.updated
.optional_updated
is enabled, assuming all the following conditions exist:post.updated
/page.updated
variablepost.updated
/page.updated
. (e.g. hexo-theme-next doesn't check)How to test
Screenshots
Pull request tasks