diff --git a/lib/chubi/content.ex b/lib/chubi/content.ex index 11b8533..67605ae 100644 --- a/lib/chubi/content.ex +++ b/lib/chubi/content.ex @@ -211,7 +211,7 @@ defmodule Chubi.Content do end defp parse_content(%{"content" => content} = params) do - format = Application.get_env(:chubi, :post_format) || "html" + format = params["format"] || Application.get_env(:chubi, :post_format) || "markdown" parser = Keyword.get(@content_parser_map, String.to_atom(format)) attrs = parser.parse(content, params) Map.merge(params, attrs) diff --git a/lib/chubi_web/controllers/admin/setting_controller.ex b/lib/chubi_web/controllers/admin/setting_controller.ex index 7fd33f1..9e4b79f 100644 --- a/lib/chubi_web/controllers/admin/setting_controller.ex +++ b/lib/chubi_web/controllers/admin/setting_controller.ex @@ -48,12 +48,17 @@ defmodule ChubiWeb.Admin.SettingController do with {:ok, files} <- :zip.extract(String.to_charlist(path), [:memory]) do rs = Enum.map(files, fn {file_path, content} -> - file_path = to_string(file_path) + file_path = + to_string(file_path) + |> IO.inspect() attrs = case Path.extname(file_path) do - ".md" -> %{"content" => content, "format" => "markdown"} - _ -> Jason.decode!(content) + ".md" -> + %{"content" => content, "format" => "markdown"} + + _ext -> + Jason.decode!(content) end if String.starts_with?(file_path, "posts") do