Sha256: 04622a1ce27878fa4f0887dfa23f9a1cbce9c56514256881818583a862e79b1e

Contents?: true

Size: 946 Bytes

Versions: 2

Compression:

Stored size: 946 Bytes

Contents

module Jekyll

  class TagPage < Page
    def initialize(site, base, dir, tag)
      @site = site
      @base = base
      @dir = dir
      @name = 'index.html'

      self.process(@name)
      self.read_yaml(File.join(base, '_layouts'), 'tag_index.html')
      self.data['tag'] = tag

      tag_title_prefix = site.config['tag_title_prefix'] || 'Tag: '
      self.data['title'] = "#{tag_title_prefix}#{tag}"
    end
  end

  class TagPageGenerator < Generator
    safe true

    def generate(site)
      if site.layouts.key? 'tag_index'
        dir = site.config['tag_dir'] || 'tags'
        site.tags.keys.each do |tag|
          tag = tag.to_s
          site.pages << TagPage.new(site, site.source, File.join(dir, tag), tag)
        end
      end
    end
  end

  class TagList < Liquid::Tag
    def render(context)
      context.registers[:site].tags.keys.sort
    end
  end
  
end

Liquid::Template.register_tag("tag_list", Jekyll::TagList)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
drink_up_doctor-0.4.0 bootstrap-boilerplate/_plugins/tag_index.rb
drink_up_doctor-0.3.1 bootstrap-boilerplate/_plugins/tag_index.rb