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>
This commit is contained in:
@@ -3,10 +3,13 @@ defmodule BerrypodWeb.Shop.Contact do
|
||||
|
||||
alias Berrypod.Orders
|
||||
alias Berrypod.Orders.OrderNotifier
|
||||
alias Berrypod.Pages
|
||||
alias BerrypodWeb.OrderLookupController
|
||||
|
||||
@impl true
|
||||
def mount(_params, _session, socket) do
|
||||
page = Pages.get_page("contact")
|
||||
|
||||
{:ok,
|
||||
socket
|
||||
|> assign(:page_title, "Contact")
|
||||
@@ -15,7 +18,8 @@ defmodule BerrypodWeb.Shop.Contact do
|
||||
"Get in touch with us for any questions or help with your order."
|
||||
)
|
||||
|> assign(:og_url, BerrypodWeb.Endpoint.url() <> "/contact")
|
||||
|> assign(:tracking_state, :idle)}
|
||||
|> assign(:tracking_state, :idle)
|
||||
|> assign(:page, page)}
|
||||
end
|
||||
|
||||
@impl true
|
||||
@@ -43,7 +47,7 @@ defmodule BerrypodWeb.Shop.Contact do
|
||||
@impl true
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<BerrypodWeb.PageTemplates.contact {assigns} />
|
||||
<BerrypodWeb.PageRenderer.render_page {assigns} />
|
||||
"""
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,7 @@ defmodule BerrypodWeb.Shop.Content do
|
||||
use BerrypodWeb, :live_view
|
||||
|
||||
alias Berrypod.LegalPages
|
||||
alias Berrypod.Pages
|
||||
alias Berrypod.Theme.PreviewData
|
||||
|
||||
@impl true
|
||||
@@ -11,65 +12,68 @@ defmodule BerrypodWeb.Shop.Content do
|
||||
|
||||
@impl true
|
||||
def handle_params(_params, _uri, socket) do
|
||||
config = page_config(socket.assigns.live_action)
|
||||
{:noreply, assign(socket, config)}
|
||||
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.PageTemplates.content {assigns} />
|
||||
<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 – this is sample content for the demo shop",
|
||||
og_url: BerrypodWeb.Endpoint.url() <> "/about",
|
||||
active_page: "about",
|
||||
hero_title: "About the studio",
|
||||
hero_description: "Your story goes here – this is sample content for the demo shop",
|
||||
hero_background: :sunken,
|
||||
image_src: "/mockups/night-sky-blanket-3",
|
||||
image_alt: "Night sky blanket draped over a chair",
|
||||
content_blocks: PreviewData.about_content()
|
||||
{
|
||||
%{
|
||||
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",
|
||||
active_page: "delivery",
|
||||
hero_title: "Delivery & returns",
|
||||
hero_description: "Everything you need to know about shipping and returns",
|
||||
content_blocks: LegalPages.delivery_content()
|
||||
{
|
||||
%{
|
||||
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",
|
||||
active_page: "privacy",
|
||||
hero_title: "Privacy policy",
|
||||
hero_description: "How we handle your personal information",
|
||||
content_blocks: LegalPages.privacy_content()
|
||||
{
|
||||
%{
|
||||
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",
|
||||
active_page: "terms",
|
||||
hero_title: "Terms of service",
|
||||
hero_description: "The legal bits",
|
||||
content_blocks: LegalPages.terms_content()
|
||||
{
|
||||
%{
|
||||
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
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
defmodule BerrypodWeb.Shop.Home do
|
||||
use BerrypodWeb, :live_view
|
||||
|
||||
alias Berrypod.Products
|
||||
alias Berrypod.Pages
|
||||
|
||||
@impl true
|
||||
def mount(_params, _session, socket) do
|
||||
products = Products.list_visible_products(limit: 8)
|
||||
page = Pages.get_page("home")
|
||||
extra = Pages.load_block_data(page.blocks, socket.assigns)
|
||||
|
||||
base = BerrypodWeb.Endpoint.url()
|
||||
site_name = socket.assigns.theme_settings.site_name
|
||||
@@ -26,7 +27,8 @@ defmodule BerrypodWeb.Shop.Home do
|
||||
|> assign(:page_title, "Home")
|
||||
|> assign(:og_url, base <> "/")
|
||||
|> assign(:json_ld, org_ld)
|
||||
|> assign(:products, products)
|
||||
|> assign(:page, page)
|
||||
|> assign(extra)
|
||||
|
||||
{:ok, socket}
|
||||
end
|
||||
@@ -34,7 +36,7 @@ defmodule BerrypodWeb.Shop.Home do
|
||||
@impl true
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<BerrypodWeb.PageTemplates.home {assigns} />
|
||||
<BerrypodWeb.PageRenderer.render_page {assigns} />
|
||||
"""
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user