Sha256: 259e7df9b06ef84cc03c47347905c53f57fcab6b545eb9522b444d6f0371833b
Contents?: true
Size: 726 Bytes
Versions: 3
Compression:
Stored size: 726 Bytes
Contents
module DayLister require 'nokogiri' require 'date' require 'jekyll' class DayListTag < Liquid::Tag def initialize(tag_name, url, tokens) super end def render(context) # current directory postlist = context.registers[:site].posts.docs result = "{\n" postlist.each do |post| doc = Nokogiri::HTML::DocumentFragment.parse(post.content) doc.search('h3').each do |header| if dt = DateTime.parse(header.text.strip) rescue false result += (dt + Rational(12, 24)).strftime('%s') + ": 4,\n" end end end result += "}" result end end end Liquid::Template.register_tag('listdays', DayLister::DayListTag)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
jekyll-lab-notebook-plugins-0.1.2 | lib/count_days.rb |
jekyll-lab-notebook-plugins-0.1.1 | lib/count_days.rb |
jekyll-lab-notebook-plugins-0.1.0 | lib/count_days.rb |