Skip to content

Instantly share code, notes, and snippets.

@sharu725
Created August 19, 2017 07:33
Show Gist options
  • Save sharu725/d8c9566562166d6d1fd6f3f49972245e to your computer and use it in GitHub Desktop.
Save sharu725/d8c9566562166d6d1fd6f3f49972245e to your computer and use it in GitHub Desktop.
Reading Time in minutes for posts
<!--
Before using this Jekyll Snippet make sure you
1. don't care if your IDE shows tag errors
2. may have to add the words "Reading Time". Currently it uses an icon from https://github.com/danklammer/bytesize-icons
-->
<span class="read-time" title="Estimated read time">
<svg id="i-clock" viewBox="0 0 32 32" width="20" height="20" fill="none" stroke="currentcolor" stroke-linecap="round"
stroke-linejoin="round" stroke-width="2"><circle cx="16" cy="16" r="14" /><path d="M16 8 L16 16 20 20" /></svg>
{% assign words = content | number_of_words %}
{% if words < 360 %}
1 min read.
{% else %}
{{ words | divided_by:180 }} mins read.
{% endif %}
</span>
<style>
svg#i-clock {vertical-align: middle;}
</style>
@techlanka
Copy link

techlanka commented Nov 4, 2018

Hi @sharu725, How do i add this to my jekyll jasper2 theme?? I'm quite new here to programming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment