Skip to content
Permalink
Browse files

add read time

  • Loading branch information...
deepu105 committed Jul 18, 2019
1 parent 73808a8 commit 4e06234c30b61569b0e859d0136f92437eca49c4
@@ -10,13 +10,6 @@ source "https://rubygems.org"
# Happy Jekylling!
gem "jekyll", "~> 3.8.6"

# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
# bundle exec jekyll serve
#

# If you have any plugins, put them here!
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
group :jekyll_plugins do
@@ -43,7 +43,7 @@ <h4 class="card-text">{{ post.excerpt | strip_html | truncatewords:25 }}</h4>
<span class="author-meta">
<span class="post-name"><a target="_blank" href="{{ author.web }}">{{ author.display_name }}</a></span><br/>
{% endif %}
<span class="post-date">{{ post.date | date_to_string }}</span>
<span class="post-date">{{ post.date | date_to_string }} | {{ post.content | reading_time }}</span>
</span>
<span class="post-read-more"><a href="{{ site.baseurl }}{{ post.url }}" title="Read Story"><svg class="svgIcon-use" width="25" height="25" viewbox="0 0 25 25"><path d="M19 6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v14.66h.012c.01.103.045.204.12.285a.5.5 0 0 0 .706.03L12.5 16.85l5.662 4.126a.508.508 0 0 0 .708-.03.5.5 0 0 0 .118-.285H19V6zm-6.838 9.97L7 19.636V6c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v13.637l-5.162-3.668a.49.49 0 0 0-.676 0z" fill-rule="evenodd"></path></svg></a></span>
<div class="clearfix"></div>
@@ -40,7 +40,7 @@ <h4 class="card-text">{{ post.excerpt | strip_html | truncatewords:30 }}</h4>
<span class="author-meta">
<span class="post-name"><a target="_blank" href="{{ author.web }}">{{ author.display_name }}</a></span><br/>
{% endif %}
<span class="post-date">{{ post.date | date_to_string }}</span>
<span class="post-date">{{ post.date | date_to_string }} | {{ post.content | reading_time }}</span>
</span>
<span class="post-read-more"><a href="{{ site.baseurl }}{{ post.url }}" title="Read Story"><svg class="svgIcon-use" width="25" height="25" viewbox="0 0 25 25"><path d="M19 6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v14.66h.012c.01.103.045.204.12.285a.5.5 0 0 0 .706.03L12.5 16.85l5.662 4.126a.508.508 0 0 0 .708-.03.5.5 0 0 0 .118-.285H19V6zm-6.838 9.97L7 19.636V6c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v13.637l-5.162-3.668a.49.49 0 0 0-.676 0z" fill-rule="evenodd"></path></svg></a></span>
<div class="clearfix"></div>
@@ -31,4 +31,5 @@
</li>
</ul>
{% endif %}

</div>
@@ -42,6 +42,16 @@ <h1 class="sitetitle">{{ site.name }}</h1>
<div class="col-xs-12 col-md-9 col-lg-10 text-center text-md-left">
<a target="_blank" class="link-dark" href="{{ author.web }}">{{ author.display_name }}</a><a target="_blank" href="{{ author.twitter }}" class="btn follow">Follow</a>
<span class="author-description">{{ author.description }}</span>
<!-- Post Date -->
<span class="author-description">
<small>
<time class="post-date" datetime="{{ page.date | date:"%Y-%m-%d" }}">{{ page.date | date_to_string }}</time>
{% if page.last_modified_at %}
(Updated: <time datetime="{{ page.last_modified_at | date_to_xmlschema }}" itemprop="dateModified">{{ page.last_modified_at | date: "%b %-d, %Y" }}</time>)
{% endif %}
</small> |
<small>{{ page.content | reading_time }}</small>
</span>
</div>
</div>
{% endif %}
@@ -112,15 +122,6 @@ <h3 class="font-weight-bold">Summary</h3>
</div>
{% endif %}

<!-- Post Date -->
<p>
<small>
<span class="post-date"><time class="post-date" datetime="{{ page.date | date:"%Y-%m-%d" }}">{{ page.date | date_to_string }}</time></span>
{% if page.last_modified_at %}
(Updated: <time datetime="{{ page.last_modified_at | date_to_xmlschema }}" itemprop="dateModified">{{ page.last_modified_at | date: "%b %-d, %Y" }}</time>)
{% endif %}
</small>
</p>

<!-- Post Categories -->
<div class="after-post-cats">
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,20 @@
# Read this in "about 4 minutes"
# Usage: Read this in {{ page.content | reading_time }}

WORD_PER_MINUTE = 180

def calculate_time( input )
words = input.split.size;
minutes = ( words / WORD_PER_MINUTE ).floor
minutes_label = minutes == 1 ? "min" : "mins"
return minutes, minutes_label
end

module ReadingTimeFilter
def reading_time( input )
minutes, minutes_label = calculate_time(input)
minutes > 0 ? "#{minutes} #{minutes_label} read" : "Less than 1 min read"
end

Liquid::Template.register_filter(ReadingTimeFilter)
end
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 4e06234

Please sign in to comment.
You can’t perform that action at this time.