diff options
Diffstat (limited to 'build-files/build_posts.rb')
-rw-r--r-- | build-files/build_posts.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/build-files/build_posts.rb b/build-files/build_posts.rb new file mode 100644 index 0000000..ec03b77 --- /dev/null +++ b/build-files/build_posts.rb @@ -0,0 +1,38 @@ +require 'erb' +require 'kramdown' + +def render(partial_path) + ERB.new(File.read(partial_path)).result(binding) +end + +def content + output = Array.new + Dir.foreach("./content/posts") do |post_filename| + if post_filename.include?("md") + output.push(Kramdown::Document.new(File.read("./content/posts/#{post_filename}")).to_html) + end + end + return output +end + +def filename + file = Array.new + Dir.foreach("./content/posts") do |post_filename| + if post_filename.include?("md") + file.push("output/#{post_filename}.html") + end + end + return file +end + +i = 0 +while (i < content.length) + @content = content[i] + template = ERB.new(File.read('recipe-template.html.erb')) + puts template.result(binding) + file = filename[i] + File.open(file, 'w') do |f| + f.write(template.result) + end + i += 1 +end
\ No newline at end of file |