add readtime for posts (#622)
This commit is contained in:
parent
3f4910fde1
commit
a8332c40fd
5 changed files with 66 additions and 29 deletions
16
_includes/readtime.html
Normal file
16
_includes/readtime.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
<!--- "ReadTime on GitHub Jekyll" (c) 2020 Ruby Griffith Ramirez, MIT License -->
|
||||
|
||||
{% assign ReadTime = page.content | strip_html | number_of_words %}
|
||||
{% assign calcReadTime = ReadTime | float %}
|
||||
{% assign finalReadTime = calcReadTime | divided_by:200 | round: 2 %}
|
||||
{% assign number = finalReadTime | round %}
|
||||
{% if number >= 1 %}
|
||||
{% assign yesReadTime = number | append: " minute read" %}
|
||||
<span class="reader-time post-meta"><span class="hidden-xs middot">·</span> {{ yesReadTime }}</span>
|
||||
{% elsif number < 1 %}
|
||||
{% assign minReadTime = '< 1 minute read' %}
|
||||
<span class="reader-time post-meta"><span class="hidden-xs middot">·</span> {{ minReadTime }}</span>
|
||||
{% else %}
|
||||
{% assign nilReadTime = number | replace:'0',' ' %}
|
||||
{{ nilReadTime }}
|
||||
{% endif %}
|
Loading…
Add table
Add a link
Reference in a new issue