Class: JekyllPost
- Inherits:
-
Object
- Object
- JekyllPost
- Defined in:
- lib/code/JekyllPost.rb
Instance Method Summary collapse
-
#initialize(path, post) ⇒ JekyllPost
constructor
A new instance of JekyllPost.
- #savePageFile ⇒ Object
Constructor Details
#initialize(path, post) ⇒ JekyllPost
Returns a new instance of JekyllPost.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/code/JekyllPost.rb', line 19 def initialize(path, post) @post = post @file_path = path + '/' + @post['date']+'-'+@post['slug']+'.md' @yaml_parsed = { 'layout' => 'post', 'title' => post['title'], 'meta_title' => post['meta_title'], 'meta_description' => post['meta_description'], 'date' => post['date'], 'excerpt' => post['excerpt'], 'categories' => post['categories'], 'source' => post['source'], } if post.key?("taxonomy") @yaml_parsed['taxonomy'] = post['taxonomy'] end if post['image'] @yaml_parsed['image_title'] = post['image_title'] @yaml_parsed['image_alt'] = post['image_alt'] post['image'].each do |key, value| post['image'][key] = 'images/posts/' + value end @yaml_parsed['image'] = post['image'] end @content_section = post['content'] end |
Instance Method Details
#savePageFile ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/code/JekyllPost.rb', line 11 def savePageFile file_contents = @yaml_parsed.to_yaml file_contents += '---'+"\n" file_contents += @content_section ZeroFetcher.writeFile(@file_path, file_contents) end |