Sha256: 92681c0844d5e01fe9f7d858fbdbce9d98da037466a814dabcde0b7678bd0558
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
# Again largely inspired by http://brizzled.clapper.org/blog/2010/12/20/some-jekyll-hacks/ module Jekyll module RpLogs class TagIndex < Jekyll::Page def initialize(site, base, dir, tag, pages) @site = site @base = base @dir = dir @name = "index.html" process(@name) # Get tag_index filename tag_index = (site.config["rp_tag_index_layout"] || "tag_index") + ".html" read_yaml(File.join(base, "_layouts"), tag_index) data["tag"] = tag # Set which tag this index is for # Sort tagged RPs by their start date data["pages"] = pages.sort_by { |p| p.data["start_date"] } tag_title_prefix = site.config["rp_tag_title_prefix"] || "Tag: " data["title"] = "#{tag_title_prefix}#{tag.name}" end end class TagIndexGenerator < Jekyll::Generator safe true # Needs to run after RpLogGenerator priority :low def initialize(config) config["rp_tag_index"] ||= true config["rp_tag_dir"] ||= "/tags" end def generate(site) return unless site.config["rp_tag_index"] dir = site.config["rp_tag_dir"] tags = rps_by_tag(site) tags.each_pair { |tag, pages| site.pages << TagIndex.new(site, site.source, File.join(dir, tag.dir), tag, pages) } Jekyll.logger.info "#{tags.size} tag pages generated." end # Returns a hash of tags => [pages with tag] private def rps_by_tag(site) tag_ref = Hash.new { |hash, key| hash[key] = Set.new } site.collections[RpLogGenerator.rp_key].docs.each { |page| page.data["rp_tags"].each { |tag| tag_ref[tag] << page } } return tag_ref end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jekyll-rp_logs-0.3.1 | lib/jekyll/rp_logs/rp_tag_index.rb |
jekyll-rp_logs-0.3.0 | lib/jekyll/rp_logs/rp_tag_index.rb |