Adds updated_diff option to post_meta#50
Adds updated_diff option to post_meta#50ivan-nginx merged 5 commits intotheme-next:masterfrom SafeEval:updated-diff
Conversation
When 'post_meta.updated_at' is enabled, all posts show a modification date, even when it is the same as the creation date. The 'post_meta.updated_diff' flag only displays the modification date if it is different than the creation date.
layout/_macro/post.swig
Outdated
| {% endif %} | ||
|
|
||
| {% if theme.post_meta.updated_at %} | ||
| {% if display_updated %} |
There was a problem hiding this comment.
It will cause problems when the user choose only to show the updated_at and not the created_at.
There was a problem hiding this comment.
You're right, thanks. Just revised and verified expected behavior with created_at, updated_at, and updated_diff, by themselves and together.
Fixes PR issue raised by @tsanie: #50 (review)
layout/_macro/post.swig
Outdated
| {% endif %} | ||
| {% endif %} | ||
|
|
||
| {% if display_updated %} |
There was a problem hiding this comment.
Good jobs, I'd like this feature. 👍
But I think here {% if display_updated %} should be {% if theme.post_meta.updated_at && (display_updated || !theme.post_meta.created_at) %}, otherwise any datetime would not be shown when the article's created time equals its updated time and the created_at == false and updated_at == true and updated_diff == true
PS: this config is not normalize but I think it could be a situation. (on the test-case? 😃)
There was a problem hiding this comment.
theme.post_meta
# Post meta display settings
post_meta:
item_text: true
created_at: true
updated_at: false
categories: trueThis is default configuration.
|
@tsanie: It's good to be thorough and cover all possible configurations. Now it only displays the updated datetime when @ivan-nginx: correct, that is how it works, plus a couple additional cases. All 8 possible cases have been verified to work as expected. When
|
|
@HuntedCodes how u not brake your brain with this cases? 😃 |
layout/_macro/post.swig
Outdated
| <span class="post-meta-divider">|</span> | ||
| {% set date_updated_diff = date(post.date, config_date_format) != date(post.updated, config.date_format) %} | ||
| {% if theme.post_meta.updated_at %} | ||
| {% if !theme.post_meta.updated_diff || theme.post_meta.updated_diff && date_updated_diff %} |
There was a problem hiding this comment.
One excess space before date_updated_diff string here.
There was a problem hiding this comment.
Fixed the whitespace, and everything was tested.
|
@ivan-nginx a lot of coffee, and good sleep 😴😴😴😴 ☕️ ☕️ ☕️ ☕️ |
|
Well, at the end of this day i think need a little beer. 🍺 😈 |
|
Beer is for merge conflicts lol |
|
Sometimes it bring fresh ideas and give another point of view on different things. |
Adds updated_diff option to post_meta
When
post_meta.updated_atis enabled, all posts show a modification date,even when it is the same as the creation date. The
post_meta.updated_diffflag only displays the modification date if it is different than the
creation date.
PR Type
What kind of change does this PR introduce?
What is the current behavior?
When
post_meta.updated_atis enabled, posts will always show a modification date, even when it is the same as the creation date.Example:
Result:
What is the new behavior?
If both
updated_atandupdated_diffare true, then the modified date will only be displayed if different from the creation date.If
updated_diffis false (default), then behavior is unchanged.How to use?
In NexT
_config.yml:In a post's meta data:
Result:
In a post's meta data:
Result:
Does this PR introduce a breaking change?