defmodule Blog do def collect(project_root, bricks) do files = Path.wildcard(project_root <> "/blog/*.fxg") |> Map.new(fn x -> {FileX.trimmed_filename(x), File.read!(x)} end) # no blog posts yet so we return nothing %{ output_dir: "#{project_root}/build/blog", main_template: File.read!(project_root <> "/templates/base.thtml"), bricks: bricks } end def compile(blog) do File.mkdir_p!("#{blog.output_dir}") index = "
comig son :3
" File.write!( "#{blog.output_dir}/index.html", Mustache.render(blog.main_template, Map.merge(%{fxg_content: index}, blog.bricks)) ) IO.puts("[GENERATE] #{blog.output_dir}/index.html") end end