@marktiderman/genesis-sites 0.4.0 → 0.5.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.
Files changed (67) hide show
  1. package/README.md +155 -18
  2. package/SKILL.md +46 -0
  3. package/dist/assets/fonts/LICENSES.txt +1469 -0
  4. package/dist/assets/form-island.c521219f1b.js +51 -0
  5. package/dist/assets/{islands.a521d323d9.js → islands.f275dc88cb.js} +1 -1
  6. package/dist/assets/sites-forms.490d10e01b.css +10 -0
  7. package/dist/assets/sites-forms.css +1 -1
  8. package/dist/assets/sites.1a40b828a5.css +2 -0
  9. package/dist/assets/sites.css +1 -1
  10. package/dist/assets.generated-P7NPIZHO.js +3 -0
  11. package/dist/{assets.generated-WCOFU56J.js.map → assets.generated-P7NPIZHO.js.map} +1 -1
  12. package/dist/{chunk-P5MR34QQ.js → chunk-3XCKSU4Z.js} +143 -85
  13. package/dist/chunk-3XCKSU4Z.js.map +1 -0
  14. package/dist/chunk-BJ6NXVZI.js +19 -0
  15. package/dist/chunk-BJ6NXVZI.js.map +1 -0
  16. package/dist/{chunk-3VKTBE7S.js → chunk-MU2Z2C4F.js} +2 -2
  17. package/dist/{chunk-3VKTBE7S.js.map → chunk-MU2Z2C4F.js.map} +1 -1
  18. package/dist/chunk-OFJISW3T.js +3 -0
  19. package/dist/chunk-OFJISW3T.js.map +1 -0
  20. package/dist/{chunk-FBQF2L7O.js → chunk-VLY75P7W.js} +190 -40
  21. package/dist/chunk-VLY75P7W.js.map +1 -0
  22. package/dist/{chunk-KGB6XHPS.js → chunk-VMJ67LCW.js} +97 -28
  23. package/dist/chunk-VMJ67LCW.js.map +1 -0
  24. package/dist/{chunk-KPOX7D4S.js → chunk-XOM334IK.js} +5 -5
  25. package/dist/chunk-XOM334IK.js.map +1 -0
  26. package/dist/{chunk-ZGWGQGT2.js → chunk-YAASBQTJ.js} +35 -22
  27. package/dist/chunk-YAASBQTJ.js.map +1 -0
  28. package/dist/editor.d.ts +5 -3
  29. package/dist/editor.js +14 -10
  30. package/dist/editor.js.map +1 -1
  31. package/dist/fonts.generated-HTXRHNVY.js +4 -0
  32. package/dist/handler-ESFMOYYF.js +10 -0
  33. package/dist/{handler-G35AUOTG.js.map → handler-ESFMOYYF.js.map} +1 -1
  34. package/dist/import.d.ts +26 -62
  35. package/dist/import.js +11 -258
  36. package/dist/import.js.map +1 -1
  37. package/dist/index.d.ts +10 -95
  38. package/dist/index.js +5 -4
  39. package/dist/{registry-HBn1X60x.d.ts → registry-CeSBSfU8.d.ts} +187 -13
  40. package/dist/sections.d.ts +153 -30
  41. package/dist/sections.js +3 -3
  42. package/dist/{store-BXiZeZzH.d.ts → store-CUsfzNmK.d.ts} +42 -119
  43. package/dist/supabase.d.ts +5 -3
  44. package/dist/supabase.js +15 -6
  45. package/dist/supabase.js.map +1 -1
  46. package/dist/templates-DALVa71A.d.ts +92 -0
  47. package/dist/templates.d.ts +78 -0
  48. package/dist/templates.js +146 -0
  49. package/dist/templates.js.map +1 -0
  50. package/dist/theme-B3Vh_b-P.d.ts +136 -0
  51. package/dist/web.d.ts +72 -13
  52. package/dist/web.js +7 -6
  53. package/migrations/tests/0001_genesis_sites.test.sql +4 -4
  54. package/migrations/tests/0002_genesis_sites_posts.test.sql +2 -2
  55. package/package.json +67 -15
  56. package/dist/assets/form-island.ad67ee00c0.js +0 -51
  57. package/dist/assets/sites-forms.e506c7dda2.css +0 -10
  58. package/dist/assets/sites.716b4ac1a5.css +0 -2
  59. package/dist/assets.generated-WCOFU56J.js +0 -3
  60. package/dist/chunk-FBQF2L7O.js.map +0 -1
  61. package/dist/chunk-IZQCYZ3R.js +0 -18
  62. package/dist/chunk-IZQCYZ3R.js.map +0 -1
  63. package/dist/chunk-KGB6XHPS.js.map +0 -1
  64. package/dist/chunk-KPOX7D4S.js.map +0 -1
  65. package/dist/chunk-P5MR34QQ.js.map +0 -1
  66. package/dist/chunk-ZGWGQGT2.js.map +0 -1
  67. package/dist/handler-G35AUOTG.js +0 -9
package/README.md CHANGED
@@ -18,6 +18,8 @@ hydration, and published as immutable releases you can roll back.
18
18
  - **Editor** (`/editor`): `<SiteEditor>`, the visual editor (on Puck).
19
19
  - **Block** (`/blocks`): `sitesBlock`, so `genesis add sites` installs the
20
20
  migration.
21
+ - **Templates** (`/templates`): industry template content, as data on the
22
+ neutral sections (see [A neutral core](#a-neutral-core-and-industry-templates)).
21
23
 
22
24
  Status: beta. The design and its reasoning are in
23
25
  [docs/SITES.md](../../docs/SITES.md).
@@ -49,18 +51,18 @@ import { createMemorySiteStore, landingPage } from "@marktiderman/genesis-sites"
49
51
  import { handleSiteRequest } from "@marktiderman/genesis-sites/web";
50
52
 
51
53
  const brand = {
52
- name: "Riverside Gym",
54
+ name: "Riverside Works",
53
55
  colors: { primary: "#0f766e", primaryDark: "#2dd4bf" },
54
56
  fonts: { heading: "space-grotesk", body: "inter" },
55
57
  };
56
58
  const { site, pages } = landingPage({
57
59
  brand,
58
60
  message: {
59
- headline: "Train with people who know your name",
60
- subhead: "Small classes and real coaching by the river.",
61
- benefits: [{ title: "Coached classes", body: "A coach in every class." }],
61
+ headline: "Make things with people who know your name",
62
+ subhead: "Small groups and real teaching by the river.",
63
+ benefits: [{ title: "Guided sessions", body: "A host in every session." }],
62
64
  },
63
- form: { slug: "free-class", heading: "Book a free class" },
65
+ form: { slug: "free-class", heading: "Book a free visit" },
64
66
  contact: { email: "hello@riverside.example" },
65
67
  });
66
68
 
@@ -117,6 +119,47 @@ serves:
117
119
  The page loads one script, the islands loader (2.3 KB), and only when it has a
118
120
  phone menu or a form. Pass `basePath` to mount a site under a path.
119
121
 
122
+ ### Everything from the site itself
123
+
124
+ A published page loads its fonts, styles and scripts from the site, never from
125
+ a third party. No visitor's address goes to a font host, and the
126
+ Content-Security-Policy says so: `font-src 'self'`, `script-src 'self'`, and a
127
+ `style-src` that names only the site and the hash of the page's one inline
128
+ style.
129
+
130
+ **Fonts.** Every font choice but `system` is served from `/_gs/`: the latin
131
+ subset, one woff2 per weight the choice lists, content-hashed and immutable.
132
+ The page's inline style declares an `@font-face` for each weight, with
133
+ `font-display: swap`, and the page preloads the heading font's bold file. A
134
+ face with one weight (Bebas Neue) is declared for every weight, so a bold
135
+ heading draws it as it is, without a faux bold. Pass `fonts: false` to load no
136
+ files; the page then uses an installed font or the stack's fallback.
137
+
138
+ The choices (`FONT_CHOICES`): System, Inter, DM Sans, Work Sans, Montserrat,
139
+ Poppins, Space Grotesk, Source Serif, Merriweather, Playfair Display, Lora,
140
+ Barlow, Barlow Condensed, Oswald, Roboto Condensed and Bebas Neue. Bebas Neue
141
+ has one weight, so it is a heading font only (`BodyFontChoice` leaves it out).
142
+ The list itself lives in genesis-design-system (`/fonts`), where each font
143
+ carries its class (grotesk, geometric, condensed, serif) for the design
144
+ systems' heading rules; this package still builds and serves the files.
145
+
146
+ The files come from the `@fontsource/*` packages at build time. All are under
147
+ the SIL Open Font License 1.1; their licences ship in
148
+ `dist/assets/fonts/LICENSES.txt`. They cost about 840 KB of woff2 (1.1 MB as
149
+ the base64 chunk the server holds). The handler loads that chunk on the first
150
+ font request only, never to render a page, and a visitor downloads only the
151
+ weights a page uses (about 20 KB each).
152
+
153
+ **Images.** A page's images and files should live on the site too: uploaded
154
+ with `putAsset`, or copied from an old site with `importAssets` (see
155
+ [Importing a site](#importing-a-site)). The publish check warns about one that loads from another
156
+ host. A site that sets `images: "own"` in its site document makes that an
157
+ error, and its page's policy narrows `img-src` to `'self' data:` plus the
158
+ store's asset origin (`SiteStore.assetOrigin`; the Supabase store's is its
159
+ storage origin). Other origins go in the publish's `assetOrigins` and, the
160
+ same list, in `handleSiteRequest`'s `assetOrigins`. Without it, `img-src` allows any https host, so existing
161
+ sites keep working.
162
+
120
163
  **Publishing and the cache.** Wrap the editor's store with
121
164
  `withCacheInvalidation` so publish and rollback purge `site:<id>`. Mind what
122
165
  the purge does: on Vercel, `invalidateByTag` serves each cached page once more
@@ -180,12 +223,14 @@ a button and a note per step) and `numbered`; `pricing` takes plan `groups`
180
223
  `tiers`; `logos` has a `trust-bar` variant (a short claim and badges), and an
181
224
  item without an image is a text badge.
182
225
 
183
- - **`schedule`**: the week's classes by time and day, with a host ("with …";
184
- `coach` is a deprecated alias), place, a note and a booking link per class,
185
- and chips per class type in the brand's colours (`types`, with a legend). On
226
+ - **`schedule`**: the week's sessions by time and day, with a host ("with …";
227
+ documents saved before version 2 keep an older key for it, which still
228
+ renders and moves into `host`), place, a note and a booking link per
229
+ session, the nouns a visitor hears (`labels`: `items`, default "sessions",
230
+ and `types`, default "Session types"), and chips per session type in the brand's colours (`types`, with a legend). On
186
231
  wider screens it is a table (a caption, a header cell per day and per time,
187
232
  an empty slot said as `emptyText`, default "Nothing scheduled"); on a phone a day picker: radio buttons and the stylesheet's
188
- `:has()` show one day's classes, with no script (every day shows where
233
+ `:has()` show one day's sessions, with no script (every day shows where
189
234
  `:has()` isn't supported).
190
235
  - **`team`**: photo, role, credentials, a long bio, a quote, a button and a
191
236
  link to the person's page (`profile`). The cards open each bio in place
@@ -252,6 +297,90 @@ props; `migrateNode` runs the steps on read and a publish writes the result
252
297
  into the release. `sectionJsonSchema(type)` gives the props' JSON Schema (for
253
298
  editor fields and AI output) and `sectionManifests()` the editor's catalog.
254
299
 
300
+ ## Design systems
301
+
302
+ A brand is identity (name, colours, fonts, logo). A **design system** is the
303
+ look rules attached to it: the type ramp, space, corners, surfaces, image
304
+ treatment and motion. They come from genesis-design-system
305
+ (`defineDesignSystem`, versioned like `crisp@1`); a brand names one, plus up
306
+ to three choices from fixed lists:
307
+
308
+ ```ts
309
+ const brand: SiteBrand = {
310
+ name: "Riverside Works",
311
+ colors: { primary: "#0f766e", secondary: "#f59e0b" }, // one accent, one optional supporting colour
312
+ fonts: { heading: "space-grotesk", body: "inter" },
313
+ designSystem: { id: "soft@1", density: "generous", corners: "round", motion: "calm" },
314
+ };
315
+ ```
316
+
317
+ - **Swapping it re-themes every page with no other work.** Sections draw only
318
+ tokens, so a swap changes the page's theme `<style>` (its CSS variables) and
319
+ nothing else in the HTML. A test renders the same page under every shipped
320
+ design system and compares.
321
+ - **`classic@1` is the default** and emits no tokens: a brand that names no
322
+ design system looks exactly as before, and its release hash is unchanged.
323
+ - **Built in** (genesis-design-system): `classic@1`, `crisp@1` (cool, exact,
324
+ flat) and `soft@1` (warm, generous, rounded). **Industry ones** are template
325
+ content in `/templates`: `forge@1` (bold, poster headings, square) and
326
+ `studio@1` (calm, warm, rounded). Register the ones you offer once at
327
+ startup; a brand naming an id that isn't registered is logged and themes
328
+ as `classic@1`:
329
+
330
+ ```ts
331
+ import { registerDesignSystem } from "@marktiderman/genesis-design-system";
332
+ import { industryDesignSystems } from "@marktiderman/genesis-sites/templates";
333
+
334
+ registerDesignSystem(...industryDesignSystems);
335
+ ```
336
+
337
+ - **Colour.** A design system with `surfaces` themes through the OKLCH colour
338
+ engine: neutrals tinted with the brand, a warm or cool ground (never pure
339
+ white), the accent as a fill (the brand colour, unchanged) and as text
340
+ (walked down its ramp until it reads at 4.5:1), and every text colour
341
+ solved to pass WCAG AA, in light and dark. A neon or near-white brand
342
+ colour passes: its buttons keep the colour, with dark text on them. The
343
+ publish's contrast check reads the engine's pairs.
344
+ - **What the tokens drive today** (`src/web/sites.css`, each with today's
345
+ value as its fallback): heading sizes from the fluid ramp (a clamp per step,
346
+ so browser zoom works; the hero's display step can reach 112px), heading
347
+ weight, tracking and case by the heading font's class, eyebrows and lead
348
+ copy, section padding by density, neighbouring bands on the same surface
349
+ sharing their padding (no doubled gap), corners (`--radius`) and button
350
+ corners, the photo filter, the wash behind text over a photo (the least
351
+ that keeps 4.5:1, instead of 80%), and motion: below-the-fold sections rise
352
+ in with a scroll-driven animation, never the hero, and never under reduced
353
+ motion. Shadows, border width, grain and the space scale are emitted as
354
+ tokens for sections to adopt.
355
+ - `siteTheme(brand, theme, { designSystem })` previews another design system
356
+ without changing the brand ("try a look").
357
+
358
+ ## A neutral core, and industry templates
359
+
360
+ The core never names an industry: its schemas, sections, presets, defaults,
361
+ examples and docs read naturally for any business (a person and their role,
362
+ a session and its host). Industry flavour is template content, in
363
+ `src/templates/` and exported from `/templates`: per-section presets on the
364
+ sections' own preset shape, plus a sample brand and message for
365
+ `landingPage`, `onePageSite` and `starterSite`. A template never adds a code
366
+ path; a section renders the same whichever template its props came from.
367
+ The businesses in templates are made up. Industry design systems
368
+ (`forgeDesignSystem`, `studioDesignSystem`, `industryDesignSystems`) live here
369
+ too, as tokens only, and a template lists the ones that suit it
370
+ (`template.designSystems`).
371
+
372
+ ```ts
373
+ import { industryTemplates } from "@marktiderman/genesis-sites/templates";
374
+
375
+ for (const template of Object.values(industryTemplates)) {
376
+ template.presets.team; // SectionPreset[]: offer them beside the built-in ones
377
+ }
378
+ ```
379
+
380
+ CI (`scripts/check-industry-words.mjs`, word list in
381
+ `scripts/industry-words.mjs`) fails on industry words anywhere in this
382
+ package but `src/templates/`.
383
+
255
384
  ## Publish checks
256
385
 
257
386
  `store.publish` runs `prepareRelease`, which migrates every node and refuses
@@ -263,20 +392,27 @@ to publish (`PublishBlockedError`, with `issues`) when:
263
392
  one hero;
264
393
  - a brand colour pair the sections draw is under 4.5:1 (3:1 for the focus
265
394
  ring), in each colour scheme the site uses, or the publish wasn't given the
266
- brand to check;
395
+ brand to check (with a colour design system, these are the colour engine's
396
+ pairs, which are solved to pass);
267
397
  - an image has no alt text and isn't marked decorative;
268
398
  - a section is unknown, has invalid props or was saved by newer code;
269
399
  - a template placeholder is still visible;
270
- - a page path is malformed or reserved, or the site has no home page.
271
-
272
- Warnings (an unknown variant, a page with no hero, a missing description)
273
- don't block.
274
- `checkRelease`, `checkPage`, `checkContrast` and `checkHtmlOutline` are
275
- exported for an editor's lint panel.
400
+ - a page path is malformed or reserved, or the site has no home page;
401
+ - on a site with `images: "own"`, an image, a file or the brand's logo loads
402
+ from a host other than the site and the store's asset origin.
403
+
404
+ Warnings (an unknown variant, a page with no hero, a missing description, an
405
+ image from another host on any other site) don't block. An image from another
406
+ host says how to fix it: upload it again, or copy the old site's files with
407
+ `importAssets`.
408
+ `checkRelease`, `checkPage`, `checkContrast`, `checkAssetHosts` and
409
+ `checkHtmlOutline` are exported for an editor's lint panel. `checkPost` takes
410
+ the same `{ images, assetOrigins }` as its third argument; the stores pass the
411
+ site's setting when they publish a post.
276
412
 
277
413
  ## SEO
278
414
 
279
- Each page gets a title from the site's template (`%s · Riverside Gym`), a
415
+ Each page gets a title from the site's template (`%s · Riverside Works`), a
280
416
  description, `robots`, a canonical URL from `origin`, and Open Graph and
281
417
  Twitter tags. The home page carries `Organization` and `WebSite` JSON-LD, and
282
418
  every page below it a `BreadcrumbList`. `sitemap.xml` lists the indexable
@@ -547,4 +683,5 @@ Vercel.
547
683
 
548
684
  ## License
549
685
 
550
- MIT
686
+ MIT. The font files it serves are under the SIL Open Font License 1.1 (see
687
+ `dist/assets/fonts/LICENSES.txt`).
package/SKILL.md ADDED
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: genesis-sites
3
+ description: Add or change a site, landing page or blog in a Genesis app with @marktiderman/genesis-sites (a module) — install it with genesis add sites, decide who edits, serve pages with handleSiteRequest, and add sections. Load before building any public page, landing page or site editor.
4
+ ---
5
+
6
+ # genesis-sites
7
+
8
+ A module: a mini app an app installs whole and a tenant switches on. A site is a set of pages
9
+ made of sections, drawn from the brand, served as cached HTML with no hydration, and published
10
+ as releases you can roll back. Its tables are in the `genesis_sites` schema.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ genesis add sites # migrations and their pgTAP tests, the feature entry, the steps
16
+ pnpm add @marktiderman/genesis-sites zod@^4
17
+ ```
18
+
19
+ Then, as `genesis add` prints:
20
+
21
+ 1. Expose `genesis_sites` to the API (`[api] schemas` in `supabase/config.toml`, and the dashboard).
22
+ 2. Decide who edits: replace `genesis_sites.can_edit(uuid)` (and `can_view`) in a migration of your
23
+ own, after the module's. The stubs fail closed. Name the person (`auth.uid()`) in the hook.
24
+ 3. Mount `handleSiteRequest` from `/web` before the app's routes. It returns `null` for a path that
25
+ isn't the site's, so the app answers.
26
+
27
+ ## Which entry point
28
+
29
+ | Need | Import |
30
+ |---|---|
31
+ | Site and page documents, `defineSection`, `landingPage`, `starterSite`, publish checks | `@marktiderman/genesis-sites` |
32
+ | The built-in sections | `@marktiderman/genesis-sites/sections` |
33
+ | Serving: `handleSiteRequest` | `@marktiderman/genesis-sites/web` |
34
+ | The Supabase store | `@marktiderman/genesis-sites/supabase` |
35
+ | The visual editor, `<SiteEditor>` | `@marktiderman/genesis-sites/editor` |
36
+ | Importing an old site's assets (Node) | `@marktiderman/genesis-sites/import` |
37
+
38
+ ## Rules
39
+
40
+ - Reuse a section before writing one; a new one is `defineSection` with a props schema and a
41
+ migration for its props, never a hand-built page.
42
+ - Forms on a page embed Genesis Forms (the `forms` primitive); don't build a contact form by hand.
43
+ - Never write to `genesis_sites` from outside the module's functions: the schema is the module's.
44
+ - Which plan unlocks Sites is the app's call, in its own `features.ts`.
45
+
46
+ Details: the package README and [docs/SITES.md](https://github.com/marktiderman/genesis/blob/main/docs/SITES.md).