add nav editors to Site tab with live preview
All checks were successful
deploy / deploy (push) Successful in 3m27s

- Add header and footer nav editors to Site tab with drag-to-reorder,
  add/remove items, and destination picker (pages, collections, external)
- Live preview updates as you edit nav items
- Remove legacy /admin/navigation page and controller (was saving to
  Settings table, now uses nav_items table)
- Update error_html.ex and pages/editor.ex to load nav from nav_items table
- Update link_scanner to read from nav_items table, edit path now /?edit=site
- Add Site.default_header_nav/0 and default_footer_nav/0 for previews/errors
- Remove fallback logic from theme_hook.ex (database is now source of truth)
- Seed default nav items and social links during setup

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-03-28 22:19:48 +00:00
parent 5a5103bc42
commit 7c07805df8
24 changed files with 1068 additions and 1130 deletions

View File

@@ -17,28 +17,6 @@ defmodule BerrypodWeb.ThemeHook do
alias Berrypod.{Products, Settings, Site, Media}
alias Berrypod.Theme.{CSSCache, CSSGenerator}
@default_header_nav [
%{"label" => "Home", "href" => "/", "slug" => "home"},
%{
"label" => "Shop",
"href" => "/collections/all",
"slug" => "collection",
"active_slugs" => ["collection", "pdp"]
},
%{"label" => "About", "href" => "/about", "slug" => "about"},
%{"label" => "Contact", "href" => "/contact", "slug" => "contact"}
]
@default_footer_nav [
%{"label" => "Delivery & returns", "href" => "/delivery", "slug" => "delivery"},
%{"label" => "Privacy policy", "href" => "/privacy", "slug" => "privacy"},
%{"label" => "Terms of service", "href" => "/terms", "slug" => "terms"},
%{"label" => "Contact", "href" => "/contact", "slug" => "contact"}
]
def default_header_nav, do: @default_header_nav
def default_footer_nav, do: @default_footer_nav
def on_mount(:mount_theme, _params, _session, socket) do
theme_settings = Settings.get_theme_settings()
@@ -92,13 +70,11 @@ defmodule BerrypodWeb.ThemeHook do
end
defp load_header_nav do
items = Site.nav_items_for_shop("header")
if items == [], do: @default_header_nav, else: add_active_slugs(items)
Site.nav_items_for_shop("header") |> add_active_slugs()
end
defp load_footer_nav do
items = Site.nav_items_for_shop("footer")
if items == [], do: @default_footer_nav, else: items
Site.nav_items_for_shop("footer")
end
# Add active_slugs for Shop nav item to highlight on collection and pdp pages