feat(layout): add option for updated time of posts#905
feat(layout): add option for updated time of posts#905ppoffice merged 1 commit intoppoffice:masterfrom
Conversation
|
This content of the PR is useful when some user has Considering theme users may relay on existing behavior, the hiding feature in this PR is only active if the user set Please let me know if we can/should change the default behavior. |
ppoffice
left a comment
There was a problem hiding this comment.
Let's default the behavior to always show article update time. And it would be great if you can update the docs as well.
include/schema/common/article.json
Outdated
| "default": true, | ||
| "nullable": true | ||
| }, | ||
| "updated_auto_hide": { |
There was a problem hiding this comment.
How about replace update_auto_hide with update_time and allow true, false, "auto" as acceptable values?
true: always show article update time whenpage.updatedis set.false: always hide article update time."auto": show article update time only whenpage.updatedis set and it is different frompage.date.
layout/common/article.jsx
Outdated
| const { url_for, date, date_xml, __, _p } = helper; | ||
|
|
||
| const indexLaunguage = config.language || 'en'; | ||
| const skip_same_date = config.article.updated_auto_hide || false; |
There was a problem hiding this comment.
Variable names should be camelCase instead of snake_case.
layout/common/article.jsx
Outdated
| }}></span>} | ||
| {/* Last Update Date */} | ||
| {page.updated && <span class="level-item" dangerouslySetInnerHTML={{ | ||
| {page.updated && !(skip_same_date && moment(page.date).isSame(moment(page.updated))) && <span class="level-item" dangerouslySetInnerHTML={{ |
There was a problem hiding this comment.
Better to set up a new variable for !(skip_same_date && moment(page.date).isSame(moment(page.updated))) so this statement can be cleaner.
const updateTime = article ? article.update_time : true;
const isUpdated = page.updated && !moment(page.date).isSame(moment(page.updated));
const showUpdateTime = page.updated && ((updateTime === 'auto' && isUpdated) || updateTime === true);4a18fd6 to
11bf259
Compare
|
According to reviewer's suggestion, modify the design of this PR as follows: Provides a new config option to determine whether to show updated time. In addition to true/false, we also support "auto" setting that |
Provides a new config option to determine whether to show updated time. In addition to true/false, we also support "auto" setting that shows updated time automatically when post updated time is different from post date. Signed-off-by: Weida Hong <wdhongtw@gmail.com>
11bf259 to
b272dbb
Compare
|
Thanks for merge. :D I will submit another PR for the document site after next release (maybe 4.5.0 or 4.4.1). |
|
@wdhongtw It's already done. |
feat(layout): add option for updated time of posts
If the post's updated is same as date, hide the element of
updated time automatically.
Also provides a new config option to toggle this behavior.
Signed-off-by: Weida Hong wdhongtw@gmail.com