Skip to content

Commit 76fde41

Browse files
committed
fix(build): capture pre_write page changes
Resolves: #161
1 parent 3714a83 commit 76fde41

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/mix/tasks/tableau.build.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ defmodule Mix.Tasks.Tableau.Build do
6565

6666
token = mods |> extensions_for(:pre_write) |> run_extensions(:pre_write, token)
6767

68-
for %{body: body, permalink: permalink} <- pages do
68+
for %{body: body, permalink: permalink} <- token.site[:pages] do
6969
file_path = build_file_path(out, permalink)
7070
dir = Path.dirname(file_path)
7171

test/mix/tasks/tableau.build_test.exs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ defmodule Mix.Tasks.Tableau.FooExtension do
2525
def pre_write(token) do
2626
pages =
2727
for page <- token.site.pages do
28-
Map.put(page, :foo, "bar")
28+
page
29+
|> Map.put(:foo, "bar")
30+
|> Map.put(:body, page.body <> "<!-- foo: bar -->\n")
2931
end
3032

3133
{:ok, put_in(token.site.pages, pages)}
@@ -189,10 +191,11 @@ defmodule Mix.Tasks.Tableau.BuildTest do
189191

190192
assert log =~ "FailExtension failed to run"
191193

192-
assert File.exists?(Path.join(out, "/index.html"))
193-
assert File.exists?(Path.join(out, "/about/index.html"))
194-
assert File.exists?(Path.join(out, "/a-bing-bong-blog-post/index.html"))
195-
assert File.exists?(Path.join(out, "/some/deeply/nested/page/my-page/index.html"))
194+
for file <- ["/index.html", "/about/index.html", "/a-bing-bong-blog-post/index.html", "/some/deeply/nested/page/my-page/index.html"] do
195+
path = Path.join(out, file)
196+
assert File.exists?(path)
197+
assert path |> File.read!() |> String.ends_with?("<!-- foo: bar -->\n")
198+
end
196199
end
197200

198201
@tag :tmp_dir

0 commit comments

Comments
 (0)