Skip to content

Commit

Permalink
Mark post files as external resources
Browse files Browse the repository at this point in the history
  • Loading branch information
qcam committed Apr 1, 2018
1 parent 9137dba commit 4a3bb88
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/nabo/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,18 @@ defmodule Nabo.Repo do
compiler_options = Module.get_attribute(env.module, :compiler_options)
root_path = Module.get_attribute(env.module, :root_path)
pattern = "*"
post_paths = find_all(root_path, pattern)

{posts_map, _compiled_errors} =
root_path
|> find_all(pattern)
post_paths
|> async_compile(env.module, compiler_options)
|> build_posts_map()

external_resources = Enum.map(post_paths, &quote(do: @external_resources unquote(&1)))

quote do
unquote(external_resources)

defp posts_map() do
unquote(posts_map)
end
Expand Down Expand Up @@ -136,7 +140,7 @@ defmodule Nabo.Repo do
defp async_compile(paths, repo_name, compiler_options) do
paths
|> Enum.map(&Task.async(fn -> compile(&1, repo_name, compiler_options) end))
|> Enum.map(&Task.await(&1))
|> Enum.map(&Task.await/1)
end

defp compile(path, repo_name, options) do
Expand Down

0 comments on commit 4a3bb88

Please sign in to comment.