Navigation in the admin: header and footer links, page titles, hidden pages, Shop
Pages -> Navigation (migration 075) edits the header's pages and buttons and the footer's links; navConfig.ts is now only the defaults. Page titles and intros move there from Site settings. A hidden page answers Not found below viewer (server and app) and is out of the menus and sitemap; signed in, it shows with a bar. Adds a /shop page of sections, hidden, with its header button. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b49497cc59
commit
0cc2a3f721
30 changed files with 716 additions and 216 deletions
122
server/src/migrations/075_site_nav.sql
Normal file
122
server/src/migrations/075_site_nav.sql
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 075 SITE NAVIGATION
|
||||
--
|
||||
-- Pages → Navigation edits what navConfig.ts used to fix in code:
|
||||
-- the header's links and buttons, the footer's, and each page's
|
||||
-- title, intro and whether it is hidden. navConfig.ts stays as the
|
||||
-- defaults the app starts from before this arrives.
|
||||
--
|
||||
-- site_nav the editor's one row ('site')
|
||||
-- site_nav_links every link, in order, by where it shows:
|
||||
-- main the header's pages (sections drop
|
||||
-- down under each); with a parent, in
|
||||
-- that page's dropdown instead
|
||||
-- action the header's buttons, right side
|
||||
-- (and the phone menu's list under
|
||||
-- the pages); a filled one also sits
|
||||
-- beside the footer's logo
|
||||
-- footer the footer's Get in Touch list
|
||||
-- legal the footer's bottom row
|
||||
-- site_nav_pages a static page's title and intro (the page's
|
||||
-- heading and its search text) over site.json's,
|
||||
-- and is_hidden: a hidden page is out of the nav
|
||||
-- and the sitemap and answers Not found to anyone
|
||||
-- below viewer (pageMeta.js, siteNav.js)
|
||||
--
|
||||
-- site_setting_pages (Site settings → Page titles and intros) moves
|
||||
-- into site_nav_pages and is dropped.
|
||||
--
|
||||
-- The Shop page: site_pages takes 'shop' (a page of sections like
|
||||
-- the others), rebuilt since its CHECK can't change in place. It
|
||||
-- starts hidden, with its header button.
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
CREATE TABLE site_nav (
|
||||
id TEXT PRIMARY KEY CHECK (id = 'site'),
|
||||
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
) STRICT;
|
||||
|
||||
INSERT INTO site_nav (id) VALUES ('site');
|
||||
|
||||
CREATE TABLE site_nav_links (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
nav_id TEXT NOT NULL REFERENCES site_nav (id) ON DELETE CASCADE,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
place TEXT NOT NULL CHECK (place IN ('main', 'action', 'footer', 'legal')),
|
||||
label TEXT NOT NULL,
|
||||
-- '/retreats', '/organization#contact', or an https:// address
|
||||
path TEXT NOT NULL,
|
||||
-- main links only: the page whose dropdown it sits in
|
||||
parent_path TEXT,
|
||||
-- action links only: null is the outlined button
|
||||
style TEXT CHECK (style IN ('filled')),
|
||||
new_tab INTEGER NOT NULL DEFAULT 0 CHECK (new_tab IN (0, 1))
|
||||
) STRICT;
|
||||
CREATE INDEX site_nav_links_order_idx ON site_nav_links (nav_id, sort_order);
|
||||
|
||||
INSERT INTO site_nav_links (nav_id, sort_order, place, label, path, parent_path, style, new_tab) VALUES
|
||||
('site', 0, 'main', 'Home', '/', NULL, NULL, 0),
|
||||
('site', 1, 'main', 'Retreats', '/retreats', NULL, NULL, 0),
|
||||
('site', 2, 'main', 'Community', '/community', NULL, NULL, 0),
|
||||
('site', 3, 'main', 'Resources', '/resources', NULL, NULL, 0),
|
||||
('site', 4, 'main', 'Organization', '/organization', NULL, NULL, 0),
|
||||
('site', 5, 'main', 'History', '/history', NULL, NULL, 0),
|
||||
('site', 6, 'action', 'Shop', '/shop', NULL, NULL, 0),
|
||||
('site', 7, 'action', 'Contact Us', '/organization#contact', NULL, NULL, 0),
|
||||
('site', 8, 'action', 'Give', '/give', NULL, 'filled', 1),
|
||||
('site', 9, 'footer', 'Feedback', '/feedback', NULL, NULL, 0),
|
||||
('site', 10, 'footer', 'Request', '/request', NULL, NULL, 0),
|
||||
('site', 11, 'footer', 'Contact Us', '/organization#contact', NULL, NULL, 0),
|
||||
('site', 12, 'legal', 'Privacy Policy', '/privacy', NULL, NULL, 0),
|
||||
('site', 13, 'legal', 'Terms of Service', '/terms', NULL, NULL, 0);
|
||||
|
||||
CREATE TABLE site_nav_pages (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
nav_id TEXT NOT NULL REFERENCES site_nav (id) ON DELETE CASCADE,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
path TEXT NOT NULL, -- '/retreats', a key of site.json's pages
|
||||
title TEXT, -- null: site.json's
|
||||
description TEXT, -- null: site.json's
|
||||
is_hidden INTEGER NOT NULL DEFAULT 0 CHECK (is_hidden IN (0, 1)),
|
||||
UNIQUE (nav_id, path)
|
||||
) STRICT;
|
||||
|
||||
INSERT INTO site_nav_pages (nav_id, sort_order, path, title, description)
|
||||
SELECT 'site', sort_order, path, title, description
|
||||
FROM site_setting_pages WHERE settings_id = 'site';
|
||||
|
||||
INSERT INTO site_nav_pages (nav_id, sort_order, path, is_hidden)
|
||||
VALUES ('site', (SELECT coalesce(max(sort_order) + 1, 0) FROM site_nav_pages), '/shop', 1);
|
||||
|
||||
DROP TABLE site_setting_pages;
|
||||
|
||||
-- site_pages, with 'shop'.
|
||||
CREATE TABLE site_pages_new (
|
||||
id TEXT PRIMARY KEY
|
||||
CHECK (id IN ('community', 'retreats', 'resources', 'organization', 'history', 'shop')),
|
||||
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
) STRICT;
|
||||
|
||||
INSERT INTO site_pages_new (id, updated_at) SELECT id, updated_at FROM site_pages;
|
||||
INSERT INTO site_pages_new (id) VALUES ('shop');
|
||||
|
||||
-- page_sections names site_pages; legacy mode leaves it alone
|
||||
-- through the rename.
|
||||
PRAGMA legacy_alter_table = ON;
|
||||
DROP TABLE site_pages;
|
||||
ALTER TABLE site_pages_new RENAME TO site_pages;
|
||||
PRAGMA legacy_alter_table = OFF;
|
||||
|
||||
CREATE TRIGGER site_nav_touch
|
||||
AFTER UPDATE ON site_nav
|
||||
FOR EACH ROW WHEN new.updated_at = old.updated_at
|
||||
BEGIN
|
||||
UPDATE site_nav SET updated_at = datetime('now') WHERE id = new.id;
|
||||
END;
|
||||
|
||||
CREATE TRIGGER site_pages_touch
|
||||
AFTER UPDATE ON site_pages
|
||||
FOR EACH ROW WHEN new.updated_at = old.updated_at
|
||||
BEGIN
|
||||
UPDATE site_pages SET updated_at = datetime('now') WHERE id = new.id;
|
||||
END;
|
||||
Loading…
Add table
Add a link
Reference in a new issue