defmodule FirehoseWeb.BlogLive.Show do @moduledoc """ Example LiveView for showing a single blog post. Copy this into your host app and customize the layout/styling. """ use MyAppWeb, :live_view import Blogex.Components @impl true def mount(%{"blog" => blog_id} = _params, _session, socket) do blog = Blogex.get_blog!(String.to_existing_atom(blog_id)) {:ok, assign(socket, :blog, blog)} end @impl true def handle_params(%{"slug" => slug}, _uri, socket) do blog = socket.assigns.blog post = blog.get_post!(slug) meta = Blogex.SEO.meta_tags(post, FirehoseWeb.Endpoint.url(), blog) {:noreply, socket |> assign(:post, post) |> assign(:meta, meta) |> assign(:page_title, post.title) |> assign(:base_path, blog.base_path())} end @impl true def render(assigns) do ~H"""
<.post_show post={@post} />
""" end end