feat: sitemap
feat: reading time
This commit is contained in:
18
_plugins/reading_time.rb
Normal file
18
_plugins/reading_time.rb
Normal file
@ -0,0 +1,18 @@
|
||||
# Outputs the reading time
|
||||
|
||||
# Read this in “about 4 minutes”
|
||||
# Put into your _plugins dir in your Jekyll site
|
||||
# Usage: Read this in about {{ page.content | reading_time }}
|
||||
|
||||
module ReadingTimeFilter
|
||||
def reading_time( input )
|
||||
words_per_minute = 180
|
||||
|
||||
words = input.split.size;
|
||||
minutes = ( words / words_per_minute ).floor
|
||||
minutes_label = minutes === 1 ? " minute" : " minutes"
|
||||
minutes > 0 ? "#{minutes} #{minutes_label}" : "less than 1 minute"
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_filter(ReadingTimeFilter)
|
Reference in New Issue
Block a user