2020-12-17 10:17:21 +03:00
|
|
|
<!--
|
|
|
|
Calculate the post's reading time, and display the word count in tooltip
|
|
|
|
-->
|
|
|
|
{% assign words = include.content | strip_html | number_of_words: "auto" %}
|
|
|
|
|
2021-01-23 22:02:19 +03:00
|
|
|
<!-- words per minute -->
|
|
|
|
{% assign wpm = 180 %}
|
|
|
|
{% assign min_time = 1 %}
|
|
|
|
|
|
|
|
{% assign read_time = words | divided_by: wpm %}
|
2020-12-17 10:17:21 +03:00
|
|
|
|
|
|
|
{% unless read_time > 0 %}
|
2021-01-23 22:02:19 +03:00
|
|
|
{% assign read_time = min_time %}
|
2020-12-17 10:17:21 +03:00
|
|
|
{% endunless %}
|
|
|
|
|
|
|
|
<!-- return element -->
|
|
|
|
<span class="readtime" data-toggle="tooltip" data-placement="bottom" title="{{ words }} words">
|
2021-01-23 22:02:19 +03:00
|
|
|
{{- read_time -}}{{" "}}{{- site.data.label.read_time_unit | default: "min" -}}
|
2020-12-17 10:17:21 +03:00
|
|
|
</span>
|