From 05c8a73839a8f3dbf61ec41771d187c5330f8b8c Mon Sep 17 00:00:00 2001 From: foo-dogsquared Date: Sun, 28 Oct 2018 13:50:23 +0800 Subject: [PATCH] Improve WPM calculation (doesn't use JS for that anymore) --- _includes/addl-post-fns.html | 12 ------------ _includes/post_meta.html | 2 +- _layouts/home.html | 11 ----------- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/_includes/addl-post-fns.html b/_includes/addl-post-fns.html index f83c7b4..5ab0a65 100644 --- a/_includes/addl-post-fns.html +++ b/_includes/addl-post-fns.html @@ -53,20 +53,8 @@ }; } - function convert_to_wpm(number_of_words = document.querySelectorAll(".no-of-mins")) { - if (number_of_words === undefined) return null; - number_of_words.forEach((num) => { - const wpm = 225 /* avg wpm for an adult */ - const minutes = Math.round((Number(num.textContent) / wpm) + 1) - num.textContent = minutes; - return minutes; - }) - } - insertHeaderLink(); // insertCenterTags(); resourcesLink(); - convert_to_wpm(); - \ No newline at end of file diff --git a/_includes/post_meta.html b/_includes/post_meta.html index 1de3283..b8c19e3 100644 --- a/_includes/post_meta.html +++ b/_includes/post_meta.html @@ -8,7 +8,7 @@ - {{ page.content | number_of_words }} minutes + {{ page.content | number_of_words | divided_by: 225 }} minutes {%- if page.categories -%} diff --git a/_layouts/home.html b/_layouts/home.html index ebba6c2..ae85384 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -26,17 +26,6 @@ layout: default {%- include post_meta.html page=post include_link=true -%} {% endfor %} -