Skip to content

Instantly share code, notes, and snippets.

@gam0022
Created December 7, 2014 03:54
Show Gist options
  • Save gam0022/dee78dd5c0d4294fee42 to your computer and use it in GitHub Desktop.
Save gam0022/dee78dd5c0d4294fee42 to your computer and use it in GitHub Desktop.
Octopressで最後に編集した記事だけをgenerate ref: http://qiita.com/gam0022/items/7b5a6e4492c90583706f
# usage rake generate_only[my-post]
# thanks to http://rcmdnk.github.io/blog/2013/12/06/blog-octopress-rake/
desc "Generate only the specified post (much faster)"
task :generate_only, :filename do |t, args|
if args.filename
filename = args.filename
else
filename = Dir.glob("#{source_dir}/#{posts_dir}/*.#{new_post_ext}").sort_by{|f| File.mtime(f)}.last
end
puts "## Test build for #{filename}"
puts "## Stashing other posts"
Rake::Task[:isolate].invoke(filename)
Rake::Task[:generate].execute
puts "## Restoring stashed posts"
Rake::Task[:integrate].execute
end
task go: :generate_only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment