Skip to content

πŸ“– Jekyll plugin for displaying reading time duration.

License

Notifications You must be signed in to change notification settings

risan/jekyll-reading-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Jekyll Reading Time

A simple Jekyll plugin for displaying a reading time duration. It can either be a content from a post, a page, or a string.

Heavily inspired by this gist: zachleat/reading_time.rb.

Installation

Simply download the reading_time_filter.rb file and store it within the _plugins directory on your Jekyll installation.

Using Git

You can also use git to download the plugin:

$ git clone https://github.com/risan/jekyll-reading-time.git /path/to/_plugins

Or if you prefer to use ssh:

$ git clone git@github.com:risan/jekyll-reading-time.git /path/to/_plugins

Configuration

By default, this plugin will use the following suffixes as a time duration:

  • seconds: Plural form for second
  • minute: Singular form for minute
  • minutes: Plural form for minutes

You can override these suffixes by adding the reading_time directive to your _config.yml file:

reading_time:
  second_plural: "sec"    # default: seconds
  minute_singular: "min"  # default: minute
  minute_plural: "min"    # default: minutes

Usage

This plugin registers a new Liquid filter that you can use to calculate the reading time duration. You can pass the content of a post, a page, or a string.

{{ content | reading_time }}

{{ "Lorem ipsum dolor" | reading_time }}

Here's another example. Let's say you want to display all posts' title along with the reading time:

<ul>
  {% for post in site.posts %}
    <li>
      <span>{{ post.title }}</span>
      <span>{{ post.content | reading_time }}</span>
    </li>
  {% endfor %}
</ul>

License

MIT Β© Risan Bagja Pradana

About

πŸ“– Jekyll plugin for displaying reading time duration.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages