File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,30 @@ task :post do
32
32
end
33
33
end # task :post
34
34
35
+ # Usage: rake page name="about.html"
36
+ # You can also specify a sub-directory path.
37
+ # If you don't specify a file extention we create an index.html at the path specified
38
+ desc "Create a new page."
39
+ task :page do
40
+ name = ENV [ "name" ] || "new-page.md"
41
+ filename = File . join ( SOURCE , "#{ name } " )
42
+ filename = File . join ( filename , "index.html" ) if File . extname ( filename ) == ""
43
+ title = File . basename ( filename , File . extname ( filename ) ) . gsub ( /[\W \_ ]/ , " " ) . gsub ( /\b \w / ) { $&. upcase }
44
+ if File . exist? ( filename )
45
+ abort ( "rake aborted!" ) if ask ( "#{ filename } already exists. Do you want to overwrite?" , [ 'y' , 'n' ] ) == 'n'
46
+ end
47
+
48
+ mkdir_p File . dirname ( filename )
49
+ puts "Creating new page: #{ filename } "
50
+ open ( filename , 'w' ) do |post |
51
+ post . puts "---"
52
+ post . puts "layout: page"
53
+ post . puts "title: \" #{ title } \" "
54
+ post . puts "---"
55
+ post . puts "{% include JB/setup %}"
56
+ end
57
+ end # task :page
58
+
35
59
desc "Switch between Jekyll-bootstrap themes."
36
60
task :switch_theme , :theme do |t , args |
37
61
theme_path = File . join ( CONFIG [ 'themes' ] , args . theme )
You can’t perform that action at this time.
0 commit comments