Undefined word_per_minutes parameter division by zero
If the parameter words_per_minute at _config.yml is not defined and the template says that must show read_time then will be divide a number by zero, a fix is verify that parameter and show a message when this is empty or zero. already localized for spanish
This commit is contained in:
parent
1510947bf6
commit
01cfcf0f3b
2 changed files with 13 additions and 5 deletions
|
@ -27,6 +27,7 @@ en: &DEFAULT_EN
|
|||
website_label : "Website"
|
||||
email_label : "Email"
|
||||
recent_posts : "Recent Posts"
|
||||
undefined_wpm : "Undefined parameter words_per_minute at _config.yml"
|
||||
en-US:
|
||||
<<: *DEFAULT_EN
|
||||
en-UK:
|
||||
|
@ -59,6 +60,7 @@ es: &DEFAULT_ES
|
|||
website_label : "Sitio web"
|
||||
email_label : "Email"
|
||||
recent_posts : "Entradas recientes"
|
||||
undefined_wpm : "Parametro words_per_minute (Palabras por minuto) no definido en _config.yml"
|
||||
es-ES:
|
||||
<<: *DEFAULT_ES
|
||||
es-CO:
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
|
||||
|
||||
{% if post.read_time %}
|
||||
{% assign words = post.content | strip_html | number_of_words %}
|
||||
{% elsif page.read_time %}
|
||||
{% assign words = page.content | strip_html | number_of_words %}
|
||||
{% endif %}
|
||||
|
||||
{% if words < 180 %}
|
||||
{{ site.data.ui-text[site.locale].less_than }} 1 {{ site.data.ui-text[site.locale].minute_read }}
|
||||
{% elsif words < 360 %}
|
||||
1 {{ site.data.ui-text[site.locale].minute_read }}
|
||||
{% if site.words_per_minute %}
|
||||
{% if words < 180 %}
|
||||
{{ site.data.ui-text[site.locale].less_than }} 1 {{ site.data.ui-text[site.locale].minute_read }}
|
||||
{% elsif words < 360 %}
|
||||
1 {{ site.data.ui-text[site.locale].minute_read }}
|
||||
{% else %}
|
||||
{{ words | divided_by:site.words_per_minute }} {{ site.data.ui-text[site.locale].minutes_read }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ words | divided_by:site.words_per_minute }} {{ site.data.ui-text[site.locale].minutes_read }}
|
||||
{{ site.data.ui-text[site.locale].undefined_words_per_minute }}
|
||||
{% endif %}
|
Loading…
Reference in a new issue