mirror of
https://github.com/foo-dogsquared/website.git
synced 2025-02-07 12:19:36 +00:00
Improve WPM calculation (doesn't use JS for that anymore)
This commit is contained in:
parent
1cd3f90102
commit
05c8a73839
@ -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();
|
insertHeaderLink();
|
||||||
// insertCenterTags();
|
// insertCenterTags();
|
||||||
resourcesLink();
|
resourcesLink();
|
||||||
|
|
||||||
convert_to_wpm();
|
|
||||||
|
|
||||||
</script>
|
</script>
|
@ -8,7 +8,7 @@
|
|||||||
</time>
|
</time>
|
||||||
|
|
||||||
<span class="reading-minutes" style="margin-left: 1.25em">
|
<span class="reading-minutes" style="margin-left: 1.25em">
|
||||||
<img src="{{ 'assets/main/icons/time-clock.svg' | relative_url }}" class="post-meta-icons"><span class="no-of-mins">{{ page.content | number_of_words }}</span> minutes
|
<img src="{{ 'assets/main/icons/time-clock.svg' | relative_url }}" class="post-meta-icons"><span class="no-of-mins">{{ page.content | number_of_words | divided_by: 225 }}</span> minutes
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{%- if page.categories -%}
|
{%- if page.categories -%}
|
||||||
|
@ -26,17 +26,6 @@ layout: default
|
|||||||
{%- include post_meta.html page=post include_link=true -%}
|
{%- include post_meta.html page=post include_link=true -%}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<script>
|
|
||||||
function convert_to_wpm(number_of_words = document.querySelectorAll(".no-of-mins")) {
|
|
||||||
number_of_words.forEach((num) => {
|
|
||||||
const wpm = 225 /* avg wpm for an adult */
|
|
||||||
num.textContent = Math.round((Number(num.textContent) / wpm) + 1);
|
|
||||||
return;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
convert_to_wpm();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- Pagination links -->
|
<!-- Pagination links -->
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
|
Loading…
Reference in New Issue
Block a user