class JekyllPost

Public Class Methods

new(path, post) click to toggle source
# 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

Public Instance Methods

savePageFile() click to toggle source
# 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