Add date_time_merge filed into post_meta#223
Conversation
With some of user may want post's show time can display to second. So make a flag to switch it. if flag is true, the display format will merge date, time together and seperate by a space. for example: in hexo _config.yml date_format: YYYY-MM-DD time_format: HH:mm:ss in next _config.yml post_meta: ... date_time_merge: true ... final format will be 'YYYY-MM-DD HH:mm:ss'
|
Thank's! 👍 |
|
@ivan-nginx wow, waht a fast merge! thx for your approve. and that's this merge made for. couple of hours ago, i was wondering that the code seems not so good for the purpose of "checking with date time". i think i accendently accidentally bind the check and output format. <!-- layout/_macro/post.swig#L85 -->
{% if theme.post_meta.date_time_merge %}
{% set datetime_format = config.date_format + ' ' + config.time_format %}
{% else %}
{% set datetime_format = config.date_format %}
{% endif %}
{% if theme.post_meta.created_at %}
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
{% if theme.post_meta.item_text %}
<span class="post-meta-item-text">{{ __('post.posted') }}</span>
{% endif %}
<time title="{{ __('post.created') }}" itemprop="dateCreated datePublished" datetime="{{ moment(post.date).format() }}">{#
#}{{ date(post.date, datetime_format) }}{#
#}</time>
{% endif %}
{% set date_updated_diff = date(post.date, datetime_format) != date(post.updated, datetime_format) %}
>>>>>>>>>>>>>> The check should run at full format for more precisely.
{% if theme.post_meta.updated_at %}
{% if !theme.post_meta.updated_diff || theme.post_meta.updated_diff && date_updated_diff %}
{% set display_updated = true %}
{% endif %}
{% endif %}i will try to edit this part again for a better program logic improve. |
|
Yeah, i understand, it's clever: fix for one-day diffs option posting and in same time add a feature! |
|
@jackey8616 also, mb this can be important for improve this pull in future. |
|
@ivan-nginx this looks really good that we can even provide a datetime field for posts. if anything helps, plz tell me, even some keyword. |
|
EJS: |
|
holy shooooooooot. i was deadly trying with i will make full use of this function. 🤣 🤣 🤣 |
Original updated_diff checking method changed From date(new Date(), [format]) To full_date(new Date(), [format]) For full datetime checking. Also merge some excess if statement. References theme-next#223
Original updated_diff checking method changed
From date(new Date(), [format])
To full_date(new Date(), [format])
For full datetime checking.
Also merge some excess if statement.
References theme-next#223
Add date_time_merge filed into post_meta
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Without origin hexo and NexT _config.ymlIn post time area, only display with date. like below
What is the new behavior?
It can merge hexo config's date and time format together. like:
How to use?
In NexT
_config.yml:and everything worked.
Does this PR introduce a breaking change?