diff --git a/lib/music_library_web/live/artist_live/show.ex b/lib/music_library_web/live/artist_live/show.ex new file mode 100644 index 00000000..8bb98f10 --- /dev/null +++ b/lib/music_library_web/live/artist_live/show.ex @@ -0,0 +1,32 @@ +defmodule MusicLibraryWeb.ArtistLive.Show do + use MusicLibraryWeb, :live_view + + alias MusicLibrary.Records + + @impl true + def mount(_params, _session, socket) do + {:ok, socket} + end + + @impl true + def handle_params(%{"musicbrainz_id" => musicbrainz_id}, _, socket) do + {:ok, artist} = Records.get_artist(musicbrainz_id) + + {:noreply, + socket + |> assign(:nav_section, :artists) + |> assign(:artist, artist) + |> assign(:page_title, page_title(socket.assigns.live_action, artist))} + end + + defp page_title(:show, artist) do + Enum.join( + [ + artist.name, + "ยท", + gettext("Details") + ], + " " + ) + end +end diff --git a/lib/music_library_web/live/artist_live/show.html.heex b/lib/music_library_web/live/artist_live/show.html.heex new file mode 100644 index 00000000..206e477a --- /dev/null +++ b/lib/music_library_web/live/artist_live/show.html.heex @@ -0,0 +1,8 @@ +
+ <%= raw(@artist.bio) || gettext("Biography not available") %> +
+