2026-03-09 14:47:50 +00:00
|
|
|
defmodule BerrypodWeb.Shop.Pages.Home do
|
|
|
|
|
@moduledoc """
|
|
|
|
|
Home page handler for the unified Shop.Page LiveView.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import Phoenix.Component, only: [assign: 2, assign: 3]
|
2026-01-17 16:19:35 +00:00
|
|
|
|
2026-02-26 18:29:20 +00:00
|
|
|
alias Berrypod.Pages
|
2026-01-17 16:19:35 +00:00
|
|
|
|
2026-03-09 14:47:50 +00:00
|
|
|
def init(socket, _params, _uri) do
|
2026-02-26 18:29:20 +00:00
|
|
|
page = Pages.get_page("home")
|
|
|
|
|
extra = Pages.load_block_data(page.blocks, socket.assigns)
|
2026-01-17 16:19:35 +00:00
|
|
|
|
2026-02-23 22:37:34 +00:00
|
|
|
base = BerrypodWeb.Endpoint.url()
|
2026-03-03 14:52:31 +00:00
|
|
|
site_name = socket.assigns.site_name
|
2026-02-23 22:37:34 +00:00
|
|
|
|
|
|
|
|
org_ld =
|
|
|
|
|
Jason.encode!(
|
|
|
|
|
%{
|
|
|
|
|
"@context" => "https://schema.org",
|
|
|
|
|
"@type" => "Organization",
|
|
|
|
|
"name" => site_name,
|
|
|
|
|
"url" => base <> "/"
|
|
|
|
|
},
|
|
|
|
|
escape: :html_safe
|
|
|
|
|
)
|
|
|
|
|
|
2026-01-17 16:19:35 +00:00
|
|
|
socket =
|
|
|
|
|
socket
|
|
|
|
|
|> assign(:page_title, "Home")
|
2026-02-23 22:37:34 +00:00
|
|
|
|> assign(:og_url, base <> "/")
|
|
|
|
|
|> assign(:json_ld, org_ld)
|
2026-02-26 18:29:20 +00:00
|
|
|
|> assign(:page, page)
|
|
|
|
|
|> assign(extra)
|
2026-01-17 16:19:35 +00:00
|
|
|
|
2026-03-09 14:47:50 +00:00
|
|
|
{:noreply, socket}
|
2026-01-17 16:19:35 +00:00
|
|
|
end
|
2026-01-17 22:17:59 +00:00
|
|
|
|
2026-03-09 14:47:50 +00:00
|
|
|
def handle_params(_params, _uri, socket) do
|
|
|
|
|
{:noreply, socket}
|
2026-01-17 22:17:59 +00:00
|
|
|
end
|
2026-03-09 14:47:50 +00:00
|
|
|
|
|
|
|
|
def handle_event(_event, _params, _socket), do: :cont
|
2026-01-17 16:19:35 +00:00
|
|
|
end
|