Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability for individual posts to set reading time #28

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions _posts/2013-10-27-set-time.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
layout: post
title: Set Reading Time
description: "How to set the amount of time."
tags: [sample post]
time: 5 minutes
categories: [intro]
---


## Code Snippets

You can override the default reading time calculation by manually setting it
within a specific post.

{% highlight yaml %}
time: 5 minutes
{% endhighlight %}
3 changes: 2 additions & 1 deletion _templates/post
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ modified:
categories: {{ dir }}
description:
tags: []
time: XX minutes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @ccjjmartin, thanks for this PR. I'd prefer to have the time empty by default. Can you update this line for time:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

image:
feature:
credit:
creditlink:
comments:
share:
---
---
15 changes: 10 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@
<div class="entry-meta">
<span class="entry-date date published updated"><time datetime="{{ post.date | date_to_xmlschema }}"><a href="{{ site.url }}{{ post.url }}">{{ post.date | date: "%B %d, %Y" }}</a></time></span><span class="author vcard"><span class="fn"><a href="{{ site.url }}/about/" title="About {{ site.owner.name }}">{{ site.owner.name }}</a></span></span>
{% if site.reading_time %}
<span class="entry-reading-time">
<i class="fa fa-clock-o"></i>
{% assign readtime = post.content | strip_html | number_of_words | divided_by:site.words_per_minute %}
Reading time ~{% if readtime <= 1 %}1 minute{% else %}{{ readtime }} minutes{% endif %}
</span><!-- /.entry-reading-time -->
<span class="entry-reading-time">
<i class="fa fa-clock-o"></i>
{% assign readtime = post.content | strip_html | number_of_words | divided_by:site.words_per_minute %}
Reading time ~
{% if post.time %}{{ post.time }}
{% elsif readtime <= 1 %}1 minute
{% else %}{{ readtime }} minutes
{% endif %}
</span>
<!-- /.entry-reading-time -->
{% endif %}
</div><!-- /.entry-meta -->
{% if post.link %}
Expand Down