2023-03-31 22:20:32 +02:00
|
|
|
defmodule ChiyaWeb.Exim do
|
2023-04-01 12:09:58 +02:00
|
|
|
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
|
2023-04-01 12:09:58 +02:00
|
|
|
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
|
|
|
|
2023-04-01 12:09:58 +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}"
|
2023-04-01 12:09:58 +02:00
|
|
|
end
|
|
|
|
end
|