# Save the file with the title in the YAML front matter
def write_file(content, title, directory, filename)
parsed_content = "#{content.sub("title:", "title: \"#{title}\"")}"
- parsed_content = "#{parsed_content.sub("date:", "date: #{POST_TIME}")}"
+ parsed_content = "#{parsed_content.sub("date:", "date: '#{POST_TIME}'")}"
File.write("#{directory}/#{filename}", parsed_content)
puts "#{filename} was created in '#{directory}'."
end
template = CONFIG["post"]["template"]
extension = CONFIG["post"]["extension"]
editor = CONFIG["editor"]
- check_title(:title)
- filename = "#{DATE}-#{transform_to_slug(:title, extension)}"
+ check_title(args.title)
+ filename = "#{DATE}-#{transform_to_slug(args.title, extension)}"
content = read_file(template)
- create_file(POSTS, filename, content, :title, editor)
+ create_file(POSTS, filename, content, args.title, editor)
end
# rake draft["Title"]