chiya/lib/chiya_web/exim.ex

13 lines
385 B
Elixir
Raw Normal View History

2023-03-31 22:20:32 +02:00
defmodule ChiyaWeb.Exim do
alias Chiya.Notes.Note
2023-03-31 22:20:32 +02:00
2023-04-01 16:05:24 +02:00
defp create_frontmatter(%Note{name: title, channels: channels}) do
channels_raw = Enum.map_join(channels, "], [", fn c -> "\"#{c.name}\"" end)
"title: \"#{title}\"\ncategories: [#{channels_raw}]"
end
2023-03-31 22:20:32 +02:00
def export_note(%Note{content: content} = note) do
2023-04-01 16:05:24 +02:00
"---\n#{create_frontmatter(note)}\n---\n#{content}"
end
end