2023-05-06 02:22:29 +03:00
|
|
|
<!-- Calculate the post's reading time, and display the word count in tooltip -->
|
2021-07-20 20:01:09 +03:00
|
|
|
|
2023-05-06 02:22:29 +03:00
|
|
|
{% assign words = include.content | strip_html | number_of_words: 'auto' %}
|
2020-12-17 10:17:21 +03:00
|
|
|
|
2023-05-06 02:22:29 +03:00
|
|
|
<!-- words per minute -->
|
2021-07-20 20:01:09 +03:00
|
|
|
|
2021-01-23 22:02:19 +03:00
|
|
|
{% 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 %}
|
|
|
|
|
2021-07-20 20:01:09 +03:00
|
|
|
{% capture read_prompt %}
|
2023-05-06 02:22:29 +03:00
|
|
|
{{- site.data.locales[include.lang].post.read_time.prompt -}}
|
2021-07-20 20:01:09 +03:00
|
|
|
{% endcapture %}
|
|
|
|
|
2020-12-17 10:17:21 +03:00
|
|
|
<!-- return element -->
|
2023-05-06 02:22:29 +03:00
|
|
|
<span
|
|
|
|
class="readtime"
|
2023-04-10 05:54:27 +03:00
|
|
|
data-bs-toggle="tooltip"
|
|
|
|
data-bs-placement="bottom"
|
2023-05-06 02:22:29 +03:00
|
|
|
title="{{ words }} {{ site.data.locales[include.lang].post.words }}"
|
|
|
|
>
|
|
|
|
<em>
|
|
|
|
{{- read_time -}}
|
|
|
|
{{ ' ' }}
|
|
|
|
{{- site.data.locales[include.lang].post.read_time.unit -}}
|
|
|
|
</em>
|
2021-07-20 20:01:09 +03:00
|
|
|
{%- if include.prompt -%}
|
2021-12-04 01:56:33 +03:00
|
|
|
{%- assign _prompt_words = read_prompt | number_of_words: 'auto' -%}
|
2023-05-06 02:22:29 +03:00
|
|
|
{%- unless _prompt_words > 1 -%}{{ ' ' }}{%- endunless -%}
|
|
|
|
{{ read_prompt }}
|
2021-07-20 20:01:09 +03:00
|
|
|
{%- endif -%}
|
2020-12-17 10:17:21 +03:00
|
|
|
</span>
|