@marktiderman/genesis-sites 0.7.6 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -8
- package/SKILL.md +10 -0
- package/dist/assets/form-island.da6c662a73.js +51 -0
- package/dist/assets/{islands.33a445f34e.js → islands.83aaf5e0df.js} +1 -1
- package/dist/assets/sites-forms.bac9a6aafd.css +10 -0
- package/dist/assets/sites-forms.css +1 -1
- package/dist/assets/sites.323090ba26.css +2 -0
- package/dist/assets/sites.css +1 -1
- package/dist/assets.generated-YGLB7VKL.js +3 -0
- package/dist/{assets.generated-LLUGUUWZ.js.map → assets.generated-YGLB7VKL.js.map} +1 -1
- package/dist/blocks.js +2 -1
- package/dist/blocks.js.map +1 -1
- package/dist/{chunk-IU6AI75R.js → chunk-6CXTOPYI.js} +343 -158
- package/dist/chunk-6CXTOPYI.js.map +1 -0
- package/dist/{chunk-7E3YGYVH.js → chunk-FMQTSXJN.js} +26 -12
- package/dist/chunk-FMQTSXJN.js.map +1 -0
- package/dist/{chunk-SMJMXQ3T.js → chunk-I767PDBR.js} +260 -62
- package/dist/chunk-I767PDBR.js.map +1 -0
- package/dist/chunk-MXV2HOJO.js +19 -0
- package/dist/chunk-MXV2HOJO.js.map +1 -0
- package/dist/{chunk-KY4ALBVH.js → chunk-QE7KS2JS.js} +65 -7
- package/dist/chunk-QE7KS2JS.js.map +1 -0
- package/dist/{chunk-VJ4HOFBA.js → chunk-YAMQ2JKO.js} +20 -9
- package/dist/chunk-YAMQ2JKO.js.map +1 -0
- package/dist/editor.d.ts +22 -14
- package/dist/editor.js +701 -157
- package/dist/editor.js.map +1 -1
- package/dist/handler-J5BCH2VW.js +10 -0
- package/dist/{handler-UMGSZY33.js.map → handler-J5BCH2VW.js.map} +1 -1
- package/dist/import.d.ts +3 -3
- package/dist/index.d.ts +51 -10
- package/dist/index.js +3 -3
- package/dist/redirects-BNSD9MKa.d.ts +43 -0
- package/dist/{registry-BIijndsq.d.ts → registry-BPn-tDlL.d.ts} +75 -0
- package/dist/sections.d.ts +86 -4
- package/dist/sections.js +2 -2
- package/dist/{store-BImtGmoF.d.ts → store-B_GMH42V.d.ts} +2 -2
- package/dist/supabase.d.ts +4 -4
- package/dist/supabase.js +3 -3
- package/dist/{templates-kA-jrnWA.d.ts → templates-CFSSG1iU.d.ts} +2 -2
- package/dist/templates.d.ts +3 -3
- package/dist/{theme-Cg-inpk5.d.ts → theme-Dw42GDI_.d.ts} +1 -1
- package/dist/web.d.ts +21 -11
- package/dist/web.js +5 -5
- package/migrations/0003_genesis_sites_post_dates.sql +117 -0
- package/migrations/tests/0003_genesis_sites_post_dates.test.sql +76 -0
- package/package.json +8 -4
- package/dist/assets/form-island.defb8daccc.js +0 -51
- package/dist/assets/sites-forms.aff23b5617.css +0 -10
- package/dist/assets/sites.5b3f64c627.css +0 -2
- package/dist/assets.generated-LLUGUUWZ.js +0 -3
- package/dist/chunk-7E3YGYVH.js.map +0 -1
- package/dist/chunk-IU6AI75R.js.map +0 -1
- package/dist/chunk-KY4ALBVH.js.map +0 -1
- package/dist/chunk-RLYO6VVP.js +0 -19
- package/dist/chunk-RLYO6VVP.js.map +0 -1
- package/dist/chunk-SMJMXQ3T.js.map +0 -1
- package/dist/chunk-VJ4HOFBA.js.map +0 -1
- package/dist/handler-UMGSZY33.js +0 -10
package/dist/editor.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { starterSite, exampleBrands, landingDirectory, landingPath, landingSlugProblems, landingDirectoryProblems, landingMoves, isLandingPage, landingPage, landingPages, landingSlugOf } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
import { starterSite, exampleBrands, landingDirectory, landingPath, landingSlugProblems, landingDirectoryProblems, landingMoves, redirectDestinations, isLandingPage, landingPage, removeRedirect, landingPages, redirectFromProblems, redirectToProblems, upsertRedirect, landingSlugOf } from './chunk-QE7KS2JS.js';
|
|
2
|
+
import './chunk-I767PDBR.js';
|
|
3
3
|
import './chunk-VZUDRPFG.js';
|
|
4
|
-
import { stableHash, isConflict, prepareRelease, PublishBlockedError, SiteConflictError, siteTheme, brandDisplayName, themeCss, migrateNode, migratePage, migrateSite } from './chunk-
|
|
5
|
-
import { getSection, sectionJsonSchema, listSections, SECTION_CATEGORIES, PageDoc, SiteDoc, newSectionId } from './chunk-
|
|
4
|
+
import { stableHash, isConflict, prepareRelease, PublishBlockedError, SiteConflictError, siteTheme, brandDisplayName, themeCss, migrateNode, migratePage, migrateSite } from './chunk-YAMQ2JKO.js';
|
|
5
|
+
import { getSection, sectionJsonSchema, listSections, SECTION_CATEGORIES, NOT_FOUND_PATH, PageDoc, SiteDoc, notFoundPageDoc, newSectionId, isNotFoundPage, SeoDefaults } from './chunk-6CXTOPYI.js';
|
|
6
6
|
import { isSafeImageSrc, DEFAULT_RESERVED_PATHS, pagePathProblems, isSafeHref } from './chunk-MU2Z2C4F.js';
|
|
7
|
-
import * as
|
|
7
|
+
import * as React10 from 'react';
|
|
8
8
|
import { createContext, useContext } from 'react';
|
|
9
9
|
import { createUsePuck, Puck } from '@puckeditor/core';
|
|
10
10
|
export { createUsePuck, usePuck } from '@puckeditor/core';
|
|
11
|
-
import { Undo2, Redo2, Monitor, Tablet, Smartphone, Plus,
|
|
11
|
+
import { Undo2, Redo2, Monitor, Tablet, Smartphone, Plus, ArrowRight, Trash2, Megaphone, CheckCircle2, Eye, ExternalLink, RotateCcw, Home, FileText, ArrowUp, ArrowDown, FileQuestion, AlertCircle, AlertTriangle } from 'lucide-react';
|
|
12
12
|
import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from '@marktiderman/genesis-ui/alert-dialog';
|
|
13
13
|
import { Alert, AlertTitle, AlertDescription } from '@marktiderman/genesis-ui/alert';
|
|
14
14
|
import { Button } from '@marktiderman/genesis-ui/button';
|
|
@@ -27,6 +27,8 @@ import { Badge } from '@marktiderman/genesis-ui/badge';
|
|
|
27
27
|
import { RadioGroup, RadioGroupItem } from '@marktiderman/genesis-ui/radio-group';
|
|
28
28
|
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@marktiderman/genesis-ui/select';
|
|
29
29
|
import { Separator } from '@marktiderman/genesis-ui/separator';
|
|
30
|
+
import { Checkbox } from '@marktiderman/genesis-ui/checkbox';
|
|
31
|
+
import { Combobox } from '@marktiderman/genesis-ui/combobox';
|
|
30
32
|
|
|
31
33
|
var IMAGE_TYPES = ["image/png", "image/jpeg", "image/webp", "image/avif", "image/gif"];
|
|
32
34
|
async function dimensions(file) {
|
|
@@ -47,18 +49,18 @@ function uploadProblem(file, maxBytes = 10 * 1024 * 1024) {
|
|
|
47
49
|
}
|
|
48
50
|
function AssetPicker({ open, siteId, store, assets, current, altElsewhere = false, onDone }) {
|
|
49
51
|
const canUpload = Boolean(assets?.upload || store.putAsset);
|
|
50
|
-
const [tab, setTab] =
|
|
51
|
-
const [file, setFile] =
|
|
52
|
-
const [url, setUrl] =
|
|
53
|
-
const [chosen, setChosen] =
|
|
54
|
-
const [alt, setAlt] =
|
|
55
|
-
const [decorative, setDecorative] =
|
|
56
|
-
const [library, setLibrary] =
|
|
57
|
-
const [uploaded, setUploaded] =
|
|
58
|
-
const [busy, setBusy] =
|
|
59
|
-
const [error, setError] =
|
|
60
|
-
const id =
|
|
61
|
-
|
|
52
|
+
const [tab, setTab] = React10.useState(canUpload ? "upload" : "link");
|
|
53
|
+
const [file, setFile] = React10.useState(null);
|
|
54
|
+
const [url, setUrl] = React10.useState(current?.src ?? "");
|
|
55
|
+
const [chosen, setChosen] = React10.useState(null);
|
|
56
|
+
const [alt, setAlt] = React10.useState(current?.alt ?? "");
|
|
57
|
+
const [decorative, setDecorative] = React10.useState(current?.decorative === true);
|
|
58
|
+
const [library, setLibrary] = React10.useState(null);
|
|
59
|
+
const [uploaded, setUploaded] = React10.useState([]);
|
|
60
|
+
const [busy, setBusy] = React10.useState(false);
|
|
61
|
+
const [error, setError] = React10.useState(null);
|
|
62
|
+
const id = React10.useId();
|
|
63
|
+
React10.useEffect(() => {
|
|
62
64
|
if (!open) return;
|
|
63
65
|
setFile(null);
|
|
64
66
|
setChosen(null);
|
|
@@ -584,9 +586,9 @@ function RichTextField({ field, id, value, onChange, readOnly }) {
|
|
|
584
586
|
}
|
|
585
587
|
function LinesField({ field, id, value, onChange, readOnly }) {
|
|
586
588
|
const max = field.metadata?.maxItems;
|
|
587
|
-
const [text, setText] =
|
|
588
|
-
const lastSent =
|
|
589
|
-
|
|
589
|
+
const [text, setText] = React10.useState(() => (value ?? []).join("\n"));
|
|
590
|
+
const lastSent = React10.useRef(value);
|
|
591
|
+
React10.useEffect(() => {
|
|
590
592
|
if (JSON.stringify(value ?? []) !== JSON.stringify(lastSent.current ?? [])) setText((value ?? []).join("\n"));
|
|
591
593
|
}, [value]);
|
|
592
594
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
@@ -602,9 +604,9 @@ function LinesField({ field, id, value, onChange, readOnly }) {
|
|
|
602
604
|
onChange: (e) => {
|
|
603
605
|
const next = e.currentTarget.value;
|
|
604
606
|
setText(next);
|
|
605
|
-
const
|
|
606
|
-
lastSent.current =
|
|
607
|
-
onChange(
|
|
607
|
+
const lines2 = next.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
608
|
+
lastSent.current = lines2;
|
|
609
|
+
onChange(lines2);
|
|
608
610
|
}
|
|
609
611
|
}
|
|
610
612
|
),
|
|
@@ -818,7 +820,7 @@ var CATEGORY_TITLES = {
|
|
|
818
820
|
footer: "Footer"
|
|
819
821
|
};
|
|
820
822
|
var META = /* @__PURE__ */ new Set(["puck", "editMode", "id"]);
|
|
821
|
-
var SectionBoundary = class extends
|
|
823
|
+
var SectionBoundary = class extends React10.Component {
|
|
822
824
|
state = { error: null };
|
|
823
825
|
static getDerivedStateFromError(error) {
|
|
824
826
|
return { error };
|
|
@@ -831,10 +833,10 @@ var SectionBoundary = class extends React8.Component {
|
|
|
831
833
|
return this.props.children;
|
|
832
834
|
}
|
|
833
835
|
};
|
|
834
|
-
function Problem({ title, lines }) {
|
|
836
|
+
function Problem({ title, lines: lines2 }) {
|
|
835
837
|
return /* @__PURE__ */ jsxs("div", { role: "alert", style: { margin: "1rem", padding: "1rem 1.25rem", border: "2px dashed currentColor", borderRadius: "0.5rem", fontFamily: "system-ui, sans-serif", fontSize: "0.875rem", lineHeight: 1.5 }, children: [
|
|
836
838
|
/* @__PURE__ */ jsx("strong", { children: title }),
|
|
837
|
-
/* @__PURE__ */ jsx("ul", { style: { margin: "0.5rem 0 0", paddingLeft: "1.25rem" }, children:
|
|
839
|
+
/* @__PURE__ */ jsx("ul", { style: { margin: "0.5rem 0 0", paddingLeft: "1.25rem" }, children: lines2.map((l, i) => /* @__PURE__ */ jsx("li", { children: l }, i)) })
|
|
838
840
|
] });
|
|
839
841
|
}
|
|
840
842
|
function Tag({ children }) {
|
|
@@ -936,7 +938,7 @@ function createEditorConfig(options2 = {}) {
|
|
|
936
938
|
return { config, components: info, slotKeys: (type) => slots.get(sectionTypeOf(type)) ?? [] };
|
|
937
939
|
}
|
|
938
940
|
var usePuck = createUsePuck();
|
|
939
|
-
var EditorLockContext =
|
|
941
|
+
var EditorLockContext = React10.createContext(false);
|
|
940
942
|
var fieldId = (p) => p.id ?? `gs-field-${p.name.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
|
|
941
943
|
function FieldShell({ id, label, children }) {
|
|
942
944
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 py-1", children: [
|
|
@@ -1002,10 +1004,10 @@ function ComponentItem({ name, info, announce }) {
|
|
|
1002
1004
|
const data = usePuck((s) => s.appState.data);
|
|
1003
1005
|
const meta = info.get(name);
|
|
1004
1006
|
const type = sectionTypeOf(name);
|
|
1005
|
-
const used =
|
|
1007
|
+
const used = React10.useMemo(() => countTypes(data).get(type) ?? 0, [data, type]);
|
|
1006
1008
|
const full = meta?.limit !== void 0 && used >= meta.limit;
|
|
1007
1009
|
const dispatch = usePuck((s) => s.dispatch);
|
|
1008
|
-
const locked =
|
|
1010
|
+
const locked = React10.useContext(EditorLockContext);
|
|
1009
1011
|
const label = meta?.label ?? name;
|
|
1010
1012
|
const add = () => {
|
|
1011
1013
|
if (locked) return;
|
|
@@ -1018,8 +1020,8 @@ function ComponentItem({ name, info, announce }) {
|
|
|
1018
1020
|
scrollCanvasTo(id, ref.current?.ownerDocument);
|
|
1019
1021
|
announce?.(`${label} added at the end of the ${zone === "root:header" ? "header" : zone === "root:footer" ? "footer" : "page"}. Its fields are open; Up and Down move it.`);
|
|
1020
1022
|
};
|
|
1021
|
-
const ref =
|
|
1022
|
-
|
|
1023
|
+
const ref = React10.useRef(null);
|
|
1024
|
+
React10.useEffect(() => {
|
|
1023
1025
|
const copy = ref.current?.closest('[class*="draggableBg"]');
|
|
1024
1026
|
if (copy) {
|
|
1025
1027
|
copy.setAttribute("aria-hidden", "true");
|
|
@@ -1050,9 +1052,9 @@ function SectionActions({ info, announce }) {
|
|
|
1050
1052
|
const getSelectorForId = usePuck((s) => s.getSelectorForId);
|
|
1051
1053
|
const getItemBySelector = usePuck((s) => s.getItemBySelector);
|
|
1052
1054
|
const dispatch = usePuck((s) => s.dispatch);
|
|
1053
|
-
const locked =
|
|
1054
|
-
const upRef =
|
|
1055
|
-
const downRef =
|
|
1055
|
+
const locked = React10.useContext(EditorLockContext);
|
|
1056
|
+
const upRef = React10.useRef(null);
|
|
1057
|
+
const downRef = React10.useRef(null);
|
|
1056
1058
|
if (!selected) return null;
|
|
1057
1059
|
const id = String(selected.props.id);
|
|
1058
1060
|
const selector = getSelectorForId(id);
|
|
@@ -1161,6 +1163,7 @@ async function publishSite(store, siteId, options2) {
|
|
|
1161
1163
|
}
|
|
1162
1164
|
function pathProblems(path, pages, options2 = {}) {
|
|
1163
1165
|
const problems = pagePathProblems(path, options2.reserved ?? DEFAULT_RESERVED_PATHS);
|
|
1166
|
+
if (path === NOT_FOUND_PATH && !options2.notFoundPage) problems.push(`${NOT_FOUND_PATH} is the site's 404 page: make it under Page not found.`);
|
|
1164
1167
|
if (pages.some((p) => p.path === path && p.id !== options2.except)) problems.push(`A page is already at ${path}.`);
|
|
1165
1168
|
return problems;
|
|
1166
1169
|
}
|
|
@@ -1190,6 +1193,13 @@ function pageTemplates() {
|
|
|
1190
1193
|
const doc = landingPage({ brand, message: { headline: title } }).pages[0].doc;
|
|
1191
1194
|
return { ...doc, root: { props: { ...doc.root.props, title } } };
|
|
1192
1195
|
}
|
|
1196
|
+
},
|
|
1197
|
+
{
|
|
1198
|
+
id: "not-found",
|
|
1199
|
+
label: "404 page",
|
|
1200
|
+
description: "What a visitor sees at an address the site doesn't have.",
|
|
1201
|
+
kind: "page",
|
|
1202
|
+
doc: ({ title }) => notFoundPageDoc({ title })
|
|
1193
1203
|
}
|
|
1194
1204
|
];
|
|
1195
1205
|
const starter = starterSite({ brand: exampleBrands.riverside, message: { headline: "Your headline" } });
|
|
@@ -1225,7 +1235,7 @@ async function createLandingPage(store, siteId, input) {
|
|
|
1225
1235
|
if (!title) throw new Error("Give the landing page a title.");
|
|
1226
1236
|
const draft = await store.getDraft(siteId);
|
|
1227
1237
|
if (!draft) throw new Error(`There's no site ${siteId}, or you can't edit it.`);
|
|
1228
|
-
const directory = landingDirectory(draft.site);
|
|
1238
|
+
const directory = landingDirectory(draft.site, input.defaultDirectory);
|
|
1229
1239
|
const path = landingPath(directory, input.slug);
|
|
1230
1240
|
const problems = landingSlugProblems(directory, input.slug, input.reserved ?? DEFAULT_RESERVED_PATHS);
|
|
1231
1241
|
if ((await store.listPages(siteId)).some((p) => p.path === path)) problems.push(`A page is already at ${path}.`);
|
|
@@ -1238,10 +1248,10 @@ async function moveLandingPage(store, pageId, slug, options2 = {}) {
|
|
|
1238
1248
|
if (!current) throw new Error("That page no longer exists.");
|
|
1239
1249
|
const draft = await store.getDraft(current.siteId);
|
|
1240
1250
|
if (!draft) throw new Error("You can't edit this site.");
|
|
1241
|
-
const directory = landingDirectory(draft.site);
|
|
1251
|
+
const directory = landingDirectory(draft.site, options2.defaultDirectory);
|
|
1242
1252
|
const problems = landingSlugProblems(directory, slug, options2.reserved ?? DEFAULT_RESERVED_PATHS);
|
|
1243
1253
|
if (problems.length) throw new Error(problems.join(" "));
|
|
1244
|
-
return renamePage(store, pageId, landingPath(directory, slug), options2);
|
|
1254
|
+
return renamePage(store, pageId, landingPath(directory, slug), options2.reserved ? { reserved: options2.reserved } : {});
|
|
1245
1255
|
}
|
|
1246
1256
|
async function setLandingDirectory(store, siteId, directory, options2 = {}) {
|
|
1247
1257
|
const reserved = options2.reserved ?? DEFAULT_RESERVED_PATHS;
|
|
@@ -1253,7 +1263,7 @@ async function setLandingDirectory(store, siteId, directory, options2 = {}) {
|
|
|
1253
1263
|
const partly = (err) => moved.length ? new LandingDirectoryError(moved, err) : err;
|
|
1254
1264
|
if (options2.movePages) {
|
|
1255
1265
|
const pages = await store.listPages(siteId);
|
|
1256
|
-
const moves = landingMoves(pages, landingDirectory(before.site), directory);
|
|
1266
|
+
const moves = landingMoves(pages, landingDirectory(before.site, options2.defaultDirectory), directory);
|
|
1257
1267
|
const moving = new Set(moves.map((m) => m.page.id));
|
|
1258
1268
|
const staying = pages.filter((p) => !moving.has(p.id));
|
|
1259
1269
|
const errors = moves.flatMap((m) => pathProblems(m.path, staying, { reserved }));
|
|
@@ -1302,13 +1312,13 @@ function SlugField({ id, directory, slug, problems, onChange, autoFocus }) {
|
|
|
1302
1312
|
] });
|
|
1303
1313
|
}
|
|
1304
1314
|
function NewLandingDialog({ open, onOpenChange, pages, directory, reserved, onCreate }) {
|
|
1305
|
-
const [title, setTitle] =
|
|
1306
|
-
const [slug, setSlug] =
|
|
1307
|
-
const [slugEdited, setSlugEdited] =
|
|
1308
|
-
const [error, setError] =
|
|
1309
|
-
const [busy, setBusy] =
|
|
1310
|
-
const id =
|
|
1311
|
-
|
|
1315
|
+
const [title, setTitle] = React10.useState("");
|
|
1316
|
+
const [slug, setSlug] = React10.useState("");
|
|
1317
|
+
const [slugEdited, setSlugEdited] = React10.useState(false);
|
|
1318
|
+
const [error, setError] = React10.useState(null);
|
|
1319
|
+
const [busy, setBusy] = React10.useState(false);
|
|
1320
|
+
const id = React10.useId();
|
|
1321
|
+
React10.useEffect(() => {
|
|
1312
1322
|
if (open) {
|
|
1313
1323
|
setTitle("");
|
|
1314
1324
|
setSlug("");
|
|
@@ -1381,12 +1391,12 @@ function NewLandingDialog({ open, onOpenChange, pages, directory, reserved, onCr
|
|
|
1381
1391
|
) }) });
|
|
1382
1392
|
}
|
|
1383
1393
|
function MoveLandingDialog({ page, pages, directory, reserved, onClose, onMove }) {
|
|
1384
|
-
const [slug, setSlug] =
|
|
1385
|
-
const [error, setError] =
|
|
1386
|
-
const [busy, setBusy] =
|
|
1387
|
-
const id =
|
|
1394
|
+
const [slug, setSlug] = React10.useState("");
|
|
1395
|
+
const [error, setError] = React10.useState(null);
|
|
1396
|
+
const [busy, setBusy] = React10.useState(false);
|
|
1397
|
+
const id = React10.useId();
|
|
1388
1398
|
const initial = page ? landingSlugOf(directory, page.path) ?? page.path.split("/").pop() ?? "" : "";
|
|
1389
|
-
|
|
1399
|
+
React10.useEffect(() => {
|
|
1390
1400
|
setSlug(initial);
|
|
1391
1401
|
setError(null);
|
|
1392
1402
|
}, [initial]);
|
|
@@ -1439,12 +1449,12 @@ function MoveLandingDialog({ page, pages, directory, reserved, onClose, onMove }
|
|
|
1439
1449
|
) }) });
|
|
1440
1450
|
}
|
|
1441
1451
|
function DirectoryDialog({ open, onOpenChange, pages, directory, reserved, onSave }) {
|
|
1442
|
-
const [value, setValue] =
|
|
1443
|
-
const [movePages, setMovePages] =
|
|
1444
|
-
const [error, setError] =
|
|
1445
|
-
const [busy, setBusy] =
|
|
1446
|
-
const id =
|
|
1447
|
-
|
|
1452
|
+
const [value, setValue] = React10.useState(directory);
|
|
1453
|
+
const [movePages, setMovePages] = React10.useState(true);
|
|
1454
|
+
const [error, setError] = React10.useState(null);
|
|
1455
|
+
const [busy, setBusy] = React10.useState(false);
|
|
1456
|
+
const id = React10.useId();
|
|
1457
|
+
React10.useEffect(() => {
|
|
1448
1458
|
if (open) {
|
|
1449
1459
|
setValue(directory);
|
|
1450
1460
|
setMovePages(true);
|
|
@@ -1508,12 +1518,12 @@ function DirectoryDialog({ open, onOpenChange, pages, directory, reserved, onSav
|
|
|
1508
1518
|
) }) });
|
|
1509
1519
|
}
|
|
1510
1520
|
function LandingPanel(props) {
|
|
1511
|
-
const [adding, setAdding] =
|
|
1512
|
-
const [moving, setMoving] =
|
|
1513
|
-
const [deleting, setDeleting] =
|
|
1514
|
-
const [editingDir, setEditingDir] =
|
|
1521
|
+
const [adding, setAdding] = React10.useState(false);
|
|
1522
|
+
const [moving, setMoving] = React10.useState(null);
|
|
1523
|
+
const [deleting, setDeleting] = React10.useState(null);
|
|
1524
|
+
const [editingDir, setEditingDir] = React10.useState(false);
|
|
1515
1525
|
const list = landingPages(props.pages);
|
|
1516
|
-
const headingId =
|
|
1526
|
+
const headingId = React10.useId();
|
|
1517
1527
|
return /* @__PURE__ */ jsxs("section", { "aria-labelledby": headingId, className: "flex flex-col gap-2", "data-gs-landing": "", children: [
|
|
1518
1528
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1519
1529
|
/* @__PURE__ */ jsx("h2", { id: headingId, className: "text-sm font-semibold", children: "Landing pages" }),
|
|
@@ -1579,16 +1589,16 @@ function LandingPanel(props) {
|
|
|
1579
1589
|
] });
|
|
1580
1590
|
}
|
|
1581
1591
|
function AddPageDialog({ open, onOpenChange, pages, reserved, onCreate }) {
|
|
1582
|
-
const templates =
|
|
1583
|
-
const [title, setTitle] =
|
|
1584
|
-
const [path, setPath] =
|
|
1585
|
-
const [pathEdited, setPathEdited] =
|
|
1586
|
-
const [templateId, setTemplateId] =
|
|
1587
|
-
const [addToMenu, setAddToMenu] =
|
|
1588
|
-
const [error, setError] =
|
|
1589
|
-
const [busy, setBusy] =
|
|
1590
|
-
const id =
|
|
1591
|
-
|
|
1592
|
+
const templates = React10.useMemo(() => pageTemplates().filter((t) => t.kind !== "landing" && t.id !== "not-found"), []);
|
|
1593
|
+
const [title, setTitle] = React10.useState("");
|
|
1594
|
+
const [path, setPath] = React10.useState("");
|
|
1595
|
+
const [pathEdited, setPathEdited] = React10.useState(false);
|
|
1596
|
+
const [templateId, setTemplateId] = React10.useState("blank");
|
|
1597
|
+
const [addToMenu, setAddToMenu] = React10.useState(true);
|
|
1598
|
+
const [error, setError] = React10.useState(null);
|
|
1599
|
+
const [busy, setBusy] = React10.useState(false);
|
|
1600
|
+
const id = React10.useId();
|
|
1601
|
+
React10.useEffect(() => {
|
|
1592
1602
|
if (open) {
|
|
1593
1603
|
setTitle("");
|
|
1594
1604
|
setPath("");
|
|
@@ -1675,11 +1685,11 @@ function AddPageDialog({ open, onOpenChange, pages, reserved, onCreate }) {
|
|
|
1675
1685
|
] }) }) });
|
|
1676
1686
|
}
|
|
1677
1687
|
function RenameDialog({ page, pages, reserved, onClose, onRename }) {
|
|
1678
|
-
const [path, setPath] =
|
|
1679
|
-
const [error, setError] =
|
|
1680
|
-
const [busy, setBusy] =
|
|
1681
|
-
const id =
|
|
1682
|
-
|
|
1688
|
+
const [path, setPath] = React10.useState("");
|
|
1689
|
+
const [error, setError] = React10.useState(null);
|
|
1690
|
+
const [busy, setBusy] = React10.useState(false);
|
|
1691
|
+
const id = React10.useId();
|
|
1692
|
+
React10.useEffect(() => {
|
|
1683
1693
|
setPath(page?.path ?? "");
|
|
1684
1694
|
setError(null);
|
|
1685
1695
|
}, [page]);
|
|
@@ -1739,8 +1749,8 @@ function menuItemProblems(item) {
|
|
|
1739
1749
|
}
|
|
1740
1750
|
function MenuEditor({ nav, pages, busy, onChange }) {
|
|
1741
1751
|
const items = nav;
|
|
1742
|
-
const id =
|
|
1743
|
-
const list =
|
|
1752
|
+
const id = React10.useId();
|
|
1753
|
+
const list = React10.useRef(null);
|
|
1744
1754
|
const commit = (next) => onChange(next);
|
|
1745
1755
|
const move = (i, by) => {
|
|
1746
1756
|
const next = [...items];
|
|
@@ -1753,7 +1763,7 @@ function MenuEditor({ nav, pages, busy, onChange }) {
|
|
|
1753
1763
|
(same && !same.disabled ? same : list.current?.querySelector(`[data-menu-move="${j}:${-by}"]`))?.focus();
|
|
1754
1764
|
});
|
|
1755
1765
|
};
|
|
1756
|
-
const unlinked = pages.filter((p) => !isLandingPage(p) && !items.some((i) => i.href === p.path));
|
|
1766
|
+
const unlinked = pages.filter((p) => !isLandingPage(p) && !isNotFoundPage(p) && !items.some((i) => i.href === p.path));
|
|
1757
1767
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
1758
1768
|
items.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "The menu is empty." }) : null,
|
|
1759
1769
|
/* @__PURE__ */ jsx("ol", { ref: list, className: "flex flex-col gap-3", children: items.map((item, i) => {
|
|
@@ -1792,10 +1802,25 @@ function MenuEditor({ nav, pages, busy, onChange }) {
|
|
|
1792
1802
|
] });
|
|
1793
1803
|
}
|
|
1794
1804
|
function PagesPanel(props) {
|
|
1795
|
-
const [adding, setAdding] =
|
|
1796
|
-
const [renaming, setRenaming] =
|
|
1797
|
-
const [deleting, setDeleting] =
|
|
1798
|
-
const ordinary = props.pages.filter((p) => !isLandingPage(p));
|
|
1805
|
+
const [adding, setAdding] = React10.useState(false);
|
|
1806
|
+
const [renaming, setRenaming] = React10.useState(null);
|
|
1807
|
+
const [deleting, setDeleting] = React10.useState(null);
|
|
1808
|
+
const ordinary = props.pages.filter((p) => !isLandingPage(p) && !isNotFoundPage(p));
|
|
1809
|
+
const notFoundPage = props.pages.find(isNotFoundPage) ?? null;
|
|
1810
|
+
const notFoundTemplate = React10.useMemo(() => pageTemplates().find((t) => t.id === "not-found"), []);
|
|
1811
|
+
const [makingNotFound, setMakingNotFound] = React10.useState(false);
|
|
1812
|
+
const [notFoundError, setNotFoundError] = React10.useState(null);
|
|
1813
|
+
const makeNotFound = async () => {
|
|
1814
|
+
setNotFoundError(null);
|
|
1815
|
+
setMakingNotFound(true);
|
|
1816
|
+
try {
|
|
1817
|
+
await props.onCreate({ title: "Page not found", path: NOT_FOUND_PATH, template: notFoundTemplate, addToMenu: false });
|
|
1818
|
+
} catch (err) {
|
|
1819
|
+
setNotFoundError(err.message);
|
|
1820
|
+
} finally {
|
|
1821
|
+
setMakingNotFound(false);
|
|
1822
|
+
}
|
|
1823
|
+
};
|
|
1799
1824
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 p-3", children: [
|
|
1800
1825
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1801
1826
|
/* @__PURE__ */ jsx("h2", { className: "text-sm font-semibold", children: "Pages" }),
|
|
@@ -1824,10 +1849,40 @@ function PagesPanel(props) {
|
|
|
1824
1849
|
] })
|
|
1825
1850
|
] }, p.id);
|
|
1826
1851
|
}) }),
|
|
1852
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
1853
|
+
/* @__PURE__ */ jsxs("section", { "aria-labelledby": "gs-not-found-heading", className: "flex flex-col gap-2", children: [
|
|
1854
|
+
/* @__PURE__ */ jsx("h2", { id: "gs-not-found-heading", className: "text-sm font-semibold", children: "Page not found" }),
|
|
1855
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
1856
|
+
"What a visitor sees at an address the site doesn't have. ",
|
|
1857
|
+
notFoundPage ? null : "Without one, they see a short built-in message."
|
|
1858
|
+
] }),
|
|
1859
|
+
notFoundPage ? /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-1 rounded-md border p-2", notFoundPage.id === props.currentId ? "border-primary bg-muted" : "border-transparent hover:border-border"), children: [
|
|
1860
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "flex min-w-0 flex-1 items-center gap-2 text-left text-sm focus-visible:outline-2 focus-visible:outline-ring", "aria-current": notFoundPage.id === props.currentId ? "page" : void 0, onClick: () => props.onOpen(notFoundPage.id), disabled: props.busy, children: [
|
|
1861
|
+
/* @__PURE__ */ jsx(FileQuestion, { "aria-hidden": true, className: "h-4 w-4 shrink-0" }),
|
|
1862
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col", children: [
|
|
1863
|
+
/* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: notFoundPage.title }),
|
|
1864
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: notFoundPage.path })
|
|
1865
|
+
] })
|
|
1866
|
+
] }),
|
|
1867
|
+
props.readOnly ? null : /* @__PURE__ */ jsx(Button, { type: "button", size: "icon", variant: "ghost", disabled: props.busy, "aria-label": `Delete ${notFoundPage.title}`, onClick: () => setDeleting(notFoundPage), children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }) })
|
|
1868
|
+
] }) : props.readOnly ? null : /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", variant: "outline", className: "self-start", loading: makingNotFound, disabled: props.busy, onClick: () => void makeNotFound(), children: [
|
|
1869
|
+
/* @__PURE__ */ jsx(Plus, { className: "mr-1 h-4 w-4" }),
|
|
1870
|
+
" Make a 404 page"
|
|
1871
|
+
] }),
|
|
1872
|
+
notFoundError ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: notFoundError }) : null
|
|
1873
|
+
] }),
|
|
1827
1874
|
props.landing ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1828
1875
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
1829
1876
|
props.landing
|
|
1830
1877
|
] }) : null,
|
|
1878
|
+
props.redirects ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1879
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
1880
|
+
props.redirects
|
|
1881
|
+
] }) : null,
|
|
1882
|
+
props.search ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1883
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
1884
|
+
props.search
|
|
1885
|
+
] }) : null,
|
|
1831
1886
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
1832
1887
|
/* @__PURE__ */ jsxs("section", { "aria-labelledby": "gs-menu-heading", className: "flex flex-col gap-2", children: [
|
|
1833
1888
|
/* @__PURE__ */ jsx("h2", { id: "gs-menu-heading", className: "text-sm font-semibold", children: "Menu" }),
|
|
@@ -1875,15 +1930,465 @@ function PagesPanel(props) {
|
|
|
1875
1930
|
] }) })
|
|
1876
1931
|
] });
|
|
1877
1932
|
}
|
|
1933
|
+
var OTHER = "\0other";
|
|
1934
|
+
function describe(to, destinations) {
|
|
1935
|
+
const d = destinations.find((x) => x.path === to);
|
|
1936
|
+
return d ? `${d.label} (${to})` : to;
|
|
1937
|
+
}
|
|
1938
|
+
function RedirectDialog({
|
|
1939
|
+
editing,
|
|
1940
|
+
open,
|
|
1941
|
+
onClose,
|
|
1942
|
+
props
|
|
1943
|
+
}) {
|
|
1944
|
+
const [from, setFrom] = React10.useState("");
|
|
1945
|
+
const [choice, setChoice] = React10.useState(void 0);
|
|
1946
|
+
const [other, setOther] = React10.useState("");
|
|
1947
|
+
const [status, setStatus] = React10.useState("301");
|
|
1948
|
+
const [prefix, setPrefix] = React10.useState(false);
|
|
1949
|
+
const [keepRest, setKeepRest] = React10.useState(false);
|
|
1950
|
+
const [touched, setTouched] = React10.useState(false);
|
|
1951
|
+
const [error, setError] = React10.useState(null);
|
|
1952
|
+
const id = React10.useId();
|
|
1953
|
+
React10.useEffect(() => {
|
|
1954
|
+
if (!open) return;
|
|
1955
|
+
setFrom(editing?.from ?? "");
|
|
1956
|
+
const known = editing && props.destinations.some((d) => d.path === editing.to);
|
|
1957
|
+
setChoice(editing ? known ? editing.to : OTHER : void 0);
|
|
1958
|
+
setOther(editing && !known ? editing.to : "");
|
|
1959
|
+
setStatus(editing?.status === 302 ? "302" : "301");
|
|
1960
|
+
setPrefix(editing?.match === "prefix");
|
|
1961
|
+
setKeepRest(Boolean(editing?.keepRest));
|
|
1962
|
+
setTouched(false);
|
|
1963
|
+
setError(null);
|
|
1964
|
+
}, [open, editing]);
|
|
1965
|
+
const to = choice === OTHER ? other.trim() : choice ?? "";
|
|
1966
|
+
const ctx = { redirects: props.redirects, pages: props.pages, reserved: props.reserved, editing: editing?.from };
|
|
1967
|
+
const how = prefix ? { match: "prefix", keepRest: keepRest || void 0 } : {};
|
|
1968
|
+
const fromProblems = from ? redirectFromProblems(from, ctx, how) : [];
|
|
1969
|
+
const toProblems = touched || to ? redirectToProblems(from, to, ctx, how) : [];
|
|
1970
|
+
const options2 = [
|
|
1971
|
+
...props.destinations.map((d) => ({ value: d.path, label: d.label, description: `${d.group} \xB7 ${d.path}` })),
|
|
1972
|
+
{ value: OTHER, label: "Another address\u2026", description: "A site path or a full https link" }
|
|
1973
|
+
];
|
|
1974
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (o) => o ? null : onClose(), children: /* @__PURE__ */ jsx(DialogContent, { className: "sm:max-w-lg", children: /* @__PURE__ */ jsxs(
|
|
1975
|
+
"form",
|
|
1976
|
+
{
|
|
1977
|
+
className: "flex flex-col gap-4",
|
|
1978
|
+
onSubmit: (e) => {
|
|
1979
|
+
e.preventDefault();
|
|
1980
|
+
setTouched(true);
|
|
1981
|
+
if (!from) return setError("Give the old address.");
|
|
1982
|
+
const problems = [...redirectFromProblems(from, ctx, how), ...redirectToProblems(from, to, ctx, how)];
|
|
1983
|
+
if (problems.length) return setError(problems.join(" "));
|
|
1984
|
+
const next = { from, to, status: status === "302" ? 302 : 301, ...how.match ? { match: how.match } : {}, ...how.keepRest ? { keepRest: true } : {} };
|
|
1985
|
+
const failed = props.onChange(upsertRedirect(props.redirects, next, editing?.from));
|
|
1986
|
+
if (failed) return setError(failed);
|
|
1987
|
+
onClose();
|
|
1988
|
+
},
|
|
1989
|
+
children: [
|
|
1990
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
1991
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: editing ? "Edit redirect" : "New redirect" }),
|
|
1992
|
+
/* @__PURE__ */ jsx(DialogDescription, { children: "Visitors to the old address go to the one you choose. It goes live at the next publish." })
|
|
1993
|
+
] }),
|
|
1994
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
1995
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-from`, children: "Old address" }),
|
|
1996
|
+
/* @__PURE__ */ jsx(
|
|
1997
|
+
Input,
|
|
1998
|
+
{
|
|
1999
|
+
id: `${id}-from`,
|
|
2000
|
+
value: from,
|
|
2001
|
+
placeholder: "/feedback",
|
|
2002
|
+
autoFocus: true,
|
|
2003
|
+
"aria-invalid": fromProblems.length > 0 || void 0,
|
|
2004
|
+
"aria-describedby": `${id}-from-hint`,
|
|
2005
|
+
onChange: (e) => setFrom(e.currentTarget.value.trim().toLowerCase())
|
|
2006
|
+
}
|
|
2007
|
+
),
|
|
2008
|
+
/* @__PURE__ */ jsx("p", { id: `${id}-from-hint`, className: fromProblems.length ? "text-sm text-destructive" : "text-sm text-muted-foreground", children: fromProblems.length ? fromProblems.join(" ") : "A path on this site that has no page, like /feedback." })
|
|
2009
|
+
] }),
|
|
2010
|
+
/* @__PURE__ */ jsxs("fieldset", { className: "flex flex-col gap-2", children: [
|
|
2011
|
+
/* @__PURE__ */ jsx("legend", { className: "mb-2 text-sm font-medium", children: "Matches" }),
|
|
2012
|
+
/* @__PURE__ */ jsxs(RadioGroup, { value: prefix ? "prefix" : "exact", onValueChange: (v) => setPrefix(v === "prefix"), className: "flex flex-col gap-2", children: [
|
|
2013
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2014
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { id: `${id}-exact`, value: "exact", className: "mt-0.5" }),
|
|
2015
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-exact`, className: "font-normal", children: "Only this address" })
|
|
2016
|
+
] }),
|
|
2017
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2018
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { id: `${id}-prefix`, value: "prefix", className: "mt-0.5" }),
|
|
2019
|
+
/* @__PURE__ */ jsxs(Label, { htmlFor: `${id}-prefix`, className: "font-normal", children: [
|
|
2020
|
+
"This address and everything under it (",
|
|
2021
|
+
from || "/old",
|
|
2022
|
+
"/\u2026). Pages there still show."
|
|
2023
|
+
] })
|
|
2024
|
+
] })
|
|
2025
|
+
] }),
|
|
2026
|
+
prefix ? /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2 pl-6", children: [
|
|
2027
|
+
/* @__PURE__ */ jsx(Checkbox, { id: `${id}-rest`, checked: keepRest, onCheckedChange: (v) => setKeepRest(v === true), className: "mt-0.5" }),
|
|
2028
|
+
/* @__PURE__ */ jsxs(Label, { htmlFor: `${id}-rest`, className: "font-normal", children: [
|
|
2029
|
+
"Keep the rest of the address (",
|
|
2030
|
+
from || "/old",
|
|
2031
|
+
"/ana goes to ",
|
|
2032
|
+
(choice === OTHER ? other.trim() : choice) || "/new",
|
|
2033
|
+
"/ana)"
|
|
2034
|
+
] })
|
|
2035
|
+
] }) : null
|
|
2036
|
+
] }),
|
|
2037
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
2038
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-to`, children: "Goes to" }),
|
|
2039
|
+
/* @__PURE__ */ jsx(
|
|
2040
|
+
Combobox,
|
|
2041
|
+
{
|
|
2042
|
+
id: `${id}-to`,
|
|
2043
|
+
options: options2,
|
|
2044
|
+
value: choice,
|
|
2045
|
+
onChange: (v) => {
|
|
2046
|
+
setChoice(v);
|
|
2047
|
+
setTouched(true);
|
|
2048
|
+
},
|
|
2049
|
+
placeholder: "Choose a page, a landing page or another place",
|
|
2050
|
+
searchPlaceholder: "Search",
|
|
2051
|
+
emptyText: "Nothing matches.",
|
|
2052
|
+
contentClassName: "w-[var(--radix-popover-trigger-width)]"
|
|
2053
|
+
}
|
|
2054
|
+
),
|
|
2055
|
+
choice === OTHER ? /* @__PURE__ */ jsx(Input, { "aria-label": "Other address", value: other, placeholder: "https://example.com/page or /about", onChange: (e) => setOther(e.currentTarget.value) }) : null,
|
|
2056
|
+
toProblems.length ? /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: toProblems.join(" ") }) : null
|
|
2057
|
+
] }),
|
|
2058
|
+
/* @__PURE__ */ jsxs("fieldset", { className: "flex flex-col gap-2", children: [
|
|
2059
|
+
/* @__PURE__ */ jsx("legend", { className: "mb-2 text-sm font-medium", children: "Kind" }),
|
|
2060
|
+
/* @__PURE__ */ jsxs(RadioGroup, { value: status, onValueChange: (v) => setStatus(v), className: "flex flex-col gap-2", children: [
|
|
2061
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2062
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { id: `${id}-301`, value: "301", className: "mt-0.5" }),
|
|
2063
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-301`, className: "font-normal", children: "Permanent (301): the address has moved for good; search engines follow it." })
|
|
2064
|
+
] }),
|
|
2065
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2066
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { id: `${id}-302`, value: "302", className: "mt-0.5" }),
|
|
2067
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-302`, className: "font-normal", children: "Temporary (302): a short link, or for now." })
|
|
2068
|
+
] })
|
|
2069
|
+
] })
|
|
2070
|
+
] }),
|
|
2071
|
+
error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: error }) : null,
|
|
2072
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
2073
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: "Cancel" }),
|
|
2074
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", children: "Save" })
|
|
2075
|
+
] })
|
|
2076
|
+
]
|
|
2077
|
+
}
|
|
2078
|
+
) }) });
|
|
2079
|
+
}
|
|
2080
|
+
function RedirectsPanel(props) {
|
|
2081
|
+
const [editing, setEditing] = React10.useState(null);
|
|
2082
|
+
const [adding, setAdding] = React10.useState(false);
|
|
2083
|
+
const [removing, setRemoving] = React10.useState(null);
|
|
2084
|
+
const [error, setError] = React10.useState(null);
|
|
2085
|
+
const headingId = React10.useId();
|
|
2086
|
+
return /* @__PURE__ */ jsxs("section", { "aria-labelledby": headingId, className: "flex flex-col gap-2", "data-gs-redirects": "", children: [
|
|
2087
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2088
|
+
/* @__PURE__ */ jsx("h2", { id: headingId, className: "text-sm font-semibold", children: "Redirects" }),
|
|
2089
|
+
props.readOnly ? null : /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", onClick: () => setAdding(true), disabled: props.busy, children: [
|
|
2090
|
+
/* @__PURE__ */ jsx(Plus, { className: "mr-1 h-4 w-4" }),
|
|
2091
|
+
" New redirect"
|
|
2092
|
+
] })
|
|
2093
|
+
] }),
|
|
2094
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Send an old or short address to a page, a landing page, a form or anywhere else. Moving a page adds one for you." }),
|
|
2095
|
+
props.redirects.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No redirects yet." }) : null,
|
|
2096
|
+
/* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1", "aria-label": "Redirects", children: props.redirects.map((r) => /* @__PURE__ */ jsxs("li", { className: "flex flex-col gap-1 rounded-md border border-transparent p-2 hover:border-border", children: [
|
|
2097
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 text-sm", children: [
|
|
2098
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1 truncate font-medium", children: [
|
|
2099
|
+
r.from,
|
|
2100
|
+
r.match === "prefix" ? /* @__PURE__ */ jsx("span", { className: "font-normal text-muted-foreground", children: " and everything under it" }) : null
|
|
2101
|
+
] }),
|
|
2102
|
+
/* @__PURE__ */ jsx(Badge, { variant: "secondary", children: r.status === 301 ? "Permanent" : "Temporary" })
|
|
2103
|
+
] }),
|
|
2104
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-1 text-xs text-muted-foreground", children: [
|
|
2105
|
+
/* @__PURE__ */ jsx(ArrowRight, { "aria-label": "goes to", className: "h-3 w-3 shrink-0" }),
|
|
2106
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 break-all", children: [
|
|
2107
|
+
describe(r.to, props.destinations),
|
|
2108
|
+
r.keepRest ? " (keeping the rest of the address)" : null
|
|
2109
|
+
] })
|
|
2110
|
+
] }),
|
|
2111
|
+
props.readOnly ? null : /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
2112
|
+
/* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "ghost", disabled: props.busy, "aria-label": `Edit the redirect from ${r.from}`, onClick: () => setEditing(r), children: "Edit" }),
|
|
2113
|
+
/* @__PURE__ */ jsx(Button, { type: "button", size: "icon", variant: "ghost", disabled: props.busy, "aria-label": `Remove the redirect from ${r.from}`, onClick: () => setRemoving(r), children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }) })
|
|
2114
|
+
] })
|
|
2115
|
+
] }, r.from)) }),
|
|
2116
|
+
error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: error }) : null,
|
|
2117
|
+
/* @__PURE__ */ jsx(RedirectDialog, { open: adding || editing !== null, editing, props, onClose: () => (setAdding(false), setEditing(null)) }),
|
|
2118
|
+
/* @__PURE__ */ jsx(AlertDialog, { open: removing !== null, onOpenChange: (o) => o ? null : setRemoving(null), children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
|
|
2119
|
+
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
2120
|
+
/* @__PURE__ */ jsxs(AlertDialogTitle, { children: [
|
|
2121
|
+
"Remove the redirect from ",
|
|
2122
|
+
removing?.from,
|
|
2123
|
+
"?"
|
|
2124
|
+
] }),
|
|
2125
|
+
/* @__PURE__ */ jsxs(AlertDialogDescription, { children: [
|
|
2126
|
+
"From the next publish, visitors to ",
|
|
2127
|
+
removing?.from,
|
|
2128
|
+
" see the page-not-found page."
|
|
2129
|
+
] })
|
|
2130
|
+
] }),
|
|
2131
|
+
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
2132
|
+
/* @__PURE__ */ jsx(AlertDialogCancel, { children: "Keep it" }),
|
|
2133
|
+
/* @__PURE__ */ jsx(
|
|
2134
|
+
AlertDialogAction,
|
|
2135
|
+
{
|
|
2136
|
+
onClick: () => {
|
|
2137
|
+
if (removing) setError(props.onChange(removeRedirect(props.redirects, removing.from)));
|
|
2138
|
+
setRemoving(null);
|
|
2139
|
+
},
|
|
2140
|
+
children: "Remove redirect"
|
|
2141
|
+
}
|
|
2142
|
+
)
|
|
2143
|
+
] })
|
|
2144
|
+
] }) })
|
|
2145
|
+
] });
|
|
2146
|
+
}
|
|
2147
|
+
var lines = (text) => text.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
2148
|
+
function searchForm(seo) {
|
|
2149
|
+
const b = seo.localBusiness;
|
|
2150
|
+
return {
|
|
2151
|
+
titleTemplate: seo.titleTemplate ?? "",
|
|
2152
|
+
description: seo.description ?? "",
|
|
2153
|
+
noindex: seo.noindex === true,
|
|
2154
|
+
orgName: seo.organization?.name ?? "",
|
|
2155
|
+
sameAs: (seo.organization?.sameAs ?? []).join("\n"),
|
|
2156
|
+
business: Boolean(b),
|
|
2157
|
+
type: b?.type ?? "LocalBusiness",
|
|
2158
|
+
name: b?.name ?? "",
|
|
2159
|
+
about: b?.description ?? "",
|
|
2160
|
+
telephone: b?.telephone ?? "",
|
|
2161
|
+
email: b?.email ?? "",
|
|
2162
|
+
foundingDate: b?.foundingDate ?? "",
|
|
2163
|
+
priceRange: b?.priceRange ?? "",
|
|
2164
|
+
street: b?.address.streetAddress ?? "",
|
|
2165
|
+
locality: b?.address.addressLocality ?? "",
|
|
2166
|
+
region: b?.address.addressRegion ?? "",
|
|
2167
|
+
postalCode: b?.address.postalCode ?? "",
|
|
2168
|
+
country: b?.address.addressCountry ?? "",
|
|
2169
|
+
latitude: b?.geo ? String(b.geo.latitude) : "",
|
|
2170
|
+
longitude: b?.geo ? String(b.geo.longitude) : "",
|
|
2171
|
+
hours: (b?.openingHours ?? []).join("\n"),
|
|
2172
|
+
pages: [...b?.pages ?? []]
|
|
2173
|
+
};
|
|
2174
|
+
}
|
|
2175
|
+
function seoFromForm(form, current) {
|
|
2176
|
+
const opt = (v) => v.trim() ? v.trim() : void 0;
|
|
2177
|
+
const { titleTemplate: _t, description: _d, noindex: _n, organization: currentOrg, localBusiness: currentBusiness, ...kept } = current;
|
|
2178
|
+
const sameAs = lines(form.sameAs);
|
|
2179
|
+
const organization = form.orgName.trim() ? { ...currentOrg?.logo ? { logo: currentOrg.logo } : {}, name: form.orgName.trim(), ...sameAs.length ? { sameAs } : {} } : void 0;
|
|
2180
|
+
if (!organization && sameAs.length) return { error: "Give the organization's name for its profile links." };
|
|
2181
|
+
let localBusiness;
|
|
2182
|
+
if (form.business) {
|
|
2183
|
+
if (!form.street.trim() || !form.locality.trim()) return { error: "The business needs a street address and a town or city." };
|
|
2184
|
+
const lat = opt(form.latitude);
|
|
2185
|
+
const lng = opt(form.longitude);
|
|
2186
|
+
if (Boolean(lat) !== Boolean(lng)) return { error: "Give both latitude and longitude, or neither." };
|
|
2187
|
+
if (lat && !Number.isFinite(Number(lat)) || lng && !Number.isFinite(Number(lng))) return { error: "Latitude and longitude are numbers, such as 40.7128 and -74.006." };
|
|
2188
|
+
const hours = lines(form.hours);
|
|
2189
|
+
localBusiness = {
|
|
2190
|
+
type: opt(form.type) ?? "LocalBusiness",
|
|
2191
|
+
...opt(form.name) ? { name: opt(form.name) } : {},
|
|
2192
|
+
...opt(form.about) ? { description: opt(form.about) } : {},
|
|
2193
|
+
...opt(form.telephone) ? { telephone: opt(form.telephone) } : {},
|
|
2194
|
+
...opt(form.email) ? { email: opt(form.email) } : {},
|
|
2195
|
+
...opt(form.foundingDate) ? { foundingDate: opt(form.foundingDate) } : {},
|
|
2196
|
+
...opt(form.priceRange) ? { priceRange: opt(form.priceRange) } : {},
|
|
2197
|
+
...currentBusiness?.image ? { image: currentBusiness.image } : {},
|
|
2198
|
+
address: {
|
|
2199
|
+
streetAddress: form.street.trim(),
|
|
2200
|
+
addressLocality: form.locality.trim(),
|
|
2201
|
+
...opt(form.region) ? { addressRegion: opt(form.region) } : {},
|
|
2202
|
+
...opt(form.postalCode) ? { postalCode: opt(form.postalCode) } : {},
|
|
2203
|
+
...opt(form.country) ? { addressCountry: opt(form.country).toUpperCase() } : {}
|
|
2204
|
+
},
|
|
2205
|
+
...lat && lng ? { geo: { latitude: Number(lat), longitude: Number(lng) } } : {},
|
|
2206
|
+
...hours.length ? { openingHours: hours } : {},
|
|
2207
|
+
...form.pages.length ? { pages: form.pages } : {}
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
const next = {
|
|
2211
|
+
...kept,
|
|
2212
|
+
...opt(form.titleTemplate) ? { titleTemplate: opt(form.titleTemplate) } : {},
|
|
2213
|
+
...opt(form.description) ? { description: opt(form.description) } : {},
|
|
2214
|
+
...form.noindex ? { noindex: true } : {},
|
|
2215
|
+
...organization ? { organization } : {},
|
|
2216
|
+
...localBusiness ? { localBusiness } : {}
|
|
2217
|
+
};
|
|
2218
|
+
const parsed = SeoDefaults.safeParse(next);
|
|
2219
|
+
if (!parsed.success) {
|
|
2220
|
+
const issue = parsed.error.issues[0];
|
|
2221
|
+
const key = String([...issue.path].reverse().find((p) => typeof p === "string") ?? "");
|
|
2222
|
+
const field = FIELD_NAMES[key] ?? issue.path.join(".");
|
|
2223
|
+
const message = issue.code === "invalid_format" ? FORMATS[key] ?? "isn't in the right form." : issue.message;
|
|
2224
|
+
return { error: `${field}: ${message}` };
|
|
2225
|
+
}
|
|
2226
|
+
return { seo: parsed.data };
|
|
2227
|
+
}
|
|
2228
|
+
var FORMATS = {
|
|
2229
|
+
type: "a schema.org type, such as LocalBusiness or Store.",
|
|
2230
|
+
telephone: "digits, spaces and + ( ) . -, such as +1 555 010 0200.",
|
|
2231
|
+
email: "an email address.",
|
|
2232
|
+
foundingDate: "a year, or a date as 2012-05-01.",
|
|
2233
|
+
addressCountry: "a two-letter country code, such as US.",
|
|
2234
|
+
openingHours: "days and times, such as Mo-Fr 06:00-20:00.",
|
|
2235
|
+
sameAs: "https links."
|
|
2236
|
+
};
|
|
2237
|
+
var FIELD_NAMES = {
|
|
2238
|
+
titleTemplate: "Title pattern",
|
|
2239
|
+
description: "Description",
|
|
2240
|
+
name: "Name",
|
|
2241
|
+
sameAs: "Profile links",
|
|
2242
|
+
type: "Kind of business",
|
|
2243
|
+
telephone: "Phone",
|
|
2244
|
+
email: "Email",
|
|
2245
|
+
foundingDate: "Founded",
|
|
2246
|
+
priceRange: "Price range",
|
|
2247
|
+
addressCountry: "Country",
|
|
2248
|
+
openingHours: "Opening hours",
|
|
2249
|
+
pages: "Pages"
|
|
2250
|
+
};
|
|
2251
|
+
function Field({ id, label, hint, children }) {
|
|
2252
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2253
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: id, children: label }),
|
|
2254
|
+
children,
|
|
2255
|
+
hint ? /* @__PURE__ */ jsx("p", { id: `${id}-hint`, className: "text-xs text-muted-foreground", children: hint }) : null
|
|
2256
|
+
] });
|
|
2257
|
+
}
|
|
2258
|
+
function SearchDialog({ open, onClose, props }) {
|
|
2259
|
+
const [form, setForm] = React10.useState(() => searchForm(props.seo));
|
|
2260
|
+
const [error, setError] = React10.useState(null);
|
|
2261
|
+
const id = React10.useId();
|
|
2262
|
+
React10.useEffect(() => {
|
|
2263
|
+
if (!open) return;
|
|
2264
|
+
setForm(searchForm(props.seo));
|
|
2265
|
+
setError(null);
|
|
2266
|
+
}, [open]);
|
|
2267
|
+
const set = (key) => (value) => setForm((f) => ({ ...f, [key]: value }));
|
|
2268
|
+
const text = (key, label, hint, extra = {}) => /* @__PURE__ */ jsx(Field, { id: `${id}-${key}`, label, ...hint ? { hint } : {}, children: /* @__PURE__ */ jsx(Input, { id: `${id}-${key}`, value: form[key], ...hint ? { "aria-describedby": `${id}-${key}-hint` } : {}, ...extra, onChange: (e) => set(key)(e.currentTarget.value) }) });
|
|
2269
|
+
const pages = props.pages.filter((p) => p.path !== "/" && !isNotFoundPage(p) && p.kind !== "post");
|
|
2270
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (o) => o ? null : onClose(), children: /* @__PURE__ */ jsx(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-xl", children: /* @__PURE__ */ jsxs(
|
|
2271
|
+
"form",
|
|
2272
|
+
{
|
|
2273
|
+
className: "flex flex-col gap-5",
|
|
2274
|
+
onSubmit: (e) => {
|
|
2275
|
+
e.preventDefault();
|
|
2276
|
+
const result = seoFromForm(form, props.seo);
|
|
2277
|
+
if ("error" in result) return setError(result.error);
|
|
2278
|
+
const failed = props.onChange(result.seo);
|
|
2279
|
+
if (failed) return setError(failed);
|
|
2280
|
+
onClose();
|
|
2281
|
+
},
|
|
2282
|
+
children: [
|
|
2283
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
2284
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: "Search and sharing" }),
|
|
2285
|
+
/* @__PURE__ */ jsx(DialogDescription, { children: "How the site shows in search results and link previews. Changes go live at the next publish." })
|
|
2286
|
+
] }),
|
|
2287
|
+
/* @__PURE__ */ jsxs("fieldset", { className: "flex flex-col gap-3", children: [
|
|
2288
|
+
/* @__PURE__ */ jsx("legend", { className: "mb-1 text-sm font-semibold", children: "Every page" }),
|
|
2289
|
+
text("titleTemplate", "Title pattern", "%s is the page's title: \u201C%s \xB7 Your business\u201D.", { placeholder: "%s \xB7 Your business" }),
|
|
2290
|
+
/* @__PURE__ */ jsx(Field, { id: `${id}-description`, label: "Description", hint: "For pages without their own: a sentence or two, up to 200 characters.", children: /* @__PURE__ */ jsx(Textarea, { id: `${id}-description`, value: form.description, rows: 2, maxLength: 200, "aria-describedby": `${id}-description-hint`, onChange: (e) => set("description")(e.currentTarget.value) }) }),
|
|
2291
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2292
|
+
/* @__PURE__ */ jsx(Checkbox, { id: `${id}-noindex`, checked: form.noindex, onCheckedChange: (c) => set("noindex")(c === true) }),
|
|
2293
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-noindex`, className: "font-normal", children: "Keep the whole site out of search results" })
|
|
2294
|
+
] })
|
|
2295
|
+
] }),
|
|
2296
|
+
/* @__PURE__ */ jsxs("fieldset", { className: "flex flex-col gap-3", children: [
|
|
2297
|
+
/* @__PURE__ */ jsx("legend", { className: "mb-1 text-sm font-semibold", children: "Organization" }),
|
|
2298
|
+
text("orgName", "Name", "The name search engines show for the site's owner."),
|
|
2299
|
+
/* @__PURE__ */ jsx(Field, { id: `${id}-sameAs`, label: "Profile links", hint: "The organization's pages elsewhere (social profiles), one https link per line, up to 10.", children: /* @__PURE__ */ jsx(Textarea, { id: `${id}-sameAs`, value: form.sameAs, rows: 2, "aria-describedby": `${id}-sameAs-hint`, onChange: (e) => set("sameAs")(e.currentTarget.value) }) })
|
|
2300
|
+
] }),
|
|
2301
|
+
/* @__PURE__ */ jsxs("fieldset", { className: "flex flex-col gap-3", children: [
|
|
2302
|
+
/* @__PURE__ */ jsx("legend", { className: "mb-1 text-sm font-semibold", children: "Business at an address" }),
|
|
2303
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2304
|
+
/* @__PURE__ */ jsx(Checkbox, { id: `${id}-business`, checked: form.business, onCheckedChange: (c) => set("business")(c === true) }),
|
|
2305
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-business`, className: "font-normal", children: "Tell search engines about a place visitors can come to" })
|
|
2306
|
+
] }),
|
|
2307
|
+
form.business ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2308
|
+
text("type", "Kind of business", "A schema.org type: LocalBusiness, or a more specific one such as Store."),
|
|
2309
|
+
text("name", "Name", "Leave empty to use the site's name."),
|
|
2310
|
+
/* @__PURE__ */ jsx(Field, { id: `${id}-about`, label: "About", children: /* @__PURE__ */ jsx(Textarea, { id: `${id}-about`, value: form.about, rows: 2, maxLength: 300, onChange: (e) => set("about")(e.currentTarget.value) }) }),
|
|
2311
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
2312
|
+
text("telephone", "Phone", void 0, { type: "tel", autoComplete: "off" }),
|
|
2313
|
+
text("email", "Email", void 0, { type: "email", autoComplete: "off" })
|
|
2314
|
+
] }),
|
|
2315
|
+
text("street", "Street address"),
|
|
2316
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
2317
|
+
text("locality", "Town or city"),
|
|
2318
|
+
text("region", "State or region"),
|
|
2319
|
+
text("postalCode", "Postal code"),
|
|
2320
|
+
text("country", "Country", "Two letters, such as US.", { maxLength: 2 })
|
|
2321
|
+
] }),
|
|
2322
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
2323
|
+
text("latitude", "Latitude", void 0, { inputMode: "decimal" }),
|
|
2324
|
+
text("longitude", "Longitude", void 0, { inputMode: "decimal" })
|
|
2325
|
+
] }),
|
|
2326
|
+
/* @__PURE__ */ jsx(Field, { id: `${id}-hours`, label: "Opening hours", hint: "One line each, as days and times: Mo-Fr 06:00-20:00, Sa 08:00-12:00.", children: /* @__PURE__ */ jsx(Textarea, { id: `${id}-hours`, value: form.hours, rows: 3, "aria-describedby": `${id}-hours-hint`, onChange: (e) => set("hours")(e.currentTarget.value) }) }),
|
|
2327
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
2328
|
+
text("foundingDate", "Founded", "A year, or YYYY-MM-DD."),
|
|
2329
|
+
text("priceRange", "Price range", "Such as $$.")
|
|
2330
|
+
] }),
|
|
2331
|
+
pages.length ? /* @__PURE__ */ jsxs("fieldset", { className: "flex flex-col gap-2", children: [
|
|
2332
|
+
/* @__PURE__ */ jsx("legend", { className: "text-sm font-medium", children: "Also on these pages" }),
|
|
2333
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "The home page always carries it." }),
|
|
2334
|
+
pages.map((p) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2335
|
+
/* @__PURE__ */ jsx(
|
|
2336
|
+
Checkbox,
|
|
2337
|
+
{
|
|
2338
|
+
id: `${id}-page-${p.path}`,
|
|
2339
|
+
checked: form.pages.includes(p.path),
|
|
2340
|
+
onCheckedChange: (c) => set("pages")(c === true ? [...form.pages, p.path] : form.pages.filter((x) => x !== p.path))
|
|
2341
|
+
}
|
|
2342
|
+
),
|
|
2343
|
+
/* @__PURE__ */ jsxs(Label, { htmlFor: `${id}-page-${p.path}`, className: "font-normal", children: [
|
|
2344
|
+
p.title,
|
|
2345
|
+
" ",
|
|
2346
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
2347
|
+
"(",
|
|
2348
|
+
p.path,
|
|
2349
|
+
")"
|
|
2350
|
+
] })
|
|
2351
|
+
] })
|
|
2352
|
+
] }, p.path))
|
|
2353
|
+
] }) : null
|
|
2354
|
+
] }) : null
|
|
2355
|
+
] }),
|
|
2356
|
+
error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: error }) : null,
|
|
2357
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
2358
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: "Cancel" }),
|
|
2359
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", disabled: props.busy, children: "Save" })
|
|
2360
|
+
] })
|
|
2361
|
+
]
|
|
2362
|
+
}
|
|
2363
|
+
) }) });
|
|
2364
|
+
}
|
|
2365
|
+
function SearchPanel(props) {
|
|
2366
|
+
const [open, setOpen] = React10.useState(false);
|
|
2367
|
+
const headingId = React10.useId();
|
|
2368
|
+
const b = props.seo.localBusiness;
|
|
2369
|
+
const summary = [
|
|
2370
|
+
props.seo.noindex ? "Hidden from search" : props.seo.description ? "Description set" : "No description",
|
|
2371
|
+
props.seo.organization ? props.seo.organization.name : null,
|
|
2372
|
+
b ? `${b.address.addressLocality} business` : null
|
|
2373
|
+
].filter(Boolean);
|
|
2374
|
+
return /* @__PURE__ */ jsxs("section", { "aria-labelledby": headingId, className: "flex flex-col gap-2", "data-gs-search": "", children: [
|
|
2375
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2376
|
+
/* @__PURE__ */ jsx("h2", { id: headingId, className: "text-sm font-semibold", children: "Search and sharing" }),
|
|
2377
|
+
props.readOnly ? null : /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "ghost", disabled: props.busy, onClick: () => setOpen(true), children: "Edit" })
|
|
2378
|
+
] }),
|
|
2379
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: summary.join(" \xB7 ") }),
|
|
2380
|
+
/* @__PURE__ */ jsx(SearchDialog, { open, onClose: () => setOpen(false), props })
|
|
2381
|
+
] });
|
|
2382
|
+
}
|
|
1878
2383
|
|
|
1879
2384
|
// src/editor/preview.ts
|
|
1880
2385
|
async function loadSiteCss() {
|
|
1881
|
-
const { ASSETS } = await import('./assets.generated-
|
|
2386
|
+
const { ASSETS } = await import('./assets.generated-YGLB7VKL.js');
|
|
1882
2387
|
return ASSETS.css.body;
|
|
1883
2388
|
}
|
|
1884
2389
|
var styleText = (css) => css.replace(/<\/style/gi, "<\\/style");
|
|
1885
2390
|
async function renderPreview(input) {
|
|
1886
|
-
const [{ renderSitePageToString }, { ASSETS }] = await Promise.all([import('./handler-
|
|
2391
|
+
const [{ renderSitePageToString }, { ASSETS }] = await Promise.all([import('./handler-J5BCH2VW.js'), import('./assets.generated-YGLB7VKL.js')]);
|
|
1887
2392
|
const result = await renderSitePageToString(new Request(`https://preview.invalid${input.path}`), {
|
|
1888
2393
|
store: input.store,
|
|
1889
2394
|
brand: { getBrand: () => input.brand },
|
|
@@ -1906,7 +2411,7 @@ function SeoFields({ siteName, pagePath, pageTitle, readOnly }) {
|
|
|
1906
2411
|
const root = usePuck2((s) => s.appState.data.root);
|
|
1907
2412
|
const dispatch = usePuck2((s) => s.dispatch);
|
|
1908
2413
|
const services = useEditorServices();
|
|
1909
|
-
const id =
|
|
2414
|
+
const id = React10.useId();
|
|
1910
2415
|
const set = (patch) => {
|
|
1911
2416
|
const next = { ...seo ?? {}, ...patch };
|
|
1912
2417
|
for (const k of Object.keys(next)) if (next[k] === void 0 || next[k] === "" || next[k] === false) delete next[k];
|
|
@@ -1988,9 +2493,9 @@ function IssueList({ issues, currentPageId, onOpenPage, onShown }) {
|
|
|
1988
2493
|
] }, i)) });
|
|
1989
2494
|
}
|
|
1990
2495
|
function PublishPanel(props) {
|
|
1991
|
-
const [note, setNote] =
|
|
1992
|
-
const [rollingBack, setRollingBack] =
|
|
1993
|
-
const id =
|
|
2496
|
+
const [note, setNote] = React10.useState("");
|
|
2497
|
+
const [rollingBack, setRollingBack] = React10.useState(null);
|
|
2498
|
+
const id = React10.useId();
|
|
1994
2499
|
const errors = props.issues?.filter((i) => i.severity === "error") ?? [];
|
|
1995
2500
|
const warnings = props.issues?.filter((i) => i.severity === "warning") ?? [];
|
|
1996
2501
|
const live = props.releases.find((r) => r.id === props.liveReleaseId);
|
|
@@ -2128,9 +2633,9 @@ function worst(...states) {
|
|
|
2128
2633
|
return "saved";
|
|
2129
2634
|
}
|
|
2130
2635
|
function useCanvasFrame(css, href, theme, dark, lang) {
|
|
2131
|
-
return
|
|
2636
|
+
return React10.useCallback(
|
|
2132
2637
|
({ children, document: document2 }) => {
|
|
2133
|
-
|
|
2638
|
+
React10.useEffect(() => {
|
|
2134
2639
|
if (!document2) return;
|
|
2135
2640
|
const nodes = [];
|
|
2136
2641
|
if (href) {
|
|
@@ -2209,7 +2714,7 @@ function useSelectFooter() {
|
|
|
2209
2714
|
}
|
|
2210
2715
|
function SelectionWatcher({ onSelect }) {
|
|
2211
2716
|
const selected = usePuck3((s) => s.selectedItem?.props.id);
|
|
2212
|
-
|
|
2717
|
+
React10.useEffect(() => {
|
|
2213
2718
|
if (selected) onSelect();
|
|
2214
2719
|
}, [selected]);
|
|
2215
2720
|
return null;
|
|
@@ -2227,46 +2732,46 @@ function PagesTab(props) {
|
|
|
2227
2732
|
}
|
|
2228
2733
|
);
|
|
2229
2734
|
}
|
|
2230
|
-
function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved, previewUrl, autosaveDelay, initialPageId, siteStylesheet, readOnly = false, onDirtyChange, className }) {
|
|
2231
|
-
const [loadError, setLoadError] =
|
|
2232
|
-
const [site, setSite] =
|
|
2233
|
-
const [pages, setPages] =
|
|
2234
|
-
const [open, setOpen] =
|
|
2235
|
-
const [editorKey, setEditorKey] =
|
|
2236
|
-
const [siteState, setSiteState] =
|
|
2237
|
-
const [pageState, setPageState] =
|
|
2238
|
-
const [invalid, setInvalid] =
|
|
2239
|
-
const [busy, setBusy] =
|
|
2240
|
-
const [notice, setNotice] =
|
|
2241
|
-
const [css, setCss] =
|
|
2242
|
-
const [h1Id, setH1Id] =
|
|
2243
|
-
const [formMap, setFormMap] =
|
|
2244
|
-
const [issues, setIssues] =
|
|
2245
|
-
const [checking, setChecking] =
|
|
2246
|
-
const [publishing, setPublishing] =
|
|
2247
|
-
const [releases, setReleases] =
|
|
2248
|
-
const [liveId, setLiveId] =
|
|
2249
|
-
const [liveIds, setLiveIds] =
|
|
2250
|
-
const [leftTab, setLeftTab] =
|
|
2251
|
-
const [rightTab, setRightTab] =
|
|
2252
|
-
const [viewport, setViewport] =
|
|
2253
|
-
const [picker, setPicker] =
|
|
2254
|
-
const [preview, setPreview] =
|
|
2255
|
-
const siteSaver =
|
|
2256
|
-
const pageSaver =
|
|
2257
|
-
const pageSaverFor =
|
|
2258
|
-
const counts =
|
|
2259
|
-
const focusTitle =
|
|
2260
|
-
const titleId =
|
|
2261
|
-
const [announcement, setAnnouncement] =
|
|
2262
|
-
const [menuDraft, setMenuDraft] =
|
|
2735
|
+
function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved, landingDirectory: defaultLanding, destinations, previewUrl, autosaveDelay, initialPageId, siteStylesheet, readOnly = false, onDirtyChange, className }) {
|
|
2736
|
+
const [loadError, setLoadError] = React10.useState(null);
|
|
2737
|
+
const [site, setSite] = React10.useState(null);
|
|
2738
|
+
const [pages, setPages] = React10.useState([]);
|
|
2739
|
+
const [open, setOpen] = React10.useState(null);
|
|
2740
|
+
const [editorKey, setEditorKey] = React10.useState(0);
|
|
2741
|
+
const [siteState, setSiteState] = React10.useState(null);
|
|
2742
|
+
const [pageState, setPageState] = React10.useState(null);
|
|
2743
|
+
const [invalid, setInvalid] = React10.useState(null);
|
|
2744
|
+
const [busy, setBusy] = React10.useState(false);
|
|
2745
|
+
const [notice, setNotice] = React10.useState(null);
|
|
2746
|
+
const [css, setCss] = React10.useState(null);
|
|
2747
|
+
const [h1Id, setH1Id] = React10.useState(null);
|
|
2748
|
+
const [formMap, setFormMap] = React10.useState(/* @__PURE__ */ new Map());
|
|
2749
|
+
const [issues, setIssues] = React10.useState(null);
|
|
2750
|
+
const [checking, setChecking] = React10.useState(false);
|
|
2751
|
+
const [publishing, setPublishing] = React10.useState(false);
|
|
2752
|
+
const [releases, setReleases] = React10.useState([]);
|
|
2753
|
+
const [liveId, setLiveId] = React10.useState(null);
|
|
2754
|
+
const [liveIds, setLiveIds] = React10.useState(null);
|
|
2755
|
+
const [leftTab, setLeftTab] = React10.useState(readOnly ? "outline" : "add");
|
|
2756
|
+
const [rightTab, setRightTab] = React10.useState("edit");
|
|
2757
|
+
const [viewport, setViewport] = React10.useState("desktop");
|
|
2758
|
+
const [picker, setPicker] = React10.useState(null);
|
|
2759
|
+
const [preview, setPreview] = React10.useState(null);
|
|
2760
|
+
const siteSaver = React10.useRef(null);
|
|
2761
|
+
const pageSaver = React10.useRef(null);
|
|
2762
|
+
const pageSaverFor = React10.useRef(null);
|
|
2763
|
+
const counts = React10.useRef(/* @__PURE__ */ new Map());
|
|
2764
|
+
const focusTitle = React10.useRef(false);
|
|
2765
|
+
const titleId = React10.useId();
|
|
2766
|
+
const [announcement, setAnnouncement] = React10.useState("");
|
|
2767
|
+
const [menuDraft, setMenuDraft] = React10.useState(null);
|
|
2263
2768
|
const locked = readOnly || publishing;
|
|
2264
|
-
const lockedRef =
|
|
2769
|
+
const lockedRef = React10.useRef(locked);
|
|
2265
2770
|
lockedRef.current = locked;
|
|
2266
2771
|
const kind = open?.kind ?? "page";
|
|
2267
|
-
const editor =
|
|
2268
|
-
const slotKeys =
|
|
2269
|
-
const theme =
|
|
2772
|
+
const editor = React10.useMemo(() => createEditorConfig({ kind, counts: () => counts.current, readOnly: () => lockedRef.current }), [kind]);
|
|
2773
|
+
const slotKeys = React10.useMemo(() => createEditorConfig().slotKeys, []);
|
|
2774
|
+
const theme = React10.useMemo(() => {
|
|
2270
2775
|
try {
|
|
2271
2776
|
return siteTheme(brand, site?.theme ?? {});
|
|
2272
2777
|
} catch (err) {
|
|
@@ -2275,7 +2780,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2275
2780
|
}
|
|
2276
2781
|
}, [brand, site?.theme]);
|
|
2277
2782
|
const iframe = useCanvasFrame(css, siteStylesheet, themeCss(theme), theme.colorScheme === "dark", site?.lang ?? "en");
|
|
2278
|
-
const loadPage =
|
|
2783
|
+
const loadPage = React10.useCallback(
|
|
2279
2784
|
async (pageId, siteDoc) => {
|
|
2280
2785
|
const draft = await store.getPageDraft(pageId);
|
|
2281
2786
|
if (!draft) throw new Error("That page no longer exists, or you can't edit it.");
|
|
@@ -2304,13 +2809,13 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2304
2809
|
},
|
|
2305
2810
|
[store, autosaveDelay, slotKeys, readOnly]
|
|
2306
2811
|
);
|
|
2307
|
-
const refreshPublishing =
|
|
2812
|
+
const refreshPublishing = React10.useCallback(async () => {
|
|
2308
2813
|
const [list, live] = await Promise.all([store.listReleases(siteId), store.getLive(siteId)]);
|
|
2309
2814
|
setReleases(list);
|
|
2310
2815
|
setLiveId(live?.id ?? null);
|
|
2311
2816
|
setLiveIds(new Set(live?.snapshot.pages.map((p) => p.id) ?? []));
|
|
2312
2817
|
}, [store, siteId]);
|
|
2313
|
-
|
|
2818
|
+
React10.useEffect(() => {
|
|
2314
2819
|
let cancelled = false;
|
|
2315
2820
|
(async () => {
|
|
2316
2821
|
try {
|
|
@@ -2341,7 +2846,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2341
2846
|
};
|
|
2342
2847
|
}, [siteId, store, readOnly]);
|
|
2343
2848
|
const menuInvalid = menuDraft !== null && !menuDraft.every((i) => menuItemProblems(i).length === 0);
|
|
2344
|
-
|
|
2849
|
+
React10.useEffect(() => {
|
|
2345
2850
|
const guard = (e) => {
|
|
2346
2851
|
if (siteSaver.current?.dirty || pageSaver.current?.dirty || invalid || menuInvalid) {
|
|
2347
2852
|
e.preventDefault();
|
|
@@ -2352,20 +2857,20 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2352
2857
|
return () => window.removeEventListener("beforeunload", guard);
|
|
2353
2858
|
}, [invalid, menuInvalid]);
|
|
2354
2859
|
const dirty = !readOnly && (worst(siteState, pageState) !== "saved" || Boolean(invalid) || menuInvalid);
|
|
2355
|
-
const dirtyReported =
|
|
2356
|
-
const onDirtyChangeRef =
|
|
2860
|
+
const dirtyReported = React10.useRef(false);
|
|
2861
|
+
const onDirtyChangeRef = React10.useRef(onDirtyChange);
|
|
2357
2862
|
onDirtyChangeRef.current = onDirtyChange;
|
|
2358
|
-
|
|
2863
|
+
React10.useEffect(() => {
|
|
2359
2864
|
if (dirty === dirtyReported.current) return;
|
|
2360
2865
|
dirtyReported.current = dirty;
|
|
2361
2866
|
onDirtyChangeRef.current?.(dirty);
|
|
2362
2867
|
}, [dirty]);
|
|
2363
|
-
const formSlugs =
|
|
2868
|
+
const formSlugs = React10.useMemo(() => {
|
|
2364
2869
|
const slugs = /* @__PURE__ */ new Set();
|
|
2365
2870
|
for (const item of open?.data.content ?? []) if (item.type.startsWith("form-embed") && typeof item.props.form === "string") slugs.add(item.props.form);
|
|
2366
2871
|
return [...slugs].sort().join(",");
|
|
2367
2872
|
}, [open]);
|
|
2368
|
-
|
|
2873
|
+
React10.useEffect(() => {
|
|
2369
2874
|
if (!forms || !formSlugs) return;
|
|
2370
2875
|
let cancelled = false;
|
|
2371
2876
|
Promise.all(formSlugs.split(",").map(async (slug) => [slug, await Promise.resolve(forms(slug, { siteId, pagePath: open?.path ?? "/", mode: "preview" })).catch(() => null)])).then((entries) => {
|
|
@@ -2375,7 +2880,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2375
2880
|
cancelled = true;
|
|
2376
2881
|
};
|
|
2377
2882
|
}, [forms, formSlugs, siteId, open?.path]);
|
|
2378
|
-
const onChange =
|
|
2883
|
+
const onChange = React10.useCallback(
|
|
2379
2884
|
(data) => {
|
|
2380
2885
|
if (!open || !site || readOnly || pageSaverFor.current !== open.id) return;
|
|
2381
2886
|
const editorData = data;
|
|
@@ -2402,7 +2907,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2402
2907
|
},
|
|
2403
2908
|
[open, site, slotKeys, readOnly]
|
|
2404
2909
|
);
|
|
2405
|
-
const onNavChange =
|
|
2910
|
+
const onNavChange = React10.useCallback(
|
|
2406
2911
|
(nav) => {
|
|
2407
2912
|
const current = siteSaver.current?.latest ?? site;
|
|
2408
2913
|
if (!current || readOnly) return;
|
|
@@ -2413,14 +2918,38 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2413
2918
|
},
|
|
2414
2919
|
[site, readOnly]
|
|
2415
2920
|
);
|
|
2416
|
-
const
|
|
2921
|
+
const onRedirectsChange = React10.useCallback(
|
|
2922
|
+
(redirects) => {
|
|
2923
|
+
const current = siteSaver.current?.latest ?? site;
|
|
2924
|
+
if (!current || readOnly) return "This site can't be changed here.";
|
|
2925
|
+
const next = SiteDoc.safeParse({ ...current, redirects });
|
|
2926
|
+
if (!next.success) return `The redirects can't be saved: ${next.error.issues[0]?.message ?? "invalid"}`;
|
|
2927
|
+
siteSaver.current?.update(next.data);
|
|
2928
|
+
setSite(next.data);
|
|
2929
|
+
return null;
|
|
2930
|
+
},
|
|
2931
|
+
[site, readOnly]
|
|
2932
|
+
);
|
|
2933
|
+
const onSeoChange = React10.useCallback(
|
|
2934
|
+
(seo) => {
|
|
2935
|
+
const current = siteSaver.current?.latest ?? site;
|
|
2936
|
+
if (!current || readOnly) return "This site can't be changed here.";
|
|
2937
|
+
const next = SiteDoc.safeParse({ ...current, seo });
|
|
2938
|
+
if (!next.success) return `The settings can't be saved: ${next.error.issues[0]?.message ?? "invalid"}`;
|
|
2939
|
+
siteSaver.current?.update(next.data);
|
|
2940
|
+
setSite(next.data);
|
|
2941
|
+
return null;
|
|
2942
|
+
},
|
|
2943
|
+
[site, readOnly]
|
|
2944
|
+
);
|
|
2945
|
+
const onMenuEdit = React10.useCallback(
|
|
2417
2946
|
(items) => {
|
|
2418
2947
|
setMenuDraft(items);
|
|
2419
2948
|
if (items.every((i) => menuItemProblems(i).length === 0)) onNavChange(items.map((i) => ({ label: i.label.trim(), href: i.href.trim() })));
|
|
2420
2949
|
},
|
|
2421
2950
|
[onNavChange]
|
|
2422
2951
|
);
|
|
2423
|
-
const flushAll =
|
|
2952
|
+
const flushAll = React10.useCallback(async () => {
|
|
2424
2953
|
if (invalid) {
|
|
2425
2954
|
setNotice({ tone: "error", text: `Fix this first: ${invalid}` });
|
|
2426
2955
|
return false;
|
|
@@ -2437,7 +2966,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2437
2966
|
return false;
|
|
2438
2967
|
}
|
|
2439
2968
|
}, [invalid, menuInvalid]);
|
|
2440
|
-
const resync =
|
|
2969
|
+
const resync = React10.useCallback(async (options2 = {}) => {
|
|
2441
2970
|
const [draft, list] = await Promise.all([store.getDraft(siteId), store.listPages(siteId)]);
|
|
2442
2971
|
setPages(list);
|
|
2443
2972
|
let redraw = false;
|
|
@@ -2471,7 +3000,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2471
3000
|
}
|
|
2472
3001
|
return { draft, list };
|
|
2473
3002
|
}, [store, siteId, open, site, slotKeys]);
|
|
2474
|
-
const runCheck =
|
|
3003
|
+
const runCheck = React10.useCallback(async () => {
|
|
2475
3004
|
if (!await flushAll()) return;
|
|
2476
3005
|
setChecking(true);
|
|
2477
3006
|
try {
|
|
@@ -2484,7 +3013,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2484
3013
|
}
|
|
2485
3014
|
}, [flushAll, store, siteId, brand, reserved]);
|
|
2486
3015
|
const settled = worst(siteState, pageState) === "saved" && !invalid;
|
|
2487
|
-
|
|
3016
|
+
React10.useEffect(() => {
|
|
2488
3017
|
if (rightTab !== "publish" || !settled) return;
|
|
2489
3018
|
const t = setTimeout(() => void runCheck(), 600);
|
|
2490
3019
|
return () => clearTimeout(t);
|
|
@@ -2513,6 +3042,8 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2513
3042
|
const createPage = (request) => holding(() => createPageNow(request));
|
|
2514
3043
|
const createPageNow = async (request) => {
|
|
2515
3044
|
if (!await flushAll()) throw new Error("Save your changes first.");
|
|
3045
|
+
const problems = pathProblems(request.path, pages, { ...reserved ? { reserved } : {}, notFoundPage: request.template.id === "not-found" });
|
|
3046
|
+
if (problems.length) throw new Error(problems.join(" "));
|
|
2516
3047
|
const doc = request.template.doc({ title: request.title, brand });
|
|
2517
3048
|
const meta = await store.createPage(siteId, { path: request.path, kind: request.template.kind, doc });
|
|
2518
3049
|
const { draft } = await resync();
|
|
@@ -2559,7 +3090,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2559
3090
|
};
|
|
2560
3091
|
const createLanding = (request) => holding(async () => {
|
|
2561
3092
|
if (!await flushAll()) throw new Error("Save your changes first.");
|
|
2562
|
-
const meta = await createLandingPage(store, siteId, { ...request, brand, ...reserved ? { reserved } : {} });
|
|
3093
|
+
const meta = await createLandingPage(store, siteId, { ...request, brand, ...reserved ? { reserved } : {}, ...defaultLanding ? { defaultDirectory: defaultLanding } : {} });
|
|
2563
3094
|
const { draft } = await resync();
|
|
2564
3095
|
focusTitle.current = true;
|
|
2565
3096
|
await loadPage(meta.id, siteSaver.current?.latest ?? draft?.site ?? site);
|
|
@@ -2568,7 +3099,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2568
3099
|
const moveLanding = (pageId, slug) => holding(async () => {
|
|
2569
3100
|
if (!await flushAll()) throw new Error("Save your changes first.");
|
|
2570
3101
|
const before = pages.find((p) => p.id === pageId)?.path;
|
|
2571
|
-
const moved = await moveLandingPage(store, pageId, slug, reserved ? { reserved } : {});
|
|
3102
|
+
const moved = await moveLandingPage(store, pageId, slug, { ...reserved ? { reserved } : {}, ...defaultLanding ? { defaultDirectory: defaultLanding } : {} });
|
|
2572
3103
|
const { draft } = await resync();
|
|
2573
3104
|
if (draft && before && draft.site.nav.some((n) => n.href === before)) onNavChange(draft.site.nav.map((n) => n.href === before ? { ...n, href: moved.path } : n));
|
|
2574
3105
|
setNotice({ tone: "info", text: `Moved to ${moved.path}. ${before} now redirects there.` });
|
|
@@ -2583,7 +3114,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2583
3114
|
if (draft && draft.nav.some((n) => to.has(n.href))) onNavChange(draft.nav.map((n) => to.has(n.href) ? { ...n, href: to.get(n.href) } : n));
|
|
2584
3115
|
};
|
|
2585
3116
|
try {
|
|
2586
|
-
result = await setLandingDirectory(store, siteId, directory, { movePages, ...reserved ? { reserved } : {} });
|
|
3117
|
+
result = await setLandingDirectory(store, siteId, directory, { movePages, ...reserved ? { reserved } : {}, ...defaultLanding ? { defaultDirectory: defaultLanding } : {} });
|
|
2587
3118
|
} catch (err) {
|
|
2588
3119
|
await resync().catch(() => void 0);
|
|
2589
3120
|
if (err instanceof LandingDirectoryError) followMoves(err.moved);
|
|
@@ -2702,13 +3233,13 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2702
3233
|
function focusPageTitle() {
|
|
2703
3234
|
requestAnimationFrame(() => document.getElementById(titleId)?.focus());
|
|
2704
3235
|
}
|
|
2705
|
-
|
|
2706
|
-
|
|
3236
|
+
React10.useEffect(() => setViewport("desktop"), [editorKey]);
|
|
3237
|
+
React10.useEffect(() => {
|
|
2707
3238
|
if (!focusTitle.current) return;
|
|
2708
3239
|
focusTitle.current = false;
|
|
2709
3240
|
focusPageTitle();
|
|
2710
3241
|
}, [editorKey]);
|
|
2711
|
-
const announce =
|
|
3242
|
+
const announce = React10.useCallback((message) => {
|
|
2712
3243
|
setAnnouncement("");
|
|
2713
3244
|
requestAnimationFrame(() => setAnnouncement(message));
|
|
2714
3245
|
}, []);
|
|
@@ -2718,7 +3249,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2718
3249
|
const textEntry = target.closest("textarea, [contenteditable=''], [contenteditable='true']") || target instanceof HTMLInputElement && !["button", "checkbox", "radio", "submit", "reset", "file", "range", "color"].includes(target.type);
|
|
2719
3250
|
if (!textEntry) e.preventDefault();
|
|
2720
3251
|
};
|
|
2721
|
-
const services =
|
|
3252
|
+
const services = React10.useMemo(
|
|
2722
3253
|
() => ({
|
|
2723
3254
|
siteId,
|
|
2724
3255
|
store,
|
|
@@ -2727,7 +3258,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2727
3258
|
}),
|
|
2728
3259
|
[siteId, store, assets]
|
|
2729
3260
|
);
|
|
2730
|
-
const metadata =
|
|
3261
|
+
const metadata = React10.useMemo(
|
|
2731
3262
|
() => ({
|
|
2732
3263
|
site: { name: site?.name ?? "", lang: site?.lang ?? "en", nav: site?.nav ?? [], ...brand && "logo" in brand && brand.logo ? { logo: { src: brand.logo.src, alt: brand.logo.alt?.trim() || brandDisplayName(brand) } } : {} },
|
|
2733
3264
|
pagePath: open?.path ?? "/",
|
|
@@ -2737,7 +3268,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2737
3268
|
}),
|
|
2738
3269
|
[site?.name, site?.lang, site?.nav, brand, open?.path, open?.placeholders, formMap, h1Id]
|
|
2739
3270
|
);
|
|
2740
|
-
const overrides =
|
|
3271
|
+
const overrides = React10.useMemo(() => genesisOverrides(editor.components, { iframe }, { announce }), [editor.components, iframe, announce]);
|
|
2741
3272
|
const permissions = locked ? LOCKED : UNLOCKED;
|
|
2742
3273
|
if (loadError) {
|
|
2743
3274
|
return /* @__PURE__ */ jsxs(Alert, { variant: "destructive", className, children: [
|
|
@@ -2820,7 +3351,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2820
3351
|
LandingPanel,
|
|
2821
3352
|
{
|
|
2822
3353
|
pages,
|
|
2823
|
-
directory: landingDirectory(site),
|
|
3354
|
+
directory: landingDirectory(site, defaultLanding),
|
|
2824
3355
|
liveIds,
|
|
2825
3356
|
currentId: open.id,
|
|
2826
3357
|
reserved,
|
|
@@ -2832,7 +3363,20 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2832
3363
|
onDelete: remove,
|
|
2833
3364
|
onSetDirectory: changeLandingDirectory
|
|
2834
3365
|
}
|
|
2835
|
-
)
|
|
3366
|
+
),
|
|
3367
|
+
redirects: /* @__PURE__ */ jsx(
|
|
3368
|
+
RedirectsPanel,
|
|
3369
|
+
{
|
|
3370
|
+
redirects: site.redirects,
|
|
3371
|
+
pages,
|
|
3372
|
+
destinations: redirectDestinations(pages, destinations),
|
|
3373
|
+
reserved,
|
|
3374
|
+
busy: busy || publishing,
|
|
3375
|
+
readOnly,
|
|
3376
|
+
onChange: onRedirectsChange
|
|
3377
|
+
}
|
|
3378
|
+
),
|
|
3379
|
+
search: /* @__PURE__ */ jsx(SearchPanel, { seo: site.seo, pages, busy: busy || publishing, readOnly, onChange: onSeoChange })
|
|
2836
3380
|
}
|
|
2837
3381
|
) })
|
|
2838
3382
|
] }) }),
|