Sha256: d4502079c8e3b36d1379365a3b4f7b69d0ef416b7534df7212310d95ff404f2c
Contents?: true
Size: 731 Bytes
Versions: 5
Compression:
Stored size: 731 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.attribute("id")) 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
5 entries across 5 versions & 1 rubygems