class WP2Middleman::Frontmatter

Attributes

include_fields[R]
post[R]

Public Class Methods

new(post, include_fields: []) click to toggle source
# File lib/wp2middleman/frontmatter.rb, line 5
def initialize(post, include_fields: [])
  @post = post
  @include_fields = include_fields
end

Public Instance Methods

post_data() click to toggle source
# File lib/wp2middleman/frontmatter.rb, line 10
def post_data
  data = {
    'title' => post.title,
    'date' => post.date_time_published,
    'tags' => post.tags
  }

  data['published'] = false if !post.published?

  include_fields.each do |field|
    data[field] = post.field(field)
  end

  data
end
to_yaml() click to toggle source
# File lib/wp2middleman/frontmatter.rb, line 26
def to_yaml
  post_data.to_yaml.strip
end