@marktiderman/genesis-sites 0.8.0 → 0.9.1

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.
Files changed (66) hide show
  1. package/README.md +128 -11
  2. package/SKILL.md +5 -0
  3. package/dist/analytics.d.ts +184 -0
  4. package/dist/analytics.js +3 -0
  5. package/dist/analytics.js.map +1 -0
  6. package/dist/assets/{form-island.da6c662a73.js → form-island.c3ffde29b6.js} +3 -3
  7. package/dist/assets/islands.21a94cdd5a.js +1 -0
  8. package/dist/assets/sites-forms.b64c156079.css +10 -0
  9. package/dist/assets/sites-forms.css +1 -1
  10. package/dist/assets/sites.2fac65f96a.css +2 -0
  11. package/dist/assets/sites.css +1 -1
  12. package/dist/assets.generated-7BO4OWC4.js +3 -0
  13. package/dist/{assets.generated-YGLB7VKL.js.map → assets.generated-7BO4OWC4.js.map} +1 -1
  14. package/dist/chunk-5RYCQEEE.js +256 -0
  15. package/dist/chunk-5RYCQEEE.js.map +1 -0
  16. package/dist/{chunk-MU2Z2C4F.js → chunk-CXBBUKGB.js} +14 -4
  17. package/dist/chunk-CXBBUKGB.js.map +1 -0
  18. package/dist/chunk-JC7VNS67.js +19 -0
  19. package/dist/chunk-JC7VNS67.js.map +1 -0
  20. package/dist/{chunk-FMQTSXJN.js → chunk-KJUN46FK.js} +60 -19
  21. package/dist/chunk-KJUN46FK.js.map +1 -0
  22. package/dist/{chunk-6CXTOPYI.js → chunk-QGU6FDH5.js} +74 -8
  23. package/dist/chunk-QGU6FDH5.js.map +1 -0
  24. package/dist/{chunk-I767PDBR.js → chunk-SBONYMUC.js} +38 -15
  25. package/dist/chunk-SBONYMUC.js.map +1 -0
  26. package/dist/{chunk-YAMQ2JKO.js → chunk-UOKNFG5O.js} +127 -14
  27. package/dist/chunk-UOKNFG5O.js.map +1 -0
  28. package/dist/{chunk-QE7KS2JS.js → chunk-UUC5USJH.js} +8 -45
  29. package/dist/chunk-UUC5USJH.js.map +1 -0
  30. package/dist/editor.d.ts +63 -14
  31. package/dist/editor.js +682 -254
  32. package/dist/editor.js.map +1 -1
  33. package/dist/handler-ZAM4NJOS.js +11 -0
  34. package/dist/{handler-J5BCH2VW.js.map → handler-ZAM4NJOS.js.map} +1 -1
  35. package/dist/import.d.ts +3 -3
  36. package/dist/import.js +1 -1
  37. package/dist/index.d.ts +23 -9
  38. package/dist/index.js +4 -4
  39. package/dist/{redirects-BNSD9MKa.d.ts → redirects-LcCNIJHQ.d.ts} +2 -2
  40. package/dist/{registry-BPn-tDlL.d.ts → registry-Cw7NF_le.d.ts} +17 -1
  41. package/dist/sections.d.ts +1 -1
  42. package/dist/sections.js +3 -3
  43. package/dist/{store-B_GMH42V.d.ts → store-BNYD5NAQ.d.ts} +30 -4
  44. package/dist/supabase.d.ts +4 -4
  45. package/dist/supabase.js +4 -4
  46. package/dist/{templates-CFSSG1iU.d.ts → templates-DPv0OYLl.d.ts} +2 -2
  47. package/dist/templates.d.ts +3 -3
  48. package/dist/templates.js +7 -3
  49. package/dist/templates.js.map +1 -1
  50. package/dist/{theme-Dw42GDI_.d.ts → theme-HJzN2tOm.d.ts} +2 -2
  51. package/dist/web.d.ts +50 -14
  52. package/dist/web.js +7 -6
  53. package/package.json +7 -3
  54. package/dist/assets/islands.83aaf5e0df.js +0 -1
  55. package/dist/assets/sites-forms.bac9a6aafd.css +0 -10
  56. package/dist/assets/sites.323090ba26.css +0 -2
  57. package/dist/assets.generated-YGLB7VKL.js +0 -3
  58. package/dist/chunk-6CXTOPYI.js.map +0 -1
  59. package/dist/chunk-FMQTSXJN.js.map +0 -1
  60. package/dist/chunk-I767PDBR.js.map +0 -1
  61. package/dist/chunk-MU2Z2C4F.js.map +0 -1
  62. package/dist/chunk-MXV2HOJO.js +0 -19
  63. package/dist/chunk-MXV2HOJO.js.map +0 -1
  64. package/dist/chunk-QE7KS2JS.js.map +0 -1
  65. package/dist/chunk-YAMQ2JKO.js.map +0 -1
  66. package/dist/handler-J5BCH2VW.js +0 -10
@@ -1,8 +1,78 @@
1
- import { getSection, redirectLoops, PostSlug, PostDoc, ReleaseSnapshot, validatePostSlug, MAX_IMPORT_POSTS, MAX_LIVE_POSTS, postSummary, redirectsAfterMove, PageDoc, SiteDoc } from './chunk-6CXTOPYI.js';
2
- import { pagePathProblems, isReservedPath, DEFAULT_RESERVED_PATHS, validatePagePath } from './chunk-MU2Z2C4F.js';
1
+ import { getSection, NOT_FOUND_PATH, redirectLoops, PostSlug, PostDoc, ReleaseSnapshot, validatePostSlug, MAX_IMPORT_POSTS, MAX_LIVE_POSTS, postSummary, redirectsAfterMove, PageDoc, SiteDoc, isSampleImage } from './chunk-QGU6FDH5.js';
2
+ import { DEFAULT_RESERVED_PATHS, pagePathProblems, normalizeRequestPath, isReservedPath, validatePagePath } from './chunk-CXBBUKGB.js';
3
3
  import { FONT_CHOICES, genesisBrand, themeFromBrand } from '@marktiderman/genesis-design-system';
4
4
  export { FONT_CHOICES } from '@marktiderman/genesis-design-system';
5
5
 
6
+ // src/core/landing.ts
7
+ var DEFAULT_LANDING_DIRECTORY = "/go";
8
+ var LANDING_SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
9
+ function landingDirectory(site, fallback) {
10
+ return site?.landing?.directory ?? fallback ?? DEFAULT_LANDING_DIRECTORY;
11
+ }
12
+ function landingPath(directory, slug) {
13
+ return `${directory}/${slug}`;
14
+ }
15
+ function landingSlugOf(directory, path) {
16
+ const prefix = `${directory}/`;
17
+ if (!path.startsWith(prefix) || path.length === prefix.length) return null;
18
+ return path.slice(prefix.length);
19
+ }
20
+ function landingDirectoryProblems(directory, reserved = DEFAULT_RESERVED_PATHS) {
21
+ if (directory === "/") return ["Landing pages need a directory of their own (like /go), not /."];
22
+ return pagePathProblems(directory, reserved).map((p) => p.replace(/^A page path/, "A landing page directory"));
23
+ }
24
+ function landingSlugProblems(directory, slug, reserved = DEFAULT_RESERVED_PATHS) {
25
+ if (!LANDING_SLUG.test(slug)) return ["A landing page's address ends in lowercase letters, digits and single hyphens (for example spring-offer)."];
26
+ return pagePathProblems(landingPath(directory, slug), reserved);
27
+ }
28
+ function isLandingPage(page) {
29
+ return page.kind === "landing" && page.path !== "/";
30
+ }
31
+ function landingPages(pages) {
32
+ return pages.filter(isLandingPage);
33
+ }
34
+ function landingMoves(pages, from, to) {
35
+ if (from === to) return [];
36
+ const moves = [];
37
+ for (const page of landingPages(pages)) {
38
+ const slug = landingSlugOf(from, page.path);
39
+ if (slug !== null) moves.push({ page, path: landingPath(to, slug) });
40
+ }
41
+ return moves;
42
+ }
43
+
44
+ // src/core/schedule.ts
45
+ function time(value) {
46
+ if (typeof value !== "string" || !value) return null;
47
+ const t = Date.parse(value);
48
+ return Number.isFinite(t) ? t : null;
49
+ }
50
+ function pageWindow(doc) {
51
+ return { from: time(doc.root.props.showFrom), until: time(doc.root.props.showUntil) };
52
+ }
53
+ function isPageShown(doc, at) {
54
+ const { from, until } = pageWindow(doc);
55
+ const now = at.getTime();
56
+ return (from === null || now >= from) && (until === null || now < until);
57
+ }
58
+ function nextPageBoundary(doc, at) {
59
+ const now = at.getTime();
60
+ const { from, until } = pageWindow(doc);
61
+ const next = [from, until].filter((t) => t !== null && t > now);
62
+ return next.length ? Math.min(...next) : null;
63
+ }
64
+ function pageWindowProblems(doc, path) {
65
+ const { showFrom, showUntil } = doc.root.props;
66
+ if (showFrom === void 0 && showUntil === void 0) return [];
67
+ if (path === "/") return ["The home page is always shown; it can't have show dates."];
68
+ if (path === NOT_FOUND_PATH) return ["The 404 page is always shown; it can't have show dates."];
69
+ const { from, until } = pageWindow(doc);
70
+ const problems = [];
71
+ if (showFrom !== void 0 && from === null) problems.push(`"${String(showFrom)}" isn't a date and time.`);
72
+ if (showUntil !== void 0 && until === null) problems.push(`"${String(showUntil)}" isn't a date and time.`);
73
+ if (from !== null && until !== null && until <= from) problems.push("The page would be hidden before it is shown: set its end after its start.");
74
+ return problems;
75
+ }
6
76
  var RADIUS = { none: "0rem", sm: "0.25rem", md: "0.5rem", lg: "0.75rem", full: "1.25rem" };
7
77
  var HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
8
78
  function parseHex(hex) {
@@ -96,10 +166,15 @@ function modeColours(brand, mode) {
96
166
  const ownText = light ? brand.primaryText : own?.primaryText;
97
167
  let primaryText = ownText && HEX.test(ownText) ? ownText : primary;
98
168
  if (primaryText === primary) {
99
- for (let t = 0.02; contrastRatio(primaryText, background) < 4.5 && t <= 1; t += 0.02) primaryText = mix(primary, light ? -t : t);
100
- if (contrastRatio(primaryText, background) < 4.5) primaryText = foreground;
169
+ const reads = (c) => contrastRatio(c, background) >= 4.5 && contrastRatio(c, muted) >= 4.5;
170
+ for (let t = 0.02; !reads(primaryText) && t <= 1; t += 0.02) primaryText = mix(primary, light ? -t : t);
171
+ if (!reads(primaryText)) primaryText = foreground;
101
172
  }
102
- return { background, foreground, muted, mutedForeground, primary, primaryForeground, primaryText, ring, border };
173
+ const displays = (c) => contrastRatio(c, background) >= 3 && contrastRatio(c, muted) >= 3;
174
+ let primaryDisplay = primary;
175
+ for (let t = 0.02; !displays(primaryDisplay) && t <= 1; t += 0.02) primaryDisplay = mix(primary, light ? -t : t);
176
+ if (!displays(primaryDisplay)) primaryDisplay = primaryText;
177
+ return { background, foreground, muted, mutedForeground, primary, primaryForeground, primaryText, primaryDisplay, ring, border };
103
178
  }
104
179
  function roleVars(c) {
105
180
  const hsl = hexToHslTriplet;
@@ -113,6 +188,7 @@ function roleVars(c) {
113
188
  "--primary": hsl(c.primary),
114
189
  "--primary-foreground": hsl(c.primaryForeground),
115
190
  "--primary-text": hsl(c.primaryText),
191
+ "--primary-display": hsl(c.primaryDisplay),
116
192
  "--secondary": hsl(c.muted),
117
193
  "--secondary-foreground": hsl(c.foreground),
118
194
  "--muted": hsl(c.muted),
@@ -327,6 +403,25 @@ function migrateSite(site, lookup) {
327
403
 
328
404
  // src/core/a11y.ts
329
405
  var isPublishable = (issues) => !issues.some((i) => i.severity === "error");
406
+ var CHOSEN_CHECKS = { "sample-image": "sampleImages", "form-missing": "missingForms" };
407
+ function applyCheckLevels(issues, levels = {}) {
408
+ const out = [];
409
+ for (const issue of issues) {
410
+ const key = Object.hasOwn(CHOSEN_CHECKS, issue.code) ? CHOSEN_CHECKS[issue.code] : void 0;
411
+ if (!key) {
412
+ out.push(issue);
413
+ continue;
414
+ }
415
+ const level = levels[key] ?? "warn";
416
+ if (level === "off") continue;
417
+ out.push({ ...issue, severity: level === "block" ? "error" : "warning" });
418
+ }
419
+ return out;
420
+ }
421
+ function placeName(path) {
422
+ if (!path) return "its image";
423
+ return path.split(".").filter((p) => p !== "src" && p !== "image").map((p) => /^\d+$/.test(p) ? String(Number(p) + 1) : p.replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase()).join(" \u203A ") || "its image";
424
+ }
330
425
  function images(value, path = []) {
331
426
  if (!value || typeof value !== "object") return [];
332
427
  if (Array.isArray(value)) return value.flatMap((v, i) => images(v, [...path, String(i)]));
@@ -373,7 +468,7 @@ function hostIssues(value, at, where, options, base = {}) {
373
468
  ...base,
374
469
  severity: options.images === "own" ? "error" : "warning",
375
470
  code: "asset-host",
376
- message: `${at}: ${what} ${where}(${path || "image"}) loads from ${hostOf(src)}, not from the site. Upload it to the site again, or copy the old site's files over with importAssets.`
471
+ message: `${at}: ${what} ${where}(${placeName(path)}) loads from ${hostOf(src)}, not from the site. Upload it to the site again so the site keeps its own copy.`
377
472
  });
378
473
  }
379
474
  return issues;
@@ -394,7 +489,8 @@ function nodeIssues(node, ctx, lookup) {
394
489
  const def = lookup(node.type);
395
490
  if (!def || !migrated.node) return issues;
396
491
  if (node.placeholder) {
397
- issues.push({ ...base, severity: "error", code: "placeholder", message: `${at}: the ${def.label} section still has the template's sample content. Replace it, or hide the section.` });
492
+ const unready = ctx.page && isLandingPage(ctx.page) ? " If this landing page isn't ready, delete it under Landing pages to publish the rest of the site." : "";
493
+ issues.push({ ...base, severity: "error", code: "placeholder", message: `${at}: the ${def.label} section still has the template's sample content. Replace it, or hide the section.${unready}` });
398
494
  }
399
495
  const placement = def.placement ?? "body";
400
496
  if (placement !== ctx.where) {
@@ -404,9 +500,13 @@ function nodeIssues(node, ctx, lookup) {
404
500
  issues.push({ ...base, severity: "error", code: "enabled-on", message: `${at}: a ${def.label} section can't go on a ${ctx.kind} page.` });
405
501
  }
406
502
  for (const { path, image } of images(migrated.node.props)) {
503
+ if (isSampleImage(image.src)) {
504
+ issues.push({ ...base, severity: "error", code: "sample-image", message: `${at}: the ${def.label} section still shows a sample picture (${placeName(path)}). Pick a photo, or remove it.` });
505
+ continue;
506
+ }
407
507
  const alt = typeof image.alt === "string" ? image.alt.trim() : "";
408
508
  if (!alt && image.decorative !== true) {
409
- issues.push({ ...base, severity: "error", code: "image-alt", message: `${at}: an image in the ${def.label} section (${path || "image"}) needs alt text, or to be marked decorative.` });
509
+ issues.push({ ...base, severity: "error", code: "image-alt", message: `${at}: an image in the ${def.label} section (${placeName(path)}) needs alt text, or to be marked decorative.` });
410
510
  }
411
511
  }
412
512
  const levels = richTextHeadings(migrated.node.props);
@@ -424,6 +524,10 @@ function checkPage(page, lookup = getSection, reserved) {
424
524
  const issues = [];
425
525
  const base = { pageId: page.id, path: page.path };
426
526
  for (const problem of pagePathProblems(page.path, reserved)) issues.push({ ...base, severity: "error", code: "path", message: `${page.path}: ${problem}` });
527
+ for (const problem of pageWindowProblems(page.doc, page.path)) issues.push({ ...base, severity: "error", code: "show-dates", message: `${page.path}: ${problem}` });
528
+ if (page.kind === "post" && (page.doc.root.props.showFrom || page.doc.root.props.showUntil)) {
529
+ issues.push({ ...base, severity: "error", code: "show-dates", message: `${page.path}: the blog's post page is always shown; it can't have show dates.` });
530
+ }
427
531
  const visible = page.doc.content.filter((n) => !n.hidden);
428
532
  const counts = /* @__PURE__ */ new Map();
429
533
  let h1 = 0;
@@ -480,6 +584,13 @@ function checkRelease(snapshot, options = {}) {
480
584
  issues.push(...checkPage(page, lookup, options.reserved));
481
585
  }
482
586
  if (!paths.has("/")) issues.push({ severity: "error", code: "no-home", message: "The site has no home page (a page at /)." });
587
+ const dated = new Set(snapshot.pages.filter((p) => p.doc.root.props.showFrom || p.doc.root.props.showUntil).map((p) => p.path));
588
+ for (const item of snapshot.site.nav) {
589
+ const target = item.href.startsWith("/") ? normalizeRequestPath(item.href.split(/[?#]/)[0]) : null;
590
+ if (target && dated.has(target)) {
591
+ issues.push({ severity: "warning", code: "menu-dated-page", path: target, message: `The menu's "${item.label}" goes to ${target}, which has show dates: outside them it's a broken link. Take it out of the menu, or link it from the page's content instead.` });
592
+ }
593
+ }
483
594
  issues.push(...checkBlog(snapshot, lookup));
484
595
  const postBase = snapshot.pages.find((p) => p.kind === "post")?.path;
485
596
  const mayBePost = (p) => postBase !== void 0 && p.startsWith(`${postBase === "/" ? "" : postBase}/`);
@@ -500,7 +611,7 @@ function checkRelease(snapshot, options = {}) {
500
611
  }
501
612
  if (options.theme) issues.push(...checkContrast(options.theme));
502
613
  issues.push(...checkAssetHosts(snapshot, { ...options, lookup }));
503
- return issues;
614
+ return applyCheckLevels(issues, options.checks);
504
615
  }
505
616
  function checkAssetHosts(snapshot, options = {}) {
506
617
  const lookup = options.lookup ?? getSection;
@@ -522,7 +633,7 @@ function checkAssetHosts(snapshot, options = {}) {
522
633
  issues.push({
523
634
  severity: hosts.images === "own" ? "error" : "warning",
524
635
  code: "asset-host",
525
- message: `The brand's logo loads from ${hostOf(options.logo)}, not from the site. Upload it to the site again, or copy it over with importAssets.`
636
+ message: `The brand's logo loads from ${hostOf(options.logo)}, not from the site. Upload it again so the site keeps its own copy.`
526
637
  });
527
638
  }
528
639
  return issues;
@@ -670,12 +781,14 @@ function prepareRelease(site, pages, options = {}) {
670
781
  pages: releasePages.map((p) => ({ ...p, doc: { ...p.doc, content: visible(p.doc.content) } }))
671
782
  });
672
783
  const theme = options.brand ? siteTheme(options.brand, snapshot.site.theme) : void 0;
784
+ if (options.brand) snapshot.brand = JSON.parse(JSON.stringify(options.brand));
673
785
  const logo = options.brand && "logo" in options.brand ? options.brand.logo?.src : void 0;
674
786
  const issues = checkRelease(snapshot, {
675
787
  ...theme ? { theme } : {},
676
788
  reserved: options.reserved ?? DEFAULT_RESERVED_PATHS,
677
789
  ...options.assetOrigins ? { assetOrigins: options.assetOrigins } : {},
678
- ...logo ? { logo } : {}
790
+ ...logo ? { logo } : {},
791
+ ...options.checks ? { checks: options.checks } : {}
679
792
  });
680
793
  if (!theme) issues.push({ severity: "error", code: "brand-missing", message: "Publish with the site's brand (`brand`), so its colours can be checked for contrast." });
681
794
  if (!isPublishable(issues)) throw new PublishBlockedError(issues);
@@ -1044,6 +1157,6 @@ function createMemorySiteStore(options = {}) {
1044
1157
  return store;
1045
1158
  }
1046
1159
 
1047
- export { ASSET_TYPES, PublishBlockedError, SiteConflictError, assetPath, brandDisplayName, checkAssetHosts, checkBlog, checkContrast, checkHtmlOutline, checkPage, checkPost, checkRelease, checkSiteDoc, contrastRatio, createMemorySiteStore, formCacheTag, hexToHslTriplet, isConflict, isOwnUrl, isPublishable, isSiteBrand, luminance, migrateNode, migratePage, migrateSite, mix, parseHex, prepareImportPost, prepareRelease, siteCacheTag, siteTheme, stableHash, themeCss, toCanonicalBrand, withCacheInvalidation };
1048
- //# sourceMappingURL=chunk-YAMQ2JKO.js.map
1049
- //# sourceMappingURL=chunk-YAMQ2JKO.js.map
1160
+ export { ASSET_TYPES, DEFAULT_LANDING_DIRECTORY, LANDING_SLUG, PublishBlockedError, SiteConflictError, applyCheckLevels, assetPath, brandDisplayName, checkAssetHosts, checkBlog, checkContrast, checkHtmlOutline, checkPage, checkPost, checkRelease, checkSiteDoc, contrastRatio, createMemorySiteStore, formCacheTag, hexToHslTriplet, isConflict, isLandingPage, isOwnUrl, isPageShown, isPublishable, isSiteBrand, landingDirectory, landingDirectoryProblems, landingMoves, landingPages, landingPath, landingSlugOf, landingSlugProblems, luminance, migrateNode, migratePage, migrateSite, mix, nextPageBoundary, pageWindow, pageWindowProblems, parseHex, prepareImportPost, prepareRelease, siteCacheTag, siteTheme, stableHash, themeCss, toCanonicalBrand, withCacheInvalidation };
1161
+ //# sourceMappingURL=chunk-UOKNFG5O.js.map
1162
+ //# sourceMappingURL=chunk-UOKNFG5O.js.map