summaryrefslogtreecommitdiff
path: root/build_posts.rb
diff options
context:
space:
mode:
Diffstat (limited to 'build_posts.rb')
-rw-r--r--build_posts.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/build_posts.rb b/build_posts.rb
new file mode 100644
index 0000000..53a18ac
--- /dev/null
+++ b/build_posts.rb
@@ -0,0 +1,47 @@
+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
+
+=begin
+filename.each do |file|
+ File.open(file, 'w') do |f|
+ f.write(template.result)
+ end
+end
+=end \ No newline at end of file