diff --git a/client/public/gen.ex b/client/public/gen.ex
index 2ec4af1..d4124bc 100644
--- a/client/public/gen.ex
+++ b/client/public/gen.ex
@@ -2,6 +2,9 @@
index_template = File.read!("./templates/post_index_page.html")
post_template = File.read!("./templates/post_single_page.html")
+post_feed_item_template = File.read!("./templates/post_item.xml")
+post_feed_template = File.read!("./templates/posts.xml")
+
post_contents = File.ls!("./posts")
|> Enum.reject(fn(x) -> String.starts_with?(x, ".") end)
|> Enum.map(fn f -> File.read!("./posts/" <> f) end)
@@ -47,3 +50,20 @@ post_contents
end))
|> File.close()
end)
+
+post_feed = post_contents
+ |> Enum.sort_by(fn m -> Map.get(m, :date) end)
+ |> Enum.reverse()
+ |> Enum.map(fn post ->
+ Regex.compile!("{{(.*)}}") |>
+ Regex.replace(post_feed_item_template, fn _, key -> Map.get(post, String.to_atom(key))
+ end)
+ end)
+ |> Enum.join("\n")
+ |> (fn items -> (Regex.compile!("{{items}}") |>
+ Regex.replace(post_feed_template, fn _, __ -> items end))
+ end).()
+
+File.open!("./gen/rss.xml", [:write])
+ |> IO.binwrite(post_feed)
+ |> File.close()
diff --git a/client/public/templates/post_item.xml b/client/public/templates/post_item.xml
new file mode 100644
index 0000000..fca9f40
--- /dev/null
+++ b/client/public/templates/post_item.xml
@@ -0,0 +1,14 @@
+ -
+ {{title}}
+ https://raymon.dev/posts/{{id}}.html
+ https://raymon.dev/posts/{{id}}.html
+
+
+
+
+ {{content}}
+
+ {{date}}
+
diff --git a/client/public/templates/post_single_page.html b/client/public/templates/post_single_page.html
index b41f560..28a49ef 100644
--- a/client/public/templates/post_single_page.html
+++ b/client/public/templates/post_single_page.html
@@ -26,7 +26,7 @@
{{title}}
- For those using a RSS reader, subscribe here: rss.xml
+ For those using a RSS reader, subscribe here: rss.xml
{{content}}
diff --git a/client/public/templates/posts.xml b/client/public/templates/posts.xml
new file mode 100644
index 0000000..fe8b854
--- /dev/null
+++ b/client/public/templates/posts.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ Posts
+ https://raymon.dev
+ Personal blog
+ en-us
+
+{{items}}
+
+