2024-02-24 13:40:20 -05:00
|
|
|
defmodule SloaneSH.Layouts.Helpers do
|
|
|
|
alias SloaneSH.Context
|
|
|
|
|
|
|
|
def cx(classes) do
|
|
|
|
classes
|
|
|
|
|> Enum.map(fn
|
|
|
|
{_, _} = t -> t
|
|
|
|
c -> {c, true}
|
|
|
|
end)
|
|
|
|
|> Enum.filter(fn {_, v} -> !!v end)
|
|
|
|
|> Enum.map_join(" ", fn {class, _} -> class end)
|
|
|
|
end
|
|
|
|
|
|
|
|
def sorted_post_attrs(%Context{} = ctx) do
|
|
|
|
ctx.posts
|
|
|
|
|> Enum.map(& &1.attrs)
|
2024-02-24 19:31:09 -05:00
|
|
|
|> Enum.sort_by(& &1[:date], {:desc, Date})
|
2024-02-24 13:40:20 -05:00
|
|
|
end
|
2024-02-24 13:53:53 -05:00
|
|
|
|
|
|
|
def fmt_date(date) do
|
|
|
|
Timex.format!(date, "{Mfull} {D}, {YYYY}")
|
|
|
|
end
|
2024-02-24 13:40:20 -05:00
|
|
|
end
|