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
104
src/lib/adminSchema/siteNav.ts
Normal file
104
src/lib/adminSchema/siteNav.ts
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
import siteConfiguration from "../../../site.json";
|
||||
|
||||
/* ── Navigation (075_site_nav.sql) ───────────────────────────────
|
||||
Pages → Navigation: the header's and footer's links, and each
|
||||
static page's title, intro and whether it's hidden. Admins and up
|
||||
save it, since hiding takes a page off the site. Server side:
|
||||
server/src/admin-schema/siteNav.js; the site reads it through
|
||||
server/src/siteNav.js and src/lib/useSiteNav.ts. */
|
||||
|
||||
const SITE_PAGES: [string, string][] = Object.entries(siteConfiguration.pages).map(
|
||||
([path, page]) => [path, `${page.title} (${path})`],
|
||||
);
|
||||
|
||||
const PLACES: [string, string][] = [
|
||||
["main", "Header: pages"],
|
||||
["action", "Header: buttons"],
|
||||
["footer", "Footer: Get in Touch"],
|
||||
["legal", "Footer: bottom row"],
|
||||
];
|
||||
|
||||
const placeLabel = (place) => PLACES.find(([key]) => key === place)?.[1];
|
||||
|
||||
export const siteNav = {
|
||||
key: "navigation",
|
||||
label: "Navigation",
|
||||
singular: "navigation",
|
||||
idLabel: "Navigation",
|
||||
singleton: "site",
|
||||
writeRole: "admin",
|
||||
|
||||
list: { columns: [], filters: [] },
|
||||
|
||||
groups: [],
|
||||
|
||||
children: [
|
||||
{
|
||||
key: "links",
|
||||
label: "Links",
|
||||
note: "Top to bottom, in the order each place shows them. A link to a hidden page is only shown to signed-in admin accounts. A header page lists its sections under it by itself (Pages → the page).",
|
||||
addLabel: "Add link",
|
||||
title: (row) => (row.label ? `${row.label} · ${placeLabel(row.place) ?? "No place"}` : "New link"),
|
||||
blank: { place: "", label: "", path: "", parent_path: "", style: "", new_tab: 0 },
|
||||
fields: [
|
||||
{ path: "place", label: "Shows in", widget: "select", options: PLACES, required: true },
|
||||
{ path: "label", label: "Label", required: true, help: "eg. Shop" },
|
||||
{
|
||||
path: "path",
|
||||
label: "Link",
|
||||
required: true,
|
||||
full: true,
|
||||
help: "A page on the site, a section of one, or an address elsewhere, eg. /shop, /organization#contact or https://www.bonfire.com/store/…",
|
||||
},
|
||||
{
|
||||
path: "parent_path",
|
||||
label: "Under page",
|
||||
widget: "select",
|
||||
options: [["/", "Home (/)"], ...SITE_PAGES],
|
||||
blankLabel: "Default: its own place in the header",
|
||||
help: "Lists it in that page's menu, after its sections, instead of in the header's row",
|
||||
when: { path: "place", value: "main" },
|
||||
},
|
||||
{
|
||||
path: "style",
|
||||
label: "Style",
|
||||
widget: "select",
|
||||
options: [["filled", "Filled, like Give (also beside the footer's logo)"]],
|
||||
blankLabel: "Default: outlined",
|
||||
when: { path: "place", value: "action" },
|
||||
},
|
||||
{ path: "new_tab", label: "Opens in a new tab", widget: "checkbox" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "pages",
|
||||
label: "Pages",
|
||||
note: "A page's heading and intro (also its search title and description), and whether it's hidden. A hidden page is out of the menus and the sitemap and says Not found to everyone but signed-in admin accounts, who see it with a bar saying it's hidden. Blank fields keep site.json's. A page not listed here shows as site.json has it.",
|
||||
addLabel: "Add page",
|
||||
title: (row) =>
|
||||
`${SITE_PAGES.find(([path]) => path === row.path)?.[1] ?? "New page"}${row.is_hidden ? " · Hidden" : ""}`,
|
||||
blank: { path: "", title: "", description: "", is_hidden: 0 },
|
||||
fields: [
|
||||
{ path: "path", label: "Page", widget: "select", options: SITE_PAGES, required: true },
|
||||
{
|
||||
path: "is_hidden",
|
||||
label: "Hidden",
|
||||
widget: "checkbox",
|
||||
help: "Not found to everyone but signed-in admin accounts, eg. a page that isn't done",
|
||||
},
|
||||
{
|
||||
path: "title",
|
||||
label: "Title",
|
||||
help: (row) => (row?.path ? `Default: ${siteConfiguration.pages[row.path]?.title ?? ""}` : undefined),
|
||||
},
|
||||
{
|
||||
path: "description",
|
||||
label: "Intro",
|
||||
widget: "textarea",
|
||||
full: true,
|
||||
help: (row) => (row?.path ? `Default: ${siteConfiguration.pages[row.path]?.description ?? ""}` : undefined),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue