2024-02-24 08:03:18 -05:00
|
|
|
defmodule SloaneSH.FrontMatter do
|
|
|
|
@moduledoc """
|
|
|
|
Parses TOML front matter out put files
|
|
|
|
"""
|
|
|
|
|
2024-02-24 13:16:56 -05:00
|
|
|
def parse("+++" <> rest) do
|
2024-02-24 08:03:18 -05:00
|
|
|
[toml, body] = String.split(rest, ["+++\n", "+++\r\n"], parts: 2)
|
|
|
|
|
|
|
|
with {:ok, attrs} <- Toml.decode(toml, keys: :atoms) do
|
|
|
|
{:ok, attrs, body}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-02-24 13:16:56 -05:00
|
|
|
def parse(body) do
|
2024-02-24 08:03:18 -05:00
|
|
|
{:ok, %{}, body}
|
|
|
|
end
|
|
|
|
end
|