1
0
mirror of https://github.com/kremalicious/blog.git synced 2025-02-14 21:10:25 +01:00

add date to rake task for new posts

This commit is contained in:
Matthias Kretschmann 2015-08-02 21:58:40 +02:00
parent 413f86856d
commit e3c628aa17

View File

@ -14,10 +14,17 @@ task :post do
path = "_src/_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md"
if File.exist?(path)
puts "Dude, file exists - skipping create"
puts "Dude, file exists - skipping create"
else
File.open(path, "w") do |file|
file.puts YAML.dump({'layout' => 'post', 'published' => false, 'title' => title, 'author' => 'Matthias Kretschmann'})
file.puts YAML.dump({
'layout' => 'post',
'published' => false,
'title' => title,
'image' => 'REPLACEME.jpg',
'author' => 'Matthias Kretschmann',
'date' => Time.now
})
file.puts "---"
end
end
@ -38,10 +45,18 @@ task :photo do
path = "_src/_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md"
if File.exist?(path)
puts "Dude, file exists - skipping create"
puts "Dude, file exists - skipping create"
else
File.open(path, "w") do |file|
file.puts YAML.dump({'layout' => 'photo', 'published' => false, 'title' => title, 'image' => 'REPLACEME.jpg', 'author' => 'Matthias Kretschmann', 'category' => 'photos'})
file.puts YAML.dump({
'layout' => 'photo',
'published' => false,
'title' => title,
'image' => 'REPLACEME.jpg',
'author' => 'Matthias Kretschmann',
'date' => Time.now,
'category' => 'photos'
})
file.puts "---"
end
end
@ -62,10 +77,16 @@ task :photo do
path = "_src/_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.md"
if File.exist?(path)
puts "Dude, file exists - skipping create"
puts "Dude, file exists - skipping create"
else
File.open(path, "w") do |file|
file.puts YAML.dump({'layout' => 'link', 'published' => false, 'title' => title, 'author' => 'Matthias Kretschmann'})
file.puts YAML.dump({
'layout' => 'link',
'published' => false,
'title' => title,
'author' => 'Matthias Kretschmann',
'date' => Time.now
})
file.puts "---"
end
end