diff options
Diffstat (limited to '_plugins/tags.rb')
-rw-r--r-- | _plugins/tags.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/_plugins/tags.rb b/_plugins/tags.rb new file mode 100644 index 0000000..63c800c --- /dev/null +++ b/_plugins/tags.rb @@ -0,0 +1,26 @@ +module Jekyll + class TagPageGenerator < Generator + safe true + + def generate(site) + tags = site.posts.docs.flat_map { |post| post.data['tags'] || [] }.to_set + tags.each do |tag| + site.pages << TagPage.new(site, site.source, tag) + end + end + end + + class TagPage < Page + def initialize(site, base, tag) + @site = site + @base = base + @dir = File.join('tag', tag) + @name = 'index.html' + + self.process(@name) + self.read_yaml(File.join(base, '_layouts'), 'tag.html') + self.data['tag'] = tag + self.data['title'] = "Tag: #{tag}" + end + end +end
\ No newline at end of file |