new_page rake task now creates pages as page_name/index.[default_format] if no file extension is passed. By default this creates nicer urls
This commit is contained in:
parent
e027d82d17
commit
6006ac8a01
8
Rakefile
8
Rakefile
@ -82,9 +82,9 @@ task :new_page, :filename do |t, args|
|
|||||||
args.with_defaults(:filename => 'new-page')
|
args.with_defaults(:filename => 'new-page')
|
||||||
page_dir = source_dir
|
page_dir = source_dir
|
||||||
if args.filename =~ /(^.+\/)?(\w+)(\.)?(.+)?/
|
if args.filename =~ /(^.+\/)?(\w+)(\.)?(.+)?/
|
||||||
page_dir += "/#{$1}"
|
page_dir += $4 ? "/#{$1}" : "/#{$1}#{$2}/"
|
||||||
name = $2
|
name = $4 ? $2 : "index"
|
||||||
extension = $4 || new_page_ext
|
extension = $4 || "#{new_page_ext}"
|
||||||
filename = "#{name}.#{extension}"
|
filename = "#{name}.#{extension}"
|
||||||
mkdir_p page_dir
|
mkdir_p page_dir
|
||||||
file = page_dir + filename
|
file = page_dir + filename
|
||||||
@ -92,7 +92,7 @@ task :new_page, :filename do |t, args|
|
|||||||
open(file, 'w') do |page|
|
open(file, 'w') do |page|
|
||||||
page.puts "---"
|
page.puts "---"
|
||||||
page.puts "layout: page"
|
page.puts "layout: page"
|
||||||
page.puts "title: \"#{name.gsub(/[-_]/, ' ').titlecase}\""
|
page.puts "title: \"#{$2.gsub(/[-_]/, ' ').titlecase}\""
|
||||||
page.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
|
page.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
|
||||||
page.puts "comments: true"
|
page.puts "comments: true"
|
||||||
page.puts "sharing: true"
|
page.puts "sharing: true"
|
||||||
|
Loading…
Reference in New Issue
Block a user