defmodule Paleta.Components.Head do use Phoenix.Component attr(:google_map, :boolean, default: false) attr(:title_suffix, :string, default: "") slot(:custom) def head(%{google_map: google_map} = assigns) do assigns = assigns |> assign(:google_map_url, google_map_url(google_map)) ~H""" <.live_title suffix={" ยท #{@title_suffix}"}> <%= assigns[:page_title] || "Welcome" %> <%= render_slot(@custom) %> """ end defp google_map_url(true) do api_key = Paleta.Config.google_map_key() "https://maps.googleapis.com/maps/api/js?key=#{api_key}&callback=Function.prototype" end defp google_map_url(false), do: nil end