berrypod/lib/berrypod_web/live/shop/content.ex
jamey c69e51051f wire simple pages to PageRenderer (stage 3)
Home, Content (about/delivery/privacy/terms), Contact, and ErrorHTML
now render through the generic PageRenderer instead of hardcoded
templates. Block wrapper divs enable CSS grid targeting. Featured
products block supports layout/card_variant/columns settings for
different page contexts. Contact page uses CSS grid on data-block-type
attributes for two-column layout.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 18:29:20 +00:00

80 lines
1.9 KiB
Elixir

defmodule BerrypodWeb.Shop.Content do
use BerrypodWeb, :live_view
alias Berrypod.LegalPages
alias Berrypod.Pages
alias Berrypod.Theme.PreviewData
@impl true
def mount(_params, _session, socket) do
{:ok, socket}
end
@impl true
def handle_params(_params, _uri, socket) do
slug = to_string(socket.assigns.live_action)
page = Pages.get_page(slug)
{seo, content_blocks} = page_config(socket.assigns.live_action)
socket =
socket
|> assign(seo)
|> assign(:page, page)
|> assign(:content_blocks, content_blocks)
{:noreply, socket}
end
@impl true
def render(assigns) do
~H"""
<BerrypodWeb.PageRenderer.render_page {assigns} />
"""
end
# Returns {seo_assigns, content_blocks} for each content page
defp page_config(:about) do
{
%{
page_title: "About",
page_description: "Your story goes here \u2013 this is sample content for the demo shop",
og_url: BerrypodWeb.Endpoint.url() <> "/about"
},
PreviewData.about_content()
}
end
defp page_config(:delivery) do
{
%{
page_title: "Delivery & returns",
page_description: "Everything you need to know about shipping and returns.",
og_url: BerrypodWeb.Endpoint.url() <> "/delivery"
},
LegalPages.delivery_content()
}
end
defp page_config(:privacy) do
{
%{
page_title: "Privacy policy",
page_description: "How we handle your personal information.",
og_url: BerrypodWeb.Endpoint.url() <> "/privacy"
},
LegalPages.privacy_content()
}
end
defp page_config(:terms) do
{
%{
page_title: "Terms of service",
page_description: "The terms and conditions governing purchases from our shop.",
og_url: BerrypodWeb.Endpoint.url() <> "/terms"
},
LegalPages.terms_content()
}
end
end