Fix rakefile when you don't have a title in markdown
This commit is contained in:
parent
c49d1fc1bd
commit
a1835c0a31
8
Rakefile
8
Rakefile
|
@ -89,7 +89,11 @@ end
|
||||||
|
|
||||||
def siteify_file(file, front_matter = {})
|
def siteify_file(file, front_matter = {})
|
||||||
abort "You seem to have misplaced your #{file} file. I can haz?" unless File.exists?(file)
|
abort "You seem to have misplaced your #{file} file. I can haz?" unless File.exists?(file)
|
||||||
title = File.read(file).match(/\A# (.*)$/)[1]
|
title = begin
|
||||||
|
File.read(file).match(/\A# (.*)$/)[1]
|
||||||
|
rescue
|
||||||
|
File.basename(file, ".*")
|
||||||
|
end
|
||||||
slug = File.basename(file, ".markdown").downcase
|
slug = File.basename(file, ".markdown").downcase
|
||||||
front_matter = front_matter.merge({
|
front_matter = front_matter.merge({
|
||||||
"title" => title,
|
"title" => title,
|
||||||
|
@ -107,7 +111,7 @@ def content_for(file)
|
||||||
when "History.markdown"
|
when "History.markdown"
|
||||||
converted_history(contents)
|
converted_history(contents)
|
||||||
else
|
else
|
||||||
contents.gsub!(/\A# .*\n\n?/, "")
|
contents.gsub(/\A# .*\n\n?/, "")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue