forked from daattali/beautiful-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code that calculates estimated read time
- Loading branch information
1 parent
3516935
commit 98386a5
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!--- "ReadTime on GitHub Jekyll" (c) 2020 Ruby Griffith Ramirez, MIT License --> | ||
|
||
{% assign ReadTime = page.content | strip_html | number_of_words %} | ||
{% assign calcReadTime = ReadTime | float %} | ||
{% assign finalReadTime = calcReadTime | divided_by:200 | round: 2 %} | ||
{% assign number = finalReadTime | round %} | ||
{% if number >= 1 %} | ||
{% assign yesReadTime = number | append: " minute read" %} | ||
· {{ yesReadTime }} | ||
{% elsif number < 1 %} | ||
{% assign minReadTime = '< 1 minute read' %} | ||
· {{ minReadTime }} | ||
{% else %} | ||
{% assign nilReadTime = number | replace:'0',' ' %} | ||
{{ nilReadTime }} | ||
{% endif %} |