hacks-guide-minimal-mistake.../_includes/post__meta.html
Lim Jing Heng f15e02ea58
Show date of posts (#2526)
* add date to read-time.html

* add option for show_date, dynamic icon style

* change read-time to post__meta

* cleanup post__metal.html

* cleanup post__meta include variables

* put date before read time

* remove space in include variable

* allow customisation of post__meta separator

* add some documentation

* oops fix typo derp

* add post date image

* change page meta separator customisation to CSS
2020-08-04 10:39:01 -04:00

35 lines
1.5 KiB
HTML

{% assign page = post | default: page %}
{% if page.read_time or page.show_date %}
<p class="page__meta">
{% if page.show_date %}
{% assign date = page.date %}
<i class="far {% if include.type == 'grid' and page.read_time and page.show_date %}fa-fw {% endif %}fa-calendar-alt" aria-hidden="true"></i>
<time datetime="{{ date | date_to_xmlschema }}">{{ date | date: "%B %-d, %Y" }}</time>
{% endif %}
{% if page.read_time and page.show_date %}
{% if include.type == "grid" %}
<br \>
{% else %}
<span class="post__meta-sep"></span>
{% endif %}
{% endif %}
{% if page.read_time %}
{% assign words_per_minute = page.words_per_minute | default: site.words_per_minute | default: 200 %}
{% assign words = page.content | strip_html | number_of_words %}
<i class="far {% if include.type == 'grid' and page.read_time and page.show_date %}fa-fw {% endif %}fa-clock" aria-hidden="true"></i>
{% if words < words_per_minute %}
{{ site.data.ui-text[site.locale].less_than | default: "less than" }} 1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }}
{% elsif words == words_per_minute %}
1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }}
{% else %}
{{ words | divided_by:words_per_minute }} {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }}
{% endif %}
{% endif %}
</p>
{% endif %}