This commit is contained in:
Inhji 2023-04-01 16:05:24 +02:00
parent d82f373bd2
commit eba003b3b5

View file

@ -1,12 +1,12 @@
defmodule ChiyaWeb.Exim do
alias Chiya.Notes.Note
defp frontmatter(%Note{name: title, channels: channels}) do
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
def export_note(%Note{content: content} = note) do
"---\n#{frontmatter(note)}\n---\n#{content}"
"---\n#{create_frontmatter(note)}\n---\n#{content}"
end
end