sloane.sh/lib/sloane_sh/layouts/helpers.ex
2024-02-24 13:40:20 -05:00

19 lines
417 B
Elixir

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)
|> Enum.sort_by(& &1[:date], &Date.compare/2)
end
end