1
0
mirror of https://github.com/TeamNewPipe/website synced 2025-10-06 00:22:38 +02:00

Handle one minute reading time differently

Improve file formatting
This commit is contained in:
Tobias Groza
2020-12-16 21:58:55 +01:00
committed by GitHub
parent aace48bca9
commit f76733dde8

View File

@@ -1,11 +1,22 @@
{% comment %}
{%- comment -%}
inspired by https://raw.githubusercontent.com/jhvanderschee/jekyllcodex/gh-pages/_includes/reading-time.html -- thanks!
{% endcomment %}
{%- endcomment -%}
<i class="fa fa-clock-o"></i>
{% capture words %}
{{ content | number_of_words | minus: 180 }}
{% endcapture %}
{% unless words contains '-' %}
{{ words | plus: 150 | divided_by: 150 | append: ' minute(s)' }}
{% endunless %}
{% capture words -%}
{{ content | number_of_words | minus: 180 }}
{%- endcapture -%}
{%- if words contains '-' -%}
{%- assign reading_time = '1' -%}
{%- else -%}
{%- capture reading_time -%}
{{ words | plus: 150 | divided_by: 150 }}
{%- endcapture -%}
{%- endif -%}
{%- if reading_time == '1' -%}
{{ reading_time | append: ' minute' }}
{%- else -%}
{{ reading_time | append: ' minutes' }}
{%- endif -%}