add data-driven navigation with admin editor
All checks were successful
deploy / deploy (push) Successful in 1m34s

Replace hardcoded header, footer and mobile nav with settings-driven
loops. Nav items stored as JSON via Settings, loaded in ThemeHook with
sensible defaults. New admin navigation editor at /admin/navigation
for add/remove/reorder/save/reset. Mobile bottom nav also driven from
header nav items with icon mapping by slug.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-28 11:18:37 +00:00
parent 045be2ed7e
commit 3a243151af
11 changed files with 725 additions and 123 deletions

View File

@@ -94,6 +94,14 @@ defmodule BerrypodWeb.ErrorHTML do
|> Map.put(:cart_count, 0)
|> Map.put(:cart_subtotal, "£0.00")
|> Map.put(:page, page)
|> Map.put(
:header_nav_items,
load_nav("header_nav", &BerrypodWeb.ThemeHook.default_header_nav/0)
)
|> Map.put(
:footer_nav_items,
load_nav("footer_nav", &BerrypodWeb.ThemeHook.default_footer_nav/0)
)
# Load block data (e.g. products for featured_products block)
extra = safe_load(fn -> Pages.load_block_data(page.blocks, assigns) end) || %{}
@@ -159,4 +167,11 @@ defmodule BerrypodWeb.ErrorHTML do
_ -> nil
end
end
defp load_nav(key, default_fn) do
case safe_load(fn -> Settings.get_setting(key) end) do
items when is_list(items) -> items
_ -> default_fn.()
end
end
end