Skip to content

Instantly share code, notes, and snippets.

@tohuw
Forked from zachleat/reading_time.rb
Last active August 15, 2018 17:01
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tohuw/cbcc8653321b9a3fb230 to your computer and use it in GitHub Desktop.
Save tohuw/cbcc8653321b9a3fb230 to your computer and use it in GitHub Desktop.
# jekyll-readtime
# 2015 Ron Scott-Adams, Licensed under MIT:
# https://tldrlegal.com/license/mit-license
# Original work: https://gist.github.com/zachleat/5792681
# Outputs the estimated time the average person might take to read the content.
# 200 is a round figure based on estimates gathered from various studies.
# http://www.ncbi.nlm.nih.gov/pubmed/18802819
# Usage: {{ page.content | readtime }}
# Will emit as an integer.
module ReadTime
def readtime(input)
words_per_minute = 200
words = input.split.size
readtime = (words / words_per_minute).floor
readtime
end
end
Liquid::Template.register_filter(ReadTime)
@tohuw
Copy link
Author

tohuw commented Feb 22, 2015

@Mimarik
Copy link

Mimarik commented Apr 7, 2015

Super!

Copy link

ghost commented Dec 31, 2015

👍

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