This commit is contained in:
Pete Lacey 2022-06-07 15:01:39 +01:00 committed by GitHub
commit b79deaccc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -122,13 +122,17 @@ defmodule LiveBeatsWeb.LiveHelpers do
"""
end
def link(%{navigate: _to} = assigns) do
assigns = assign_new(assigns, :class, fn -> nil end)
def link(%{navigate: to} = assigns) do
opts =
assigns
|> assign_new(:class, fn -> nil end)
|> assigns_to_attributes([:navigate])
|> Keyword.put(:to, to)
assigns = assign(assigns, :opts, opts)
~H"""
<a href={@navigate} data-phx-link="redirect" data-phx-link-state="push" class={@class}>
<%= render_slot(@inner_block) %>
</a>
<%= live_redirect @opts do %><%= render_slot(@inner_block) %><% end %>
"""
end