Skip to content

Commit

Permalink
Merge pull request #78 from LorenzoLeonardini/master
Browse files Browse the repository at this point in the history
Adding reading time feature (fixes #77)
  • Loading branch information
biomadeira authored Mar 14, 2019
2 parents 1c0673d + 6a1e163 commit d173135
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 6 deletions.
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ markdown: kramdown
highlighter: rouge
paginate: 100 # it will paginate after this number
language: 'en-uk'
words_per_minute: 200

# edit baseurl to simply '/' if using as your personal page (instead of a project page)
baseurl: /jasper2/
Expand Down
10 changes: 10 additions & 0 deletions _includes/post-card-error.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% assign words_per_minute = site.words_per_minute | default: 200 %}

{% assign count = 0 %}
{% for post in site.posts %}
{% assign count = count | plus: 1 %}
Expand Down Expand Up @@ -42,6 +44,14 @@ <h2 class="post-card-title">{{ post.title }}</h2>
</span>
{% endif %}
{% endfor %}
<span class="reading-time">
{% assign words = post.content | strip_html | number_of_words %}
{% if words <= words_per_minute %}
1 min read
{% else %}
{{ words | divided_by:words_per_minute }} min read
{% endif %}
</span>
</footer>
</div>
</article>
Expand Down
9 changes: 9 additions & 0 deletions _includes/post-card-next.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% assign words_per_minute = site.words_per_minute | default: 200 %}

<article class="post-card {{ page.next.class }}{% unless page.next.cover %} no-image{% endunless %}">
{% if page.next.cover %}
Expand Down Expand Up @@ -39,6 +40,14 @@ <h2 class="post-card-title">{{ page.next.title }}</h2>
</span>
{% endif %}
{% endfor %}
<span class="reading-time">
{% assign words = post.content | strip_html | number_of_words %}
{% if words <= words_per_minute %}
1 min read
{% else %}
{{ words | divided_by:words_per_minute }} min read
{% endif %}
</span>
</footer>
</div>
</article>
9 changes: 9 additions & 0 deletions _includes/post-card-previous.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% assign words_per_minute = site.words_per_minute | default: 200 %}

<article class="post-card {{ page.previous.class }}{% unless page.previous.cover %} no-image{% endunless %}">
{% if page.previous.cover %}
Expand Down Expand Up @@ -39,6 +40,14 @@ <h2 class="post-card-title">{{ page.previous.title }}</h2>
</span>
{% endif %}
{% endfor %}
<span class="reading-time">
{% assign words = post.content | strip_html | number_of_words %}
{% if words <= words_per_minute %}
1 min read
{% else %}
{{ words | divided_by:words_per_minute }} min read
{% endif %}
</span>
</footer>
</div>
</article>
10 changes: 10 additions & 0 deletions _includes/post-card.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% assign words_per_minute = site.words_per_minute | default: 200 %}

{% for post in paginator.posts %}
<article class="post-card {{ page.class }}{% unless post.cover %} no-image{% endunless %}">
{% if post.cover %}
Expand Down Expand Up @@ -39,6 +41,14 @@ <h2 class="post-card-title">{{ post.title }}</h2>
</span>
{% endif %}
{% endfor %}
<span class="reading-time">
{% assign words = post.content | strip_html | number_of_words %}
{% if words <= words_per_minute %}
1 min read
{% else %}
{{ words | divided_by:words_per_minute }} min read
{% endif %}
</span>
</footer>
</div>
</article>
Expand Down
2 changes: 1 addition & 1 deletion assets/built/global.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d173135

Please sign in to comment.