Class: Zine::Tag
- Inherits:
-
Object
- Object
- Zine::Tag
- Defined in:
- lib/zine/tag.rb
Overview
Posts’ tags
Instance Method Summary collapse
-
#initialize(tags_by_post, tag_templates, tag_index_templates, options) ⇒ Tag
constructor
A new instance of Tag.
- #write_tags ⇒ Object
Constructor Details
#initialize(tags_by_post, tag_templates, tag_index_templates, options) ⇒ Tag
Returns a new instance of Tag.
8 9 10 11 12 13 14 15 |
# File 'lib/zine/tag.rb', line 8 def initialize(, tag_templates, tag_index_templates, ) @options = @posts_by_tag = @templates = { tag: tag_templates, tag_index: tag_index_templates } @tag_dir = File.join @options['directories']['build'], 'tags' FileUtils.remove_dir @tag_dir, force: true FileUtils.mkdir_p @tag_dir end |
Instance Method Details
#write_tags ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/zine/tag.rb', line 17 def @posts_by_tag.each do |tag_name, struct_array| sorted_array = struct_array data = { name: tag_name, title: "Tags: #{tag_name}", post_array: sorted_array, build_dir: @tag_dir } tag_page = Zine::DataPage.new(data, @templates[:tag], @options) tag_page.write end write_tag_index end |