add content_for method
This commit is contained in:
parent
c6790bd8c9
commit
7e21d2a98f
17
Rakefile
17
Rakefile
|
@ -89,8 +89,7 @@ end
|
|||
|
||||
def siteify_file(file, front_matter = {})
|
||||
abort "You seem to have misplaced your #{file} file. I can haz?" unless File.exists?(file)
|
||||
contents = File.read(file)
|
||||
title = contents.match(/\A# (.*)$/)[1]
|
||||
title = File.read(file).match(/\A# (.*)$/)[1]
|
||||
output_file = file.sub(/\.markdown\z/, ".md").downcase
|
||||
slug = File.basename(output_file, ".md")
|
||||
front_matter = front_matter.merge({
|
||||
|
@ -99,12 +98,20 @@ def siteify_file(file, front_matter = {})
|
|||
"permalink" => "/docs/#{slug}/",
|
||||
"note" => "This file is autogenerated. Edit /#{file} instead."
|
||||
})
|
||||
contents.gsub!(/\A# #{title}\n\n?/, "")
|
||||
contents = converted_history(contents) if output_file == "history.md"
|
||||
contents = "#{front_matter.to_yaml}---\n\n#{contents}"
|
||||
contents = "#{front_matter.to_yaml}---\n\n#{content_for(file)}"
|
||||
File.write("site/_docs/#{output_file}", contents)
|
||||
end
|
||||
|
||||
def content_for(file)
|
||||
contents = File.read(file)
|
||||
case file
|
||||
when "HISTORY.markdown"
|
||||
converted_history(contents)
|
||||
else
|
||||
contents.gsub!(/\A# .*\n\n?/, "")
|
||||
end
|
||||
end
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
# Standard tasks
|
||||
|
|
Loading…
Reference in New Issue