@@ -6,8 +6,6 @@ defmodule AlgoraWeb.BlogLive do
66 alias AlgoraWeb.Components.Footer
77 alias AlgoraWeb.Components.Header
88
9- @ blog_path "priv/blog"
10-
119 @ impl true
1210 def mount ( % { "slug" => slug } , _session , socket ) do
1311 case load_blog_post ( slug ) do
@@ -108,15 +106,15 @@ defmodule AlgoraWeb.BlogLive do
108106 end
109107
110108 defp load_blog_post ( slug ) do
111- with { :ok , content } <- File . read ( Path . join ( @ blog_path , "#{ slug } .md" ) ) ,
109+ with { :ok , content } <- File . read ( Path . join ( blog_path ( ) , "#{ slug } .md" ) ) ,
112110 [ frontmatter , markdown ] <- content |> String . split ( "---\n " , parts: 3 ) |> Enum . drop ( 1 ) ,
113111 { :ok , parsed_frontmatter } <- YamlElixir . read_from_string ( frontmatter ) do
114112 { :ok , { parsed_frontmatter , markdown } }
115113 end
116114 end
117115
118116 defp list_blog_posts do
119- @ blog_path
117+ blog_path ( )
120118 |> File . ls! ( )
121119 |> Enum . filter ( & String . ends_with? ( & 1 , ".md" ) )
122120 |> Enum . map ( fn filename ->
@@ -142,4 +140,6 @@ defmodule AlgoraWeb.BlogLive do
142140 end
143141
144142 def format_date ( _ ) , do: ""
143+
144+ defp blog_path , do: Path . join ( [ :code . priv_dir ( :algora ) , "blog" ] )
145145end
0 commit comments