Skip to content

Instantly share code, notes, and snippets.

@dhfromkorea
Created July 6, 2019 05:42
Show Gist options
  • Save dhfromkorea/ff0d5d95fc443d527b470a8b02c8a68c to your computer and use it in GitHub Desktop.
Save dhfromkorea/ff0d5d95fc443d527b470a8b02c8a68c to your computer and use it in GitHub Desktop.
A quick fix for Octopress 2 that prevents drafts from being deployed. Preview still possible.
desc "Default deploy task"
task :deploy do
# Check if preview posts exist, which should not be published
if File.exists?(".preview-mode")
puts "## Found posts in preview mode, regenerating files ..."
File.delete(".preview-mode")
Rake::Task[:generate].execute
end
Rake::Task[:copydot].invoke(source_dir, public_dir)
# exclude drafts in public/ before deployment
# we compare each post in source/_drafts/ against one in public/
Dir.foreach("#{args.source}/_drafts") do |item|
file_ext = File.extname(item)
puts "draft file candidate: #{file_ext}"
if file_ext == ".markdown" or file_ext == ".md"
file_base = File.basename(item, file_ext)
puts "removing a draft: #{public_dir}/#{file_base}"
rm_rf("#{public_dir}/#{file_base}")
end
end
Rake::Task["#{deploy_default}"].execute
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment