Last active
December 16, 2015 03:49
-
-
Save rcmdnk/5372744 to your computer and use it in GitHub Desktop.
Rakefile for Octopress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Rakefile b/Rakefile | |
index 471b227..a092f76 100644 | |
--- a/Rakefile | |
+++ b/Rakefile | |
@@ -23,8 +23,8 @@ deploy_dir = "_deploy" # deploy directory (for Github pages deployment) | |
stash_dir = "_stash" # directory to stash posts for speedy generation | |
posts_dir = "_posts" # directory for blog files | |
themes_dir = ".themes" # directory for blog files | |
-new_post_ext = "markdown" # default new post file extension when using the new_post task | |
-new_page_ext = "markdown" # default new page file extension when using the new_page task | |
+new_post_ext = "md" # default new post file extension when using the new_post task | |
+new_page_ext = "md" # default new page file extension when using the new_page task | |
server_port = "4000" # port for preview server eg. localhost:4000 | |
@@ -98,6 +98,9 @@ task :new_post, :title do |t, args| | |
title = get_stdin("Enter a title for your post: ") | |
end | |
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir) | |
+ title_words = title.split(' ') | |
+ tags = title_words | |
+ category = tags.shift | |
mkdir_p "#{source_dir}/#{posts_dir}" | |
filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}" | |
if File.exist?(filename) | |
@@ -110,8 +113,20 @@ task :new_post, :title do |t, args| | |
post.puts "title: \"#{title.gsub(/&/,'&')}\"" | |
post.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}" | |
post.puts "comments: true" | |
- post.puts "categories: " | |
+ post.puts "category: #{category}" | |
+ post.puts "tags: #{tags}" | |
+ post.puts "keywords: #{title.gsub(' ',', ')}" | |
+ #post.puts "description: " | |
+ post.puts "published: false" | |
+ post.puts "" | |
post.puts "---" | |
+ post.puts "" | |
+ post.puts "<!-- more -->" | |
+ post.puts "" | |
+ post.puts "** Contents **" | |
+ post.puts "{:TOC}" | |
+ post.puts "" | |
+ post.puts "" | |
end | |
end | |
@@ -147,6 +162,7 @@ task :new_page, :filename do |t, args| | |
page.puts "comments: true" | |
page.puts "sharing: true" | |
page.puts "footer: true" | |
+ page.puts "published: false" | |
page.puts "---" | |
end | |
else |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rakefile for Octopress