I'm working on an extension that parses links like [foo]($ref:foo.md) and turns it into a proper link so that I don't have to know the full rendered path to the post. I'm doing this as part of a pre_write extension with Floki to parse the the <a href= (or <img src=) value and convert $ref:foo.md to the appropriate full path for the post named foo.md.
It doesn't work. I think that the fix is relatively small in lib/mix/tasks/tableau.build.ex:
token = put_in(token.site[:pages], pages)
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)
File.mkdir_p!(dir)
File.write!(file_path, body)
end
As long as the pre_write/1 callback updates token.site[:pages] as part of its flow, it should be able to work.
I'm working on an extension that parses links like
[foo]($ref:foo.md)and turns it into a proper link so that I don't have to know the full rendered path to the post. I'm doing this as part of apre_writeextension with Floki to parse the the<a href=(or<img src=) value and convert$ref:foo.mdto the appropriate full path for the post namedfoo.md.It doesn't work. I think that the fix is relatively small in
lib/mix/tasks/tableau.build.ex:token = put_in(token.site[:pages], pages) 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) File.mkdir_p!(dir) File.write!(file_path, body) endAs long as the
pre_write/1callback updatestoken.site[:pages]as part of its flow, it should be able to work.