berrypod/lib/berrypod_web/live/shop/home.ex

41 lines
850 B
Elixir
Raw Normal View History

defmodule BerrypodWeb.Shop.Home do
use BerrypodWeb, :live_view
alias Berrypod.Products
@impl true
def mount(_params, _session, socket) do
products = Products.list_visible_products(limit: 8)
base = BerrypodWeb.Endpoint.url()
site_name = socket.assigns.theme_settings.site_name
org_ld =
Jason.encode!(
%{
"@context" => "https://schema.org",
"@type" => "Organization",
"name" => site_name,
"url" => base <> "/"
},
escape: :html_safe
)
socket =
socket
|> assign(:page_title, "Home")
|> assign(:og_url, base <> "/")
|> assign(:json_ld, org_ld)
|> assign(:products, products)
{:ok, socket}
end
@impl true
def render(assigns) do
~H"""
<BerrypodWeb.PageTemplates.home {assigns} />
"""
end
end