|
|
@ -13,24 +13,6 @@ end |
|
|
|
|
|
|
|
|
|
|
|
fill_template_pretemplated = fn template -> &fill_template.(template, &1) end |
|
|
|
fill_template_pretemplated = fn template -> &fill_template.(template, &1) end |
|
|
|
|
|
|
|
|
|
|
|
wrapInParagraphs = fn content -> content |
|
|
|
|
|
|
|
|> String.split("\\n") |
|
|
|
|
|
|
|
|> Enum.reject(fn(x) -> x == "" end) |
|
|
|
|
|
|
|
|> Enum.map(fn paragraph -> if String.starts_with?(paragraph, "<") do paragraph else "<p>" <> paragraph <> "</p>" end end) |
|
|
|
|
|
|
|
|> Enum.join("") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
post_contents_custom = File.ls!("./posts_custom") |
|
|
|
|
|
|
|
|> Enum.reject(fn(x) -> String.starts_with?(x, ".") end) |
|
|
|
|
|
|
|
|> Enum.map(fn f -> File.read!("./posts_custom/" <> f) end) |
|
|
|
|
|
|
|
|> Enum.map(fn c -> String.split(c, "\n") end) |
|
|
|
|
|
|
|
|> Enum.map(fn c -> Enum.reject(c, fn(x) -> x == "" end) end) |
|
|
|
|
|
|
|
|> Enum.map(fn c -> Enum.chunk_every(c, 2) end) |
|
|
|
|
|
|
|
|> Enum.map(fn c -> |
|
|
|
|
|
|
|
Enum.map(c, fn [k, v] -> %{String.to_atom(k) => v} end) |
|
|
|
|
|
|
|
|> Enum.reduce(%{}, fn(x, acc) -> Map.merge(x, acc) end) |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|> Enum.map(fn m -> Map.update!(m, :content, wrapInParagraphs) end) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filterCutFileExtension = fn files -> |
|
|
|
filterCutFileExtension = fn files -> |
|
|
|
fn ext -> |
|
|
|
fn ext -> |
|
|
|
Enum.filter(files, &String.ends_with?(&1, "." <> ext)) |
|
|
|
Enum.filter(files, &String.ends_with?(&1, "." <> ext)) |
|
|
@ -78,7 +60,7 @@ normalize_title = fn title -> String.replace(String.downcase(title), " ", "-") e |
|
|
|
|
|
|
|
|
|
|
|
constructLocalPath = fn p -> dateFolder.(p) <> normalize_title.(Map.get(p, :title)) end |
|
|
|
constructLocalPath = fn p -> dateFolder.(p) <> normalize_title.(Map.get(p, :title)) end |
|
|
|
|
|
|
|
|
|
|
|
post_contents = Enum.concat(post_contents_custom, post_contents_org) |
|
|
|
post_contents = post_contents_org |
|
|
|
|> Enum.map(fn postMap -> Map.merge(postMap, %{localpath: (constructLocalPath.(postMap))}) end) |
|
|
|
|> Enum.map(fn postMap -> Map.merge(postMap, %{localpath: (constructLocalPath.(postMap))}) end) |
|
|
|
|
|
|
|
|
|
|
|
index_file = |
|
|
|
index_file = |
|
|
|