diff --git a/lib/mix/tasks/tableau.build.ex b/lib/mix/tasks/tableau.build.ex index a7f1511..cffa01b 100644 --- a/lib/mix/tasks/tableau.build.ex +++ b/lib/mix/tasks/tableau.build.ex @@ -65,7 +65,7 @@ defmodule Mix.Tasks.Tableau.Build do token = mods |> extensions_for(:pre_write) |> run_extensions(:pre_write, token) - for %{body: body, permalink: permalink} <- pages do + for %{body: body, permalink: permalink} <- token.site[:pages] do file_path = build_file_path(out, permalink) dir = Path.dirname(file_path) diff --git a/test/mix/tasks/tableau.build_test.exs b/test/mix/tasks/tableau.build_test.exs index 2be65b2..92e9483 100644 --- a/test/mix/tasks/tableau.build_test.exs +++ b/test/mix/tasks/tableau.build_test.exs @@ -25,7 +25,9 @@ defmodule Mix.Tasks.Tableau.FooExtension do def pre_write(token) do pages = for page <- token.site.pages do - Map.put(page, :foo, "bar") + page + |> Map.put(:foo, "bar") + |> Map.put(:body, page.body <> "\n") end {:ok, put_in(token.site.pages, pages)} @@ -189,10 +191,16 @@ defmodule Mix.Tasks.Tableau.BuildTest do assert log =~ "FailExtension failed to run" - assert File.exists?(Path.join(out, "/index.html")) - assert File.exists?(Path.join(out, "/about/index.html")) - assert File.exists?(Path.join(out, "/a-bing-bong-blog-post/index.html")) - assert File.exists?(Path.join(out, "/some/deeply/nested/page/my-page/index.html")) + for file <- [ + "/index.html", + "/about/index.html", + "/a-bing-bong-blog-post/index.html", + "/some/deeply/nested/page/my-page/index.html" + ] do + path = Path.join(out, file) + assert File.exists?(path) + assert path |> File.read!() |> String.ends_with?("\n") + end end @tag :tmp_dir