From f9e36767c2a5a3449b4c4e1c64e7fa8fd5040821 Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Fri, 18 Nov 2016 12:22:40 -0500 Subject: [PATCH] Set default value for `words_per_minute` - Close #657 --- _includes/read-time.html | 16 +++++++--------- docs/_includes/read-time.html | 16 +++++++--------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/_includes/read-time.html b/_includes/read-time.html index a45043c1..e8e9063d 100644 --- a/_includes/read-time.html +++ b/_includes/read-time.html @@ -1,17 +1,15 @@ +{% assign words_per_minute = site.words_per_minute | default: 200 %} + {% 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 site.words_per_minute %} - {% if words < 180 %} - {{ site.data.ui-text[site.locale].less_than | default: "less than" }} 1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} - {% elsif words < 360 %} - 1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} - {% else %} - {{ words | divided_by:site.words_per_minute }} {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} - {% endif %} +{% if words < 180 %} + {{ site.data.ui-text[site.locale].less_than | default: "less than" }} 1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} +{% elsif words < 360 %} + 1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} {% else %} - {{ site.data.ui-text[site.locale].undefined_wpm | "Undefined parameter words_per_minute at _config.yml" }} + {{ words | divided_by:words_per_minute }} {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} {% endif %} \ No newline at end of file diff --git a/docs/_includes/read-time.html b/docs/_includes/read-time.html index a45043c1..e8e9063d 100644 --- a/docs/_includes/read-time.html +++ b/docs/_includes/read-time.html @@ -1,17 +1,15 @@ +{% assign words_per_minute = site.words_per_minute | default: 200 %} + {% 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 site.words_per_minute %} - {% if words < 180 %} - {{ site.data.ui-text[site.locale].less_than | default: "less than" }} 1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} - {% elsif words < 360 %} - 1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} - {% else %} - {{ words | divided_by:site.words_per_minute }} {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} - {% endif %} +{% if words < 180 %} + {{ site.data.ui-text[site.locale].less_than | default: "less than" }} 1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} +{% elsif words < 360 %} + 1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} {% else %} - {{ site.data.ui-text[site.locale].undefined_wpm | "Undefined parameter words_per_minute at _config.yml" }} + {{ words | divided_by:words_per_minute }} {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} {% endif %} \ No newline at end of file