Created
          June 26, 2019 20:17 
        
      - 
      
- 
        Save dsignr/4032bce992ce302e068699fd69b0bfff to your computer and use it in GitHub Desktop. 
Revisions
- 
        dsignr created this gist Jun 26, 2019 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ def extract(changeset) do file_name = changeset.data.name data = File.read!("#{@data_folder}/pages/#{file_name}") case String.split(data, ~r/\n-{3,}\n/, parts: 2) do [""] -> %{frontmatter: nil, content: nil} [frontmatter, content] -> %{ frontmatter: parse_yaml(frontmatter), content: content } _ -> %{frontmatter: nil, content: nil} end # {parse_yaml(frontmatter), Earmark.to_html(markdown)} end