Join date sort order function to one line

- Fixes not using year in order calculation
master
Raymonzut 4 years ago
parent 8e15354c2a
commit 6c31c8752d
No known key found for this signature in database
GPG Key ID: 1E9BCC39EDD1DD53
  1. 3
      client/gen.exs

@ -38,8 +38,7 @@ index_file = post_contents
|> Enum.reverse() |> Enum.reverse()
# Group by month # Group by month
|> 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(8..15) end)
|> Enum.sort_by(fn {d, _c} -> (length months) * elem(Integer.parse(String.slice(d, 4..7)), 0) |> 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.find_index(months, &(&1 == String.slice(d, 0..2))) end)
|> Enum.reverse() |> Enum.reverse()
|> Enum.map(fn {month, posts} -> "\n<h1>" <> month <> "</h1>\n" <> (posts |> |> Enum.map(fn {month, posts} -> "\n<h1>" <> month <> "</h1>\n" <> (posts |>
Enum.map(fn post -> "<h2>" <> (Map.get(post, :date) |> String.slice(0..6)) <> Enum.map(fn post -> "<h2>" <> (Map.get(post, :date) |> String.slice(0..6)) <>

Loading…
Cancel
Save