diff --git a/PROGRESS.md b/PROGRESS.md
index 87877b3..b7bedcc 100644
--- a/PROGRESS.md
+++ b/PROGRESS.md
@@ -458,15 +458,15 @@ See: [plan](docs/plans/shipping-sync.md) for implementation details
See: [docs/plans/analytics-v2.md](docs/plans/analytics-v2.md) for v2 plan
### Page Editor
-**Status:** In progress — Stage 2 of 9 complete, 1284 tests
+**Status:** In progress — Stage 3 of 9 complete, 1284 tests
Database-driven page builder. Every page is a flat list of blocks stored as JSON — add, remove, reorder, and edit blocks on any page. One generic renderer for all pages (no page-specific render functions). Portable blocks (hero, featured_products, image_text, etc.) work on any page. Page-specific blocks (product_hero, cart_items, etc.) are restricted to their native page. Block data loaders dynamically load data based on which blocks are on the page. ETS-cached page definitions. Mobile-first admin editor with live preview, undo/redo, accessible reordering (no drag-and-drop), inline settings forms, and "reset to defaults". CSS-driven page layout (not renderer-driven).
**Stages:**
1. ~~Foundation — data model, cache, block registry~~ ✅ (`35f96e4`)
2. ~~Page renderer — generic renderer tested in isolation~~ ✅ (`32f54c7`)
-3. **Next →** Wire simple pages — Home, Content (x4), Contact, Error
-4. Wire shop pages — Collection, PDP, Cart, Search
+3. ~~Wire simple pages — Home, Content (x4), Contact, Error~~ ✅
+4. **Next →** Wire shop pages — Collection, PDP, Cart, Search
5. Wire order pages + theme preview — CheckoutSuccess, Orders, OrderDetail, theme editor
6. Admin editor — page list + block management (reorder, add, remove, duplicate, save)
7. Admin editor — inline block settings editing
diff --git a/assets/css/shop/components.css b/assets/css/shop/components.css
index dac6456..8dc7d69 100644
--- a/assets/css/shop/components.css
+++ b/assets/css/shop/components.css
@@ -2444,6 +2444,9 @@
max-width: 56rem;
padding-top: 0;
padding-bottom: 4rem;
+
+ & > [data-block-type="hero"] { grid-column: 1 / -1; }
+ & > [data-block-type="contact_form"] { grid-column: 1; }
}
.contact-grid {
@@ -2527,6 +2530,7 @@
.footer-bottom { flex-direction: row; }
.pdp-grid { grid-template-columns: repeat(2, 1fr); }
.contact-grid { grid-template-columns: repeat(2, 1fr); }
+ .contact-main { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2rem; }
.product-grid[data-columns="fixed-4"] {
grid-template-columns: repeat(4, 1fr);
}
diff --git a/docs/plans/page-builder.md b/docs/plans/page-builder.md
index 5af4199..549044f 100644
--- a/docs/plans/page-builder.md
+++ b/docs/plans/page-builder.md
@@ -1,6 +1,6 @@
# Page builder plan
-Status: In progress (Stage 2 complete)
+Status: In progress (Stage 3 complete)
## Context
diff --git a/lib/berrypod/pages.ex b/lib/berrypod/pages.ex
index 94423dc..019d01b 100644
--- a/lib/berrypod/pages.ex
+++ b/lib/berrypod/pages.ex
@@ -26,6 +26,9 @@ defmodule Berrypod.Pages do
{:ok, page_data} -> page_data
:miss -> get_page_uncached(slug)
end
+ rescue
+ # ETS table might not exist yet during startup
+ ArgumentError -> get_page_uncached(slug)
end
@doc """
diff --git a/lib/berrypod/pages/block_types.ex b/lib/berrypod/pages/block_types.ex
index f60956f..19663d6 100644
--- a/lib/berrypod/pages/block_types.ex
+++ b/lib/berrypod/pages/block_types.ex
@@ -22,6 +22,8 @@ defmodule Berrypod.Pages.BlockTypes do
%{key: "description", label: "Description", type: :textarea, default: ""},
%{key: "cta_text", label: "Button text", type: :text, default: ""},
%{key: "cta_href", label: "Button link", type: :text, default: ""},
+ %{key: "secondary_cta_text", label: "Secondary button text", type: :text, default: ""},
+ %{key: "secondary_cta_href", label: "Secondary button link", type: :text, default: ""},
%{
key: "variant",
label: "Style",
@@ -37,7 +39,28 @@ defmodule Berrypod.Pages.BlockTypes do
allowed_on: :all,
settings_schema: [
%{key: "title", label: "Title", type: :text, default: "Featured products"},
- %{key: "product_count", label: "Number of products", type: :number, default: 8}
+ %{key: "product_count", label: "Number of products", type: :number, default: 8},
+ %{
+ key: "layout",
+ label: "Layout",
+ type: :select,
+ options: ~w(section grid),
+ default: "section"
+ },
+ %{
+ key: "card_variant",
+ label: "Card style",
+ type: :select,
+ options: ~w(featured default minimal compact),
+ default: "featured"
+ },
+ %{
+ key: "columns",
+ label: "Columns",
+ type: :select,
+ options: ~w(auto fixed-4),
+ default: "auto"
+ }
],
data_loader: :load_featured_products
},
diff --git a/lib/berrypod/pages/defaults.ex b/lib/berrypod/pages/defaults.ex
index fe3caca..eddd1de 100644
--- a/lib/berrypod/pages/defaults.ex
+++ b/lib/berrypod/pages/defaults.ex
@@ -65,12 +65,12 @@ defmodule Berrypod.Pages.Defaults do
[
block("hero", %{
"title" => "About the studio",
- "description" => "",
+ "description" => "Your story goes here \u2013 this is sample content for the demo shop",
"variant" => "sunken"
}),
block("content_body", %{
"image_src" => "/mockups/night-sky-blanket-3",
- "image_alt" => "Night sky blanket"
+ "image_alt" => "Night sky blanket draped over a chair"
})
]
end
@@ -78,8 +78,8 @@ defmodule Berrypod.Pages.Defaults do
defp blocks("delivery") do
[
block("hero", %{
- "title" => "Delivery information",
- "description" => "",
+ "title" => "Delivery & returns",
+ "description" => "Everything you need to know about shipping and returns",
"variant" => "page"
}),
block("content_body")
@@ -90,7 +90,7 @@ defmodule Berrypod.Pages.Defaults do
[
block("hero", %{
"title" => "Privacy policy",
- "description" => "",
+ "description" => "How we handle your personal information",
"variant" => "page"
}),
block("content_body")
@@ -100,8 +100,8 @@ defmodule Berrypod.Pages.Defaults do
defp blocks("terms") do
[
block("hero", %{
- "title" => "Terms & conditions",
- "description" => "",
+ "title" => "Terms of service",
+ "description" => "The legal bits",
"variant" => "page"
}),
block("content_body")
@@ -186,11 +186,16 @@ defmodule Berrypod.Pages.Defaults do
block("hero", %{
"variant" => "error",
"cta_text" => "Go to Homepage",
- "cta_href" => "/"
+ "cta_href" => "/",
+ "secondary_cta_text" => "Browse Products",
+ "secondary_cta_href" => "/collections/all"
}),
block("featured_products", %{
"title" => "Featured products",
- "product_count" => 4
+ "product_count" => 4,
+ "layout" => "grid",
+ "card_variant" => "minimal",
+ "columns" => "fixed-4"
})
]
end
diff --git a/lib/berrypod_web/controllers/error_html.ex b/lib/berrypod_web/controllers/error_html.ex
index af978d3..2977b7a 100644
--- a/lib/berrypod_web/controllers/error_html.ex
+++ b/lib/berrypod_web/controllers/error_html.ex
@@ -6,6 +6,8 @@ defmodule BerrypodWeb.ErrorHTML do
"""
use BerrypodWeb, :html
+ alias Berrypod.Pages
+ alias Berrypod.Pages.Defaults
alias Berrypod.Settings
alias Berrypod.Settings.ThemeSettings
alias Berrypod.Media
@@ -76,22 +78,26 @@ defmodule BerrypodWeb.ErrorHTML do
{theme_settings, generated_css} = load_theme_data()
logo_image = safe_load(&Media.get_logo/0)
header_image = safe_load(&Media.get_header/0)
-
- products = safe_load(fn -> Products.list_visible_products(limit: 4) end) || []
categories = safe_load(fn -> Products.list_categories() end) || []
+ page = safe_load(fn -> Pages.get_page("error") end) || Defaults.for_slug("error")
+
assigns =
assigns
|> Map.put(:theme_settings, theme_settings)
|> Map.put(:generated_css, generated_css)
|> Map.put(:logo_image, logo_image)
|> Map.put(:header_image, header_image)
- |> Map.put(:products, products)
|> Map.put(:categories, categories)
|> Map.put(:mode, :shop)
|> Map.put(:cart_items, [])
|> Map.put(:cart_count, 0)
|> Map.put(:cart_subtotal, "£0.00")
+ |> Map.put(:page, page)
+
+ # Load block data (e.g. products for featured_products block)
+ extra = safe_load(fn -> Pages.load_block_data(page.blocks, assigns) end) || %{}
+ assigns = Map.merge(assigns, extra)
~H"""
@@ -118,20 +124,7 @@ defmodule BerrypodWeb.ErrorHTML do
data-layout={@theme_settings.layout_width}
data-shadow={@theme_settings.card_shadow}
>
-
+