add Site context with social links editor and site-wide settings
Some checks failed
deploy / deploy (push) Has been cancelled
Some checks failed
deploy / deploy (push) Has been cancelled
- Add Site context for managing site-wide content (social links, nav items, announcement bar, footer content) - Add SocialLink schema with URL normalization and platform auto-detection supporting 40+ platforms via host and 25+ via URI scheme - Add NavItem schema for header/footer navigation (editor UI coming next) - Add SiteEditor component with collapsible sections for each content type - Wire social links card block and footer to use database data - Filter empty URLs from display in shop components - Add DetailsPreserver hook to preserve collapsible section state - Add comprehensive tests for Site context and SocialLink functions - Remove unused helper functions from onboarding to fix compiler warnings - Move sync_edit_url_param helper to group handle_editor_event clauses Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
16
priv/repo/migrations/20260327163916_create_social_links.exs
Normal file
16
priv/repo/migrations/20260327163916_create_social_links.exs
Normal file
@@ -0,0 +1,16 @@
|
||||
defmodule Berrypod.Repo.Migrations.CreateSocialLinks do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:social_links, primary_key: false) do
|
||||
add :id, :binary_id, primary_key: true
|
||||
add :platform, :string, null: false
|
||||
add :url, :string, null: false
|
||||
add :position, :integer, null: false, default: 0
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
create index(:social_links, [:position])
|
||||
end
|
||||
end
|
||||
19
priv/repo/migrations/20260327163919_create_nav_items.exs
Normal file
19
priv/repo/migrations/20260327163919_create_nav_items.exs
Normal file
@@ -0,0 +1,19 @@
|
||||
defmodule Berrypod.Repo.Migrations.CreateNavItems do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:nav_items, primary_key: false) do
|
||||
add :id, :binary_id, primary_key: true
|
||||
add :location, :string, null: false
|
||||
add :label, :string, null: false
|
||||
add :url, :string, null: false
|
||||
add :page_id, references(:pages, type: :binary_id, on_delete: :nilify_all)
|
||||
add :position, :integer, null: false, default: 0
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
create index(:nav_items, [:location, :position])
|
||||
create index(:nav_items, [:page_id])
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,43 @@
|
||||
defmodule Berrypod.Repo.Migrations.AllowNullSocialLinkUrl do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
# Allow blank URLs so users can add a link and then paste the URL
|
||||
# SQLite doesn't support ALTER COLUMN, so we recreate the table
|
||||
execute(
|
||||
"CREATE TABLE social_links_new (
|
||||
id BLOB PRIMARY KEY,
|
||||
platform TEXT NOT NULL,
|
||||
url TEXT,
|
||||
position INTEGER NOT NULL DEFAULT 0,
|
||||
inserted_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
)",
|
||||
"DROP TABLE social_links_new"
|
||||
)
|
||||
|
||||
execute(
|
||||
"INSERT INTO social_links_new SELECT * FROM social_links",
|
||||
"INSERT INTO social_links SELECT * FROM social_links_new"
|
||||
)
|
||||
|
||||
execute(
|
||||
"DROP TABLE social_links",
|
||||
"CREATE TABLE social_links (
|
||||
id BLOB PRIMARY KEY,
|
||||
platform TEXT NOT NULL,
|
||||
url TEXT NOT NULL,
|
||||
position INTEGER NOT NULL DEFAULT 0,
|
||||
inserted_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
)"
|
||||
)
|
||||
|
||||
execute(
|
||||
"ALTER TABLE social_links_new RENAME TO social_links",
|
||||
"ALTER TABLE social_links RENAME TO social_links_new"
|
||||
)
|
||||
|
||||
create index(:social_links, [:position])
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user