All checks were successful
deploy / deploy (push) Successful in 4m59s
- Per-page SEO controls: meta robots directives, focus keyword, OG image - Site-wide default OG image in admin settings - FAQ block type with FAQPage JSON-LD schema - Enhanced Organization JSON-LD with business info, contact, address - Image sitemap with product images - SEO preview panel with Google/social card mockups - SEO checklist with real-time scoring - Business info section in site editor - GSC integration scaffolding (OAuth, client, cache) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
94 lines
2.3 KiB
Elixir
94 lines
2.3 KiB
Elixir
defmodule BerrypodWeb.Shop.Pages.Content do
|
||
@moduledoc """
|
||
Content page handler for the unified Shop.Page LiveView.
|
||
Handles about, delivery, privacy, and terms pages.
|
||
"""
|
||
|
||
import Phoenix.Component, only: [assign: 2, assign: 3]
|
||
|
||
alias Berrypod.LegalPages
|
||
alias Berrypod.Pages
|
||
alias Berrypod.Theme.PreviewData
|
||
alias BerrypodWeb.Helpers.SeoHelpers
|
||
alias BerrypodWeb.R
|
||
|
||
def init(socket, _params, _uri) do
|
||
# Content pages load in handle_params based on live_action
|
||
{:noreply, socket}
|
||
end
|
||
|
||
def handle_params(_params, _uri, socket) do
|
||
action = socket.assigns.live_action
|
||
slug = to_string(action)
|
||
page = Pages.get_page(slug)
|
||
{seo, content_blocks} = page_config(action)
|
||
|
||
socket =
|
||
socket
|
||
|> assign(seo)
|
||
|> assign(:page, page)
|
||
|> assign(:content_blocks, content_blocks)
|
||
|> assign(:json_ld, SeoHelpers.faq_json_ld(page && page.blocks))
|
||
|> maybe_assign_meta_robots(page)
|
||
|
||
{:noreply, socket}
|
||
end
|
||
|
||
defp maybe_assign_meta_robots(socket, page) do
|
||
meta_robots = page && page[:meta_robots]
|
||
|
||
if meta_robots && meta_robots != "index, follow" do
|
||
assign(socket, :meta_robots, meta_robots)
|
||
else
|
||
socket
|
||
end
|
||
end
|
||
|
||
def handle_event(_event, _params, _socket), do: :cont
|
||
|
||
# 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: R.url(R.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: R.url(R.delivery())
|
||
},
|
||
LegalPages.delivery_content()
|
||
}
|
||
end
|
||
|
||
defp page_config(:privacy) do
|
||
{
|
||
%{
|
||
page_title: "Privacy policy",
|
||
page_description: "How we handle your personal information.",
|
||
og_url: R.url(R.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: R.url(R.terms())
|
||
},
|
||
LegalPages.terms_content()
|
||
}
|
||
end
|
||
end
|