diff options
author | ronv <ronalds.vilcins@gmail.com> | 2020-01-30 20:19:33 +0200 |
---|---|---|
committer | ronv <ronalds.vilcins@gmail.com> | 2020-01-30 20:19:33 +0200 |
commit | a1a0a4ad553f59906930d44bf56b089421d2c7a5 (patch) | |
tree | ca8b44675434a07394c63a4b0bb22390ed261589 /_plugins | |
parent | bc7896a33321ad0c6e22ad60f20e498f55900c12 (diff) | |
download | wiki-a1a0a4ad553f59906930d44bf56b089421d2c7a5.tar.gz |
initial commit
Diffstat (limited to '_plugins')
-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 |