Skip to content
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: bring up config.updated_option #4278

Merged
merged 3 commits into from Jun 22, 2020
Merged

Conversation

SukkaW
Copy link
Member

@SukkaW SukkaW commented Apr 27, 2020

What does it do?

Continuation of #3235, specifically #3235 (comment). #3887 (comment)

Quote from #3887

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 variable lastUpdated 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 leave post.updated to be empty if updated: is not set in the front-matter.

This PR introduced a new option updated_option which accept:

  • mtime: This is the default behavior of hexo, use file's mtime as data.updated when not set in front-matter.
  • date: Use data.date as data.updated when not set in front-matter.
  • empty: Completely remove data.updated when not set in front-matter. This shouldn't be used by common users as it will break many themes (like NexT) and plugins (like hexo-generator-feed)

The use_date_for_updated introduced in hexo v4 is still retained, and still has higher priority than updated_option (That's mean when use_date_for_updated is set to true, updated_option will be ignored).

Breaking changes

See #3887 for more details.

How to test

git clone -b BRANCH https://github.com/USER/hexo.git
cd hexo
npm install
npm test

Screenshots

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@SukkaW SukkaW requested review from curbengh and a team April 27, 2020 06:55
@SukkaW SukkaW added Breaking Change enhancement New feature or request labels Apr 27, 2020
@SukkaW SukkaW changed the title feat: config.updated option feat: bring up config.updated_option Apr 27, 2020
@coveralls
Copy link

coveralls commented Apr 27, 2020

Coverage Status

Coverage increased (+0.08%) to 97.822% when pulling db55fc7 on SukkaW:feat-updated_option into c51b87e on hexojs:master.

@SukkaW
Copy link
Member Author

SukkaW commented Apr 27, 2020

Without default: moment defined in Post model, the page.updated will no longer exist by default, causing open_graph test case (which is rely on page.updated) to fail.

@curbengh
Copy link
Contributor

curbengh commented Jun 21, 2020

Without default: moment defined in Post model, the page.updated will no longer exist by default, causing open_graph test case (which is rely on page.updated) to fail.

Comment out that line and mention this PR.


Since the default behavior is still retained, no breaking change then?

@SukkaW SukkaW marked this pull request as ready for review June 21, 2020 12:43
@SukkaW
Copy link
Member Author

SukkaW commented Jun 21, 2020

@curbengh Done.

The PR is now ready for reivew.

Copy link
Contributor

@curbengh curbengh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested working.

@SukkaW SukkaW merged commit 2dfaa6a into hexojs:master Jun 22, 2020
curbengh pushed a commit to curbengh/curbengh.github.io that referenced this pull request Jun 23, 2020
- post.updated will be null if not set in front-matter
- hexojs/hexo#4278
@curbengh
Copy link
Contributor

I re-label this as breaking change due to https://github.com/hexojs/hexo/pull/4278/files#diff-a17a4a3f711955a771f0f61a61525fd9L30, post.updated no longer has a default value and it could be a breaking change for dev that uses Hexo API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants