@marktiderman/genesis-sites 0.2.0 → 0.3.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.
- package/README.md +89 -5
- package/dist/assets/form-island.6a75e310e3.js +51 -0
- package/dist/assets/{islands.77d11f5697.js → islands.825682bd57.js} +1 -1
- package/dist/assets/sites-forms.732cc7e0c1.css +10 -0
- package/dist/assets/sites-forms.css +1 -1
- package/dist/assets/sites.716b4ac1a5.css +2 -0
- package/dist/assets/sites.css +1 -1
- package/dist/assets.generated-V3HPVNXQ.js +3 -0
- package/dist/assets.generated-V3HPVNXQ.js.map +1 -0
- package/dist/{chunk-IXMY4B56.js → chunk-FBQF2L7O.js} +90 -89
- package/dist/chunk-FBQF2L7O.js.map +1 -0
- package/dist/chunk-HCICSNBH.js +465 -0
- package/dist/chunk-HCICSNBH.js.map +1 -0
- package/dist/chunk-KPOX7D4S.js +250 -0
- package/dist/chunk-KPOX7D4S.js.map +1 -0
- package/dist/chunk-TL2ZKVML.js +18 -0
- package/dist/chunk-TL2ZKVML.js.map +1 -0
- package/dist/editor.d.ts +526 -0
- package/dist/editor.js +2480 -0
- package/dist/editor.js.map +1 -0
- package/dist/handler-3VGM5WKF.js +9 -0
- package/dist/handler-3VGM5WKF.js.map +1 -0
- package/dist/import.d.ts +2 -2
- package/dist/index.d.ts +11 -5
- package/dist/index.js +2 -249
- package/dist/index.js.map +1 -1
- package/dist/{registry-D_DCWRTc.d.ts → registry-HBn1X60x.d.ts} +1 -1
- package/dist/sections.d.ts +1 -1
- package/dist/{store-DkSycDhq.d.ts → store-BXiZeZzH.d.ts} +2 -2
- package/dist/supabase.d.ts +3 -3
- package/dist/supabase.js +2 -2
- package/dist/web.d.ts +5 -5
- package/dist/web.js +6 -476
- package/dist/web.js.map +1 -1
- package/package.json +18 -8
- package/dist/assets/form-island.c0f6fac859.js +0 -51
- package/dist/assets/sites-forms.4e6aa42497.css +0 -10
- package/dist/assets/sites.e1ffd2708b.css +0 -2
- package/dist/chunk-IXMY4B56.js.map +0 -1
package/README.md
CHANGED
|
@@ -15,12 +15,11 @@ hydration, and published as immutable releases you can roll back.
|
|
|
15
15
|
- **Import** (`/import`, Node): `importAssets`, which re-hosts an old site's
|
|
16
16
|
images and PDFs behind a guard against server-side request forgery, and
|
|
17
17
|
`rewriteUrls`.
|
|
18
|
+
- **Editor** (`/editor`): `<SiteEditor>`, the visual editor (on Puck).
|
|
18
19
|
- **Block** (`/blocks`): `sitesBlock`, so `genesis add sites` installs the
|
|
19
20
|
migration.
|
|
20
21
|
|
|
21
|
-
Status: beta. The
|
|
22
|
-
(`sectionManifests`, `sectionJsonSchema`, labels, categories, variants and
|
|
23
|
-
presets) are in place for it. The design and its reasoning are in
|
|
22
|
+
Status: beta. The design and its reasoning are in
|
|
24
23
|
[docs/SITES.md](../../docs/SITES.md).
|
|
25
24
|
|
|
26
25
|
## Install
|
|
@@ -32,8 +31,9 @@ pnpm add @marktiderman/genesis-sites zod@^4
|
|
|
32
31
|
|
|
33
32
|
Peers: `react` and `react-dom` 19, `zod` 4, `@marktiderman/genesis-ui`,
|
|
34
33
|
`@marktiderman/genesis-design-system`, `@marktiderman/genesis-forms` and
|
|
35
|
-
`-forms-web` (the form embed), `lucide-react`,
|
|
36
|
-
the Supabase store.
|
|
34
|
+
`-forms-web` (the form embed), `lucide-react`, `@supabase/supabase-js` for
|
|
35
|
+
the Supabase store, and `@puckeditor/core` 0.23 for the editor. The last two
|
|
36
|
+
are optional: install them only if you use the Supabase store or `/editor`.
|
|
37
37
|
|
|
38
38
|
Then:
|
|
39
39
|
|
|
@@ -445,6 +445,90 @@ A public bucket serves any file to whoever has its URL, so give uploads random
|
|
|
445
445
|
names (`putAsset` does) and never put anything there that isn't meant for the
|
|
446
446
|
published site.
|
|
447
447
|
|
|
448
|
+
## The editor
|
|
449
|
+
|
|
450
|
+
```bash
|
|
451
|
+
pnpm add @puckeditor/core@^0.23 # only where the editor runs
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
```tsx
|
|
455
|
+
import { SiteEditor } from "@marktiderman/genesis-sites/editor";
|
|
456
|
+
|
|
457
|
+
<div style={{ height: "100dvh" }}>
|
|
458
|
+
<SiteEditor siteId={siteId} store={store} brand={brand} forms={forms} onPublish={(release) => purge(release)} />
|
|
459
|
+
</div>;
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
`SiteEditor` fills its parent, so give the parent a height. Props:
|
|
463
|
+
|
|
464
|
+
| Prop | |
|
|
465
|
+
|---|---|
|
|
466
|
+
| `siteId`, `store` | Any `SiteStore`: the Supabase store signed in as the editor, or the memory store. |
|
|
467
|
+
| `brand` | The site's brand: the canvas theme, and what publishing checks contrast against. |
|
|
468
|
+
| `forms?` | Your `FormsResolver`, so form embeds draw on the canvas and in preview. |
|
|
469
|
+
| `assets?` | `{ list?, upload?, maxBytes? }`: the image library, and an upload of your own instead of the store's `putAsset`. |
|
|
470
|
+
| `onPublish?` | Called with each new release. |
|
|
471
|
+
| `onDirtyChange?` | Called with whether anything isn't saved yet. Block your app's own navigation while it's true; closing the tab is guarded already. |
|
|
472
|
+
| `siteStylesheet?` | The site stylesheet's URL (`@marktiderman/genesis-sites/sites.css`, say through Vite's `?url`). Without it the canvas loads the renderer's bundled assets, a much larger download. |
|
|
473
|
+
| `reserved?` | Paths pages can't use (default: the store's rule, `DEFAULT_RESERVED_PATHS`). |
|
|
474
|
+
| `previewUrl?` | A link to your own preview route for a page path, shown in the Publish panel. |
|
|
475
|
+
| `readOnly?` | View only: the canvas, fields and SEO can't be changed; there is no Add picker, no page actions, no Publish and no Roll back; no autosaver is made, so nothing is saved. A "View only" note says so. |
|
|
476
|
+
| `autosaveDelay?`, `initialPageId?`, `className?` | |
|
|
477
|
+
|
|
478
|
+
What it does:
|
|
479
|
+
|
|
480
|
+
- **Generated from the registry.** Each section becomes one Add-picker entry
|
|
481
|
+
per preset, grouped by category, with fields made from its JSON Schema:
|
|
482
|
+
text and textareas, a select for its layout (variants) and for enums, the
|
|
483
|
+
image picker for images, the Genesis rich text editor, objects (links),
|
|
484
|
+
lists, one-per-line string lists, and Puck slots for props marked
|
|
485
|
+
`x-genesis-kind: "slot"`. A section at its `limit` can't be added again. A
|
|
486
|
+
prop the editor can't map shows as "can't be edited here" and warns in the
|
|
487
|
+
console; it is kept as it is. Register a section and it appears; nothing in
|
|
488
|
+
the editor changes.
|
|
489
|
+
- **The canvas** is an iframe drawn by each section's own renderer, with the
|
|
490
|
+
site stylesheet and your brand's theme, and the site's header and footer
|
|
491
|
+
as editable slots above and below the page. **Preview** runs the real
|
|
492
|
+
`/web` handler on the drafts (and **View it live** on the live release)
|
|
493
|
+
in a sandboxed frame with no scripts.
|
|
494
|
+
- **Autosave** saves a moment after each change by compare-and-swap. If
|
|
495
|
+
someone else saved first, it stops, keeps your edits, and asks: load their
|
|
496
|
+
version, or keep yours. Closing the tab with unsaved changes asks first;
|
|
497
|
+
for a route change in your app, use `onDirtyChange` to ask. When the editor
|
|
498
|
+
unmounts with changes still waiting it saves them on the way out, but it
|
|
499
|
+
can't wait for that save, so a host that must not lose them asks first.
|
|
500
|
+
Undo and redo are Puck's history (the toolbar, or Ctrl+Z and Ctrl+Shift+Z).
|
|
501
|
+
- **Pages**: open, add (blank, the landing page from your brand, or a starter
|
|
502
|
+
site page), change an address (the old one redirects with a 301; reserved
|
|
503
|
+
paths are refused), delete, and edit the header menu. Reordering pages
|
|
504
|
+
needs a store with `reorderPages(siteId, pageIds)`; without it the list is
|
|
505
|
+
in the store's order.
|
|
506
|
+
- **Publish**: the publish checks run on the saved drafts and errors block
|
|
507
|
+
the button. While a publish runs the canvas is read-only and autosave
|
|
508
|
+
waits, so no edit races the store's own re-saves; afterwards the editor
|
|
509
|
+
takes the new revisions and saves anything that waited; "Show" selects the section a check is about. Publish with a
|
|
510
|
+
note, see the release history, and roll back. Per-page SEO (search title,
|
|
511
|
+
description, share image, noindex) is in the same panel.
|
|
512
|
+
- **Images** come from an upload, the library, or a link; every one needs alt
|
|
513
|
+
text unless it is marked decorative. SVG isn't accepted.
|
|
514
|
+
- **Accessible**: every field has a label; nothing needs dragging (each
|
|
515
|
+
Add-picker entry has an Add button, and the selected section's Up, Down
|
|
516
|
+
and Remove buttons sit above its fields); actions are announced; and the
|
|
517
|
+
panels are Genesis UI tabs and dialogs. Puck's canvas and outline still
|
|
518
|
+
move sections only by dragging.
|
|
519
|
+
|
|
520
|
+
Puck is an optional peer dependency (`@puckeditor/core`): an app that only
|
|
521
|
+
serves sites never installs it, and the root, `/web` and `/sections` never
|
|
522
|
+
import it. It stays inside `/editor`: import everything from here (it re-exports `usePuck`, `createUsePuck` and the
|
|
523
|
+
`PuckConfig`, `PuckData` and `PuckOverrides` types for extensions), and
|
|
524
|
+
never from `@puckeditor/core`. `/web` never imports the editor, so published
|
|
525
|
+
pages carry no Puck code. The lower-level pieces are exported too:
|
|
526
|
+
`createEditorConfig`, `sectionFields`, `toEditorData` and `fromEditorData`,
|
|
527
|
+
`Autosaver`, and `checkSite`, `publishSite`, `renamePage` and
|
|
528
|
+
`pageTemplates`.
|
|
529
|
+
|
|
530
|
+
The sample app's `/sites-editor` route is a working demo on the memory store.
|
|
531
|
+
|
|
448
532
|
## Stores
|
|
449
533
|
|
|
450
534
|
`createSupabaseSiteStore(client)` uses the `genesis_sites` functions: pass a
|