Sha256: 7e60343b42c74eeeff2773efafa2fdffbe7f3d509e79075740492473dd6a90f3

Contents?: true

Size: 540 Bytes

Versions: 1

Compression:

Stored size: 540 Bytes

Contents

require 'rubygems'
require 'optparse'
require 'yaml'

desc "create new post with textmate"
task :np do
  OptionParser.new.parse!
  ARGV.shift
  title = ARGV.join(' ')

  path = "../config/jekyll/_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.markdown"
  
  if File.exist?(path)
  	puts "[WARN] File exists - skipping create"
  else
    File.open(path, "w") do |file|
      file.puts YAML.dump({'layout' => 'post', 'published' => false, 'title' => title})
      file.puts "---"
    end
  end
  `mate #{path}`

  exit 1
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bloggy-0.0.8 lib/generators/jekyll/blog/templates/config/jekyll/tasks/new_post.rake