mirror of
https://github.com/foo-dogsquared/website.git
synced 2025-02-07 09:19:00 +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();
|
||||
// insertCenterTags();
|
||||
resourcesLink();
|
||||
|
||||
convert_to_wpm();
|
||||
|
||||
</script>
|
@ -8,7 +8,7 @@
|
||||
</time>
|
||||
|
||||
<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>
|
||||
|
||||
{%- if page.categories -%}
|
||||
|
@ -26,17 +26,6 @@ layout: default
|
||||
{%- include post_meta.html page=post include_link=true -%}
|
||||
</div>
|
||||
{% 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 -->
|
||||
<div class="pagination">
|
||||
|
Loading…
Reference in New Issue
Block a user