|
|
@ -63,6 +63,13 @@ constructLocalPath = fn p -> dateFolder.(p) <> normalize_title.(Map.get(p, :titl |
|
|
|
post_contents = 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) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
date_sort = fn post -> |
|
|
|
|
|
|
|
date = Map.get(post, :date) |
|
|
|
|
|
|
|
month = Enum.find_index(months, &(&1 == String.slice(date, 8..10))) |
|
|
|
|
|
|
|
day = elem(Integer.parse(String.slice(date, 5..6)), 0) |
|
|
|
|
|
|
|
32 * month + day |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
index_file = |
|
|
|
index_file = |
|
|
|
post_contents |
|
|
|
post_contents |
|
|
|
|> Enum.sort_by( |
|
|
|
|> Enum.sort_by( |
|
|
@ -71,15 +78,18 @@ index_file = |
|
|
|
|> Integer.parse()) |
|
|
|
|> Integer.parse()) |
|
|
|
) |
|
|
|
) |
|
|
|
|> Enum.reverse() |
|
|
|
|> Enum.reverse() |
|
|
|
# Group by month |
|
|
|
# Group by year |
|
|
|
|> Enum.group_by(fn m -> Map.get(m, :date) |> String.slice(8..15) end) |
|
|
|
|> Enum.group_by(fn m -> Map.get(m, :date) |> String.slice(12..15) end) |
|
|
|
|> Enum.sort_by(fn {d, _c} -> ((length months) * elem(Integer.parse(String.slice(d, 4..7)), 0)) + Enum.find_index(months, &(&1 == String.slice(d, 0..2))) end) |
|
|
|
|> Enum.sort_by(fn {d, _c} -> Integer.parse(d) end) |
|
|
|
|> Enum.reverse() |
|
|
|
|> Enum.reverse() |
|
|
|
|> Enum.map(fn {month, posts} -> "\n<h1>" <> month <> "</h1>\n" <> (posts |> |
|
|
|
|> Enum.map(fn {year, posts} -> "\n<h1>" <> year <> "</h1>\n<ul>" <> (posts |> Enum.sort_by(date_sort) |> Enum.reverse() |> |
|
|
|
Enum.map(fn post -> "<h2 class=\"post-link\">" <> (Map.get(post, :date) |> String.slice(0..6)) <> |
|
|
|
Enum.map(fn post -> "<li class=\"post-link\">" <> |
|
|
|
" - <a href=\"" <> Map.get(post, :localpath) <> ".html\">" <> Map.get(post, :title) <> "</a></h2>" |
|
|
|
"<time datetime=\""<> Map.get(post, :date) <> "\">" <> (Map.get(post, :date) |> String.slice(0..10)) <> "</time>" <> |
|
|
|
end) |> Enum.join("\n")) end) |
|
|
|
" - " <> |
|
|
|
|> Enum.join("\n") |
|
|
|
"<a href=\"" <> Map.get(post, :localpath) <> ".html\">" <> Map.get(post, :title) <> "</a>" <> |
|
|
|
|
|
|
|
"</li>" |
|
|
|
|
|
|
|
end) |> Enum.join("\n")) end) |
|
|
|
|
|
|
|
|> Enum.join("\n</ul>") |
|
|
|
|> (fn v -> %{index: v} end).() |
|
|
|
|> (fn v -> %{index: v} end).() |
|
|
|
|> fill_template_pretemplated.(index_template).() |
|
|
|
|> fill_template_pretemplated.(index_template).() |
|
|
|
|
|
|
|
|
|
|
|