Hey Guys,
I’m trying to move my blog posts from Ghost to Phoenix Live View.
I am aware of 2 approaches, that others take, to create blogs.
- Nimble Publisher (That compiles the markdown to HTML, and uses the file system as storage)
- Postgres/Sqlite backed one, where new posts are added to the database.
However, I want to go the third route, which is just writing my blog posts in HEEX.
This is what I have tried so far:
defmodule DerpyToolsWeb.BlogLive do
use DerpyToolsWeb, :live_view
embed_templates "posts/*"
def mount(%{"post_slug" => post_slug}, _session, socket) do
IO.inspect(post_slug, label: "post_slug")
{:ok, socket}
end
def render(assigns) do
~H"""
<.taskfile_a_sensible_makefile_and_shell_script_alternative />
<%!-- <.live_component
id="blog-post"
module={taskfile_a_sensible_makefile_and_shell_script_alternative} # How to make this work dynamically, using a string?
/> --%>
"""
end
end
So, how to embed that live component based on a string received from URL?
- Do I use something other than live_component?
- Will
embed_templates
import, say 1000 blog posts from the folder? (Is it bad? Although I doubt I will ever write that many blog posts.)