Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mix/tasks/tableau.build.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
18 changes: 13 additions & 5 deletions test/mix/tasks/tableau.build_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <> "<!-- foo: bar -->\n")
end

{:ok, put_in(token.site.pages, pages)}
Expand Down Expand Up @@ -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?("<!-- foo: bar -->\n")
end
end

@tag :tmp_dir
Expand Down