@marktiderman/genesis-sites 0.7.6 → 0.9.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 +202 -19
- package/SKILL.md +15 -0
- package/dist/analytics.d.ts +184 -0
- package/dist/analytics.js +3 -0
- package/dist/analytics.js.map +1 -0
- package/dist/assets/form-island.da6c662a73.js +51 -0
- package/dist/assets/islands.399b13ea6f.js +1 -0
- package/dist/assets/sites-forms.b64c156079.css +10 -0
- package/dist/assets/sites-forms.css +1 -1
- package/dist/assets/sites.2fac65f96a.css +2 -0
- package/dist/assets/sites.css +1 -1
- package/dist/assets.generated-ZBFSP23U.js +3 -0
- package/dist/{assets.generated-LLUGUUWZ.js.map → assets.generated-ZBFSP23U.js.map} +1 -1
- package/dist/blocks.js +2 -1
- package/dist/blocks.js.map +1 -1
- package/dist/chunk-5G2H6EZ2.js +19 -0
- package/dist/chunk-5G2H6EZ2.js.map +1 -0
- package/dist/chunk-5RYCQEEE.js +256 -0
- package/dist/chunk-5RYCQEEE.js.map +1 -0
- package/dist/{chunk-7E3YGYVH.js → chunk-ATRS5GSD.js} +77 -22
- package/dist/chunk-ATRS5GSD.js.map +1 -0
- package/dist/{chunk-MU2Z2C4F.js → chunk-CXBBUKGB.js} +14 -4
- package/dist/chunk-CXBBUKGB.js.map +1 -0
- package/dist/{chunk-IU6AI75R.js → chunk-QGU6FDH5.js} +413 -162
- package/dist/chunk-QGU6FDH5.js.map +1 -0
- package/dist/{chunk-SMJMXQ3T.js → chunk-SBONYMUC.js} +294 -73
- package/dist/chunk-SBONYMUC.js.map +1 -0
- package/dist/{chunk-VJ4HOFBA.js → chunk-UOKNFG5O.js} +144 -20
- package/dist/chunk-UOKNFG5O.js.map +1 -0
- package/dist/{chunk-KY4ALBVH.js → chunk-UUC5USJH.js} +58 -37
- package/dist/chunk-UUC5USJH.js.map +1 -0
- package/dist/editor.d.ts +76 -19
- package/dist/editor.js +1217 -245
- package/dist/editor.js.map +1 -1
- package/dist/handler-OR554RTS.js +11 -0
- package/dist/{handler-UMGSZY33.js.map → handler-OR554RTS.js.map} +1 -1
- package/dist/import.d.ts +3 -3
- package/dist/import.js +1 -1
- package/dist/index.d.ts +66 -11
- package/dist/index.js +4 -4
- package/dist/redirects-LcCNIJHQ.d.ts +43 -0
- package/dist/{registry-BIijndsq.d.ts → registry-Cw7NF_le.d.ts} +92 -1
- package/dist/sections.d.ts +86 -4
- package/dist/sections.js +3 -3
- package/dist/{store-BImtGmoF.d.ts → store-BNYD5NAQ.d.ts} +30 -4
- package/dist/supabase.d.ts +4 -4
- package/dist/supabase.js +4 -4
- package/dist/{templates-kA-jrnWA.d.ts → templates-DPv0OYLl.d.ts} +2 -2
- package/dist/templates.d.ts +3 -3
- package/dist/templates.js +7 -3
- package/dist/templates.js.map +1 -1
- package/dist/{theme-Cg-inpk5.d.ts → theme-HJzN2tOm.d.ts} +2 -2
- package/dist/web.d.ts +64 -18
- package/dist/web.js +7 -6
- 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 +12 -4
- package/dist/assets/form-island.defb8daccc.js +0 -51
- package/dist/assets/islands.33a445f34e.js +0 -1
- 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-MU2Z2C4F.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/README.md
CHANGED
|
@@ -102,13 +102,18 @@ export async function handle(request: Request) {
|
|
|
102
102
|
`handleSiteRequest` answers `GET` and `HEAD` and returns `null` for anything it
|
|
103
103
|
doesn't own: another method, a reserved path (`/api`, `/_server`, `/auth`, and
|
|
104
104
|
`/_gs`, where it serves its own assets), an unknown path (or the site's 404 page
|
|
105
|
-
with `unknownPath: "not-found"`), or a site that isn't published.
|
|
105
|
+
with `unknownPath: "not-found"`), or a site that isn't published. The 404 page
|
|
106
|
+
is the site's page at `/404` (`NOT_FOUND_PATH`), made in the editor's Page not
|
|
107
|
+
found section from `notFoundPageDoc()` and edited like any page; it answers 404
|
|
108
|
+
with `noindex` at every unknown address and at `/404` itself, and stays out of
|
|
109
|
+
the sitemap. A site without one shows a built-in "Page not found". In order, it
|
|
106
110
|
serves:
|
|
107
111
|
|
|
108
112
|
1. its own content-hashed assets under `/_gs/` (immutable);
|
|
109
113
|
2. `robots.txt` and `sitemap.xml`;
|
|
110
|
-
3. the site's redirects, then a 308 to the one address of a page
|
|
111
|
-
trailing slash)
|
|
114
|
+
3. the site's exact redirects, then a 308 to the one address of a page
|
|
115
|
+
(lowercase, no trailing slash), then, where no page or post is, its prefix
|
|
116
|
+
redirects;
|
|
112
117
|
4. the page: streamed HTML from `renderToReadableStream`, with no hydration, an
|
|
113
118
|
inline theme `<style>`, a Content-Security-Policy, `Cache-Control: public,
|
|
114
119
|
max-age=0, s-maxage=31536000, stale-while-revalidate=86400` and
|
|
@@ -174,11 +179,18 @@ const editorStore = withCacheInvalidation(store, (tags, { action }) =>
|
|
|
174
179
|
);
|
|
175
180
|
```
|
|
176
181
|
|
|
177
|
-
Archiving a site
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
+
Archiving a site doesn't go through the store: purge the tag there too (the
|
|
183
|
+
database sends a `genesis_sites` notification on every publish, rollback and
|
|
184
|
+
archive, for a listener). A failed purge is logged and rethrown.
|
|
185
|
+
|
|
186
|
+
A release keeps the brand it was published with (`snapshot.brand`), and the
|
|
187
|
+
live site renders with it: editing the brand changes the editor and the
|
|
188
|
+
preview at once, and the live site with the next publish, so a brand edit
|
|
189
|
+
needs no purge, and a rollback brings back the look the site had. The
|
|
190
|
+
Publish panel says when the look changed since the live release. The brand
|
|
191
|
+
is public, like the page it styles. A release from before releases kept
|
|
192
|
+
their brand renders with the host's current brand, cached for 5 minutes
|
|
193
|
+
with a warning when that brand changed since it was checked.
|
|
182
194
|
|
|
183
195
|
A hidden section stays in the draft and is left out of the release, so it is
|
|
184
196
|
never public. A stored page that no longer parses is left out of the site
|
|
@@ -198,15 +210,15 @@ renders an empty list (or, for one post, not found) instead of failing the page.
|
|
|
198
210
|
|---|---|---|
|
|
199
211
|
| `nav` | simple, centered, minimal | Header with menu; Centred header; Landing page header |
|
|
200
212
|
| `hero` | centered, split, image-bg | Centred hero; Hero with image |
|
|
201
|
-
| `features` | grid, list, alternating | Three features; Feature list |
|
|
202
|
-
| `cta` | banner, card, split | Banner; Card |
|
|
213
|
+
| `features` | grid, list, alternating | Three features; Feature list; Included and not included |
|
|
214
|
+
| `cta` | banner, card, split, image-bg, sticky | Banner; Card; Phone bar |
|
|
203
215
|
| `testimonials` | grid, single | Quotes; One quote |
|
|
204
216
|
| `faq` | accordion, list | FAQ |
|
|
205
217
|
| `pricing` | cards, compact | Three plans |
|
|
206
218
|
| `logos` | row, grid | Logo row |
|
|
207
219
|
| `stats` | row, cards | Three numbers |
|
|
208
220
|
| `gallery` | grid, masonry | Photo grid |
|
|
209
|
-
| `rich-text` | narrow, wide | Text |
|
|
221
|
+
| `rich-text` | narrow, wide, split | Text |
|
|
210
222
|
| `form-embed` | card, split | Contact form; Form card |
|
|
211
223
|
| `footer` | simple, columns, minimal | Footer; Footer with columns |
|
|
212
224
|
| `schedule` | grid, agenda | Weekly timetable; Day by day |
|
|
@@ -223,6 +235,35 @@ a button and a note per step) and `numbered`; `pricing` takes plan `groups`
|
|
|
223
235
|
`tiers`; `logos` has a `trust-bar` variant (a short claim and badges), and an
|
|
224
236
|
item without an image is a text badge.
|
|
225
237
|
|
|
238
|
+
Section options:
|
|
239
|
+
|
|
240
|
+
- **Eyebrows**: a short line above the heading on every section with an
|
|
241
|
+
intro, `cta`, `faq`, `testimonials`, `gallery`, `logos`, `stats` and
|
|
242
|
+
`rich-text` included.
|
|
243
|
+
- **A highlighted phrase**: `headingAccent` on `hero`, `cta` and `rich-text`
|
|
244
|
+
sets the first place the heading contains it (any case) in the brand's
|
|
245
|
+
accent colour, or underlines it on an accent or inverse band. A phrase
|
|
246
|
+
the heading doesn't contain changes nothing. `withAccent` does the same in
|
|
247
|
+
a section of your own.
|
|
248
|
+
- **`hero`**: `stats`, two to five value and label pairs under the buttons.
|
|
249
|
+
- **`rich-text`**: `split` puts the eyebrow and heading in one column and the
|
|
250
|
+
copy in the other.
|
|
251
|
+
- **`cta`**: `image-bg` puts the band over an image behind a scrim (as the
|
|
252
|
+
hero's does; without an image it is the banner); `sticky` is a bar fixed to
|
|
253
|
+
the bottom of the screen on phones (heading and the first button, above the
|
|
254
|
+
safe area) and a band in the page on wider screens. Put it last on the page.
|
|
255
|
+
- **`features`**: `compare`, two lists side by side (`included`, with a tick,
|
|
256
|
+
and `excluded`, with a dash), with or instead of the items; and an `anchor`
|
|
257
|
+
per item for links straight to it. `pricing` plans take an `anchor` too.
|
|
258
|
+
- **`faq`**: answers are rich text (links, emphasis, lists). Version 1's
|
|
259
|
+
plain answers move on read: a blank line starts a paragraph and a single
|
|
260
|
+
line break stays a break (`answerToRichText`).
|
|
261
|
+
- **`nav`**: `tagline` under the site's name; `ctaShortLabel`, the button's
|
|
262
|
+
label below wide screens (the phone menu keeps the full one); and
|
|
263
|
+
`drawerContact` (phone, email, address) at the foot of the phone menu.
|
|
264
|
+
- **`footer`**: `cta`, a button under the line about you; `{year}` in
|
|
265
|
+
`copyright` is the current year.
|
|
266
|
+
|
|
226
267
|
- **`schedule`**: the week's sessions by time and day, with a host ("with …";
|
|
227
268
|
documents saved before version 2 keep an older key for it, which still
|
|
228
269
|
renders and moves into `host`), place, a note and a booking link per
|
|
@@ -297,6 +338,12 @@ props; `migrateNode` runs the steps on read and a publish writes the result
|
|
|
297
338
|
into the release. `sectionJsonSchema(type)` gives the props' JSON Schema (for
|
|
298
339
|
editor fields and AI output) and `sectionManifests()` the editor's catalog.
|
|
299
340
|
|
|
341
|
+
Mark a preset `sample: true` when its props are made-up content its owner must
|
|
342
|
+
replace (names, prices, times, quotes, an address, or copy that says what to
|
|
343
|
+
write). A section added from it, in the editor or with `nodeFromPreset`, is a
|
|
344
|
+
placeholder: the publish check holds it until it is edited or hidden, and the
|
|
345
|
+
editor shows its text as hints, so typing replaces the sample.
|
|
346
|
+
|
|
300
347
|
## Design systems
|
|
301
348
|
|
|
302
349
|
A brand is identity (name, colours, fonts, logo). A **design system** is the
|
|
@@ -377,9 +424,7 @@ for (const template of Object.values(industryTemplates)) {
|
|
|
377
424
|
}
|
|
378
425
|
```
|
|
379
426
|
|
|
380
|
-
|
|
381
|
-
`scripts/industry-words.mjs`) fails on industry words anywhere in this
|
|
382
|
-
package but `src/templates/`.
|
|
427
|
+
Keep industry words out of this package but `src/templates/`.
|
|
383
428
|
|
|
384
429
|
## Publish checks
|
|
385
430
|
|
|
@@ -396,7 +441,9 @@ to publish (`PublishBlockedError`, with `issues`) when:
|
|
|
396
441
|
pairs, which are solved to pass);
|
|
397
442
|
- an image has no alt text and isn't marked decorative;
|
|
398
443
|
- a section is unknown, has invalid props or was saved by newer code;
|
|
399
|
-
- a template placeholder is still
|
|
444
|
+
- a template placeholder, or a section added from a `sample` preset, is still
|
|
445
|
+
visible and unedited (on a landing page, the message says it can be deleted
|
|
446
|
+
to publish the rest of the site);
|
|
400
447
|
- a page path is malformed or reserved, or the site has no home page;
|
|
401
448
|
- on a site with `images: "own"`, an image, a file or the brand's logo loads
|
|
402
449
|
from a host other than the site and the store's asset origin.
|
|
@@ -410,17 +457,109 @@ host says how to fix it: upload it again, or copy the old site's files with
|
|
|
410
457
|
the same `{ images, assetOrigins }` as its third argument; the stores pass the
|
|
411
458
|
site's setting when they publish a post.
|
|
412
459
|
|
|
460
|
+
## Show dates
|
|
461
|
+
|
|
462
|
+
A page can be shown only between two times: `showFrom` and `showUntil` on its
|
|
463
|
+
root props (ISO times with an offset), set in the editor's Publish tab under
|
|
464
|
+
"Show dates" (in the editor's time zone). Before the start and from the end,
|
|
465
|
+
the published page is as if it weren't there: an unknown path (its 404 page
|
|
466
|
+
with `unknownPath: "not-found"`), and out of the sitemap. The editor's preview
|
|
467
|
+
always shows it. A sale's landing page that ends at midnight needs no publish
|
|
468
|
+
and no purge job: the page, its 404 answer, a prefix redirect over it and the
|
|
469
|
+
sitemap are cached no longer than the next boundary (`s-maxage` up to it, and
|
|
470
|
+
no `stale-while-revalidate`), so the CDN asks again then. That holds for what
|
|
471
|
+
the package answers: with the default `unknownPath: "fall-through"` a hidden
|
|
472
|
+
page returns `null`, and the host serves its own 404 and owns its cache, so
|
|
473
|
+
keep that 404 out of the shared cache (or use `"not-found"`) for the page to
|
|
474
|
+
appear on time. `handleSiteRequest`'s `now` sets the clock for
|
|
475
|
+
tests. A publish refuses an end before its start, and dates on the home page,
|
|
476
|
+
the 404 page or the blog's post page. `isPageShown`, `nextPageBoundary`,
|
|
477
|
+
`pageWindow` and `pageWindowProblems` are exported.
|
|
478
|
+
|
|
413
479
|
## SEO
|
|
414
480
|
|
|
415
481
|
Each page gets a title from the site's template (`%s · Riverside Works`), a
|
|
416
482
|
description, `robots`, a canonical URL from `origin`, and Open Graph and
|
|
417
483
|
Twitter tags. The home page carries `Organization` and `WebSite` JSON-LD, and
|
|
418
|
-
every page below it a `BreadcrumbList`. `
|
|
484
|
+
every page below it a `BreadcrumbList`. A site with `seo.localBusiness` (its
|
|
485
|
+
schema.org type, address, phone, email, founding date, geo and opening hours)
|
|
486
|
+
adds that business to the home page and the pages it lists in `pages` (a
|
|
487
|
+
contact page, say), with the organization's logo and links. A page with
|
|
488
|
+
visible `faq` sections carries one `FAQPage` of all their questions
|
|
489
|
+
(`localBusinessJsonLd`, `faqPageJsonLd`). The editor's Pages tab edits all of
|
|
490
|
+
this under Search and sharing; the share image is set per page in Publish. `sitemap.xml` lists the indexable
|
|
419
491
|
pages; `robots.txt` points at it, or disallows everything for a `noindex` site
|
|
420
492
|
and in preview. Moving a page (`store.movePage`) leaves a 301 from the old
|
|
421
493
|
path and rewrites older redirects to point at the new one, so there are no
|
|
422
494
|
chains.
|
|
423
495
|
|
|
496
|
+
Editors add their own redirects in the editor's Redirects section (Pages tab):
|
|
497
|
+
an old or short address, permanent (301) or temporary (302), to one of the
|
|
498
|
+
site's pages or landing pages, a place the host app publishes on the site's
|
|
499
|
+
address, or any other link. Pass those places as `SiteEditor`'s
|
|
500
|
+
`destinations` (`{ group: "Forms", label: "Feedback", path: "/f/feedback" }`).
|
|
501
|
+
The section refuses an address a page or another redirect has, the home page
|
|
502
|
+
and reserved paths, and a destination that redirects again; adding one points
|
|
503
|
+
earlier redirects to its address straight at its destination. The same rules
|
|
504
|
+
are exported for your own screens: `redirectFromProblems`,
|
|
505
|
+
`redirectToProblems`, `upsertRedirect`, `removeRedirect` and
|
|
506
|
+
`redirectDestinations`.
|
|
507
|
+
|
|
508
|
+
A redirect matches its old address only, or, with `match: "prefix"`, every
|
|
509
|
+
address under it too (`/people` takes `/people/ana`, never `/peoplex`): an
|
|
510
|
+
old section of a site, or tag and category archives. Pages and posts under it
|
|
511
|
+
still show, an exact redirect beats a prefix one, and the longest prefix wins.
|
|
512
|
+
With `keepRest: true` the rest of the address goes along
|
|
513
|
+
(`/blog/old/2019/post` → `/blog/2019/post`). A redirect to a site path keeps the
|
|
514
|
+
visitor's query string. `matchPrefixRedirect` and `isUnderPrefix` are exported;
|
|
515
|
+
a release refuses a prefix redirect from `/`, one into its own prefix (it would
|
|
516
|
+
redirect again), and `keepRest` on an exact one.
|
|
517
|
+
|
|
518
|
+
## Analytics
|
|
519
|
+
|
|
520
|
+
First-party and server-side: no third-party script on the page, nothing
|
|
521
|
+
stored on the visitor's device, and the Content-Security-Policy is unchanged.
|
|
522
|
+
Pass `analytics` to `handleSiteRequest` and every live page loads the islands
|
|
523
|
+
loader, which sends a small beacon to the site's own `/_gs/e`: a page view,
|
|
524
|
+
and clicks on links with `data-gs-event`, links off the site, and downloads.
|
|
525
|
+
`collect` gets each beacon with the request, but only from the site's own pages
|
|
526
|
+
(a beacon whose `Origin` or `Sec-Fetch-Site` names another site, or that has
|
|
527
|
+
neither, is answered 204 and dropped). A beacon's page address keeps only its
|
|
528
|
+
campaign tags (`utm_*`, `gclid`, `gbraid`, `wbraid`) from the query, in the page
|
|
529
|
+
and again in `beaconEvent`, so a prefilled email or a token never reaches a
|
|
530
|
+
provider. The request waits for `collect`: forward after the response, with
|
|
531
|
+
`waitUntil` or a queue, using `@marktiderman/genesis-sites/analytics`:
|
|
532
|
+
|
|
533
|
+
```ts
|
|
534
|
+
import { beaconEvent, forwardEvent, sendsGpc, visitorId } from "@marktiderman/genesis-sites/analytics";
|
|
535
|
+
|
|
536
|
+
handleSiteRequest(request, {
|
|
537
|
+
...options,
|
|
538
|
+
analytics: {
|
|
539
|
+
async collect(beacon, { request, siteId, origin }) {
|
|
540
|
+
const destinations = await destinationsFor(siteId); // { ga4?: { measurementId, apiSecret }, meta?: { pixelId, accessToken } }
|
|
541
|
+
if (!destinations) return;
|
|
542
|
+
const visitor = await visitorId({ salt: env.ANALYTICS_SALT, siteId, ip: clientIp(request), userAgent: request.headers.get("user-agent") ?? "" });
|
|
543
|
+
waitUntil(forwardEvent(beaconEvent(beacon, { origin, visitor, id: crypto.randomUUID(), gpc: sendsGpc(request) }), destinations));
|
|
544
|
+
},
|
|
545
|
+
},
|
|
546
|
+
});
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
Your server records the conversions where they happen (`lead`, `sign_up`,
|
|
550
|
+
`submit_form`, `schedule`, `start_trial`, `purchase`) as a `SiteEvent` and
|
|
551
|
+
forwards them the same way. GA4 gets them through the Measurement Protocol,
|
|
552
|
+
Meta through the Conversions API (`ga4Request` and `metaRequest` build the
|
|
553
|
+
requests, for a queue of your own).
|
|
554
|
+
|
|
555
|
+
Personal data: a visitor is a daily hash of a secret salt, the site, the day,
|
|
556
|
+
the IP address and the browser, so a day's visits count once and nothing
|
|
557
|
+
identifies the visitor. An event carries an email or phone (hashed), the IP
|
|
558
|
+
address or the browser only with `consent.personalData`, which your server
|
|
559
|
+
sets when the person agreed (a form's or an offer's consent tick); a beacon
|
|
560
|
+
never has it. Meta gets only events with consent, and nothing from a browser
|
|
561
|
+
that sends Global Privacy Control.
|
|
562
|
+
|
|
424
563
|
## Forms
|
|
425
564
|
|
|
426
565
|
A `form-embed` section names a form by slug. Your `forms` resolver says what
|
|
@@ -452,11 +591,42 @@ forms: (slug) =>
|
|
|
452
591
|
same fields as an ordinary form.
|
|
453
592
|
- A definition that needs the engine renders with forms-web's `<Form>`, and
|
|
454
593
|
the form bundle loads on that page only.
|
|
455
|
-
- `embed` shows an https URL in a sandboxed iframe.
|
|
594
|
+
- `embed` shows an https URL in a sandboxed iframe. An http URL on this
|
|
595
|
+
computer (`localhost`, `127.0.0.1`, `[::1]`, `*.localhost`) is framed too,
|
|
596
|
+
so a local stack's forms show while you build.
|
|
456
597
|
|
|
457
598
|
Either way, your endpoint checks the answers again (`validateSubmission` from
|
|
458
599
|
genesis-forms). An unknown slug renders nothing and logs.
|
|
459
600
|
|
|
601
|
+
In the editor, give `<SiteEditor>` a `listForms` service
|
|
602
|
+
(`() => Promise<{ slug, title }[]>`) and the form section's field becomes a
|
|
603
|
+
picker of your forms. Pass `listForms` (and `forms`) to `checkSite` and
|
|
604
|
+
`publishSite` too: a form section whose slug isn't on that list is flagged
|
|
605
|
+
(`form-missing`), so the check agrees with the picker. Without
|
|
606
|
+
`listForms`, the check asks the `forms` resolver, which must then return null
|
|
607
|
+
for a slug you don't have (a resolver that embeds any slug passes them all).
|
|
608
|
+
|
|
609
|
+
The Photo grid and Logo row start with sample pictures (`/_gs/sample/…`),
|
|
610
|
+
drawn inline in the editor and the preview. The check (`sample-image`) names
|
|
611
|
+
the section and the picture to replace.
|
|
612
|
+
|
|
613
|
+
### Checks the app chooses
|
|
614
|
+
|
|
615
|
+
Those two checks are yours to set, on `<SiteEditor checks>`, `checkSite` and
|
|
616
|
+
`publishSite`. Each one blocks the publish, warns in the Publish panel, or is
|
|
617
|
+
off; left out, it warns. A store's `publish` and `checkRelease` take
|
|
618
|
+
`sampleImages` only: the forms check needs your forms, so it runs in
|
|
619
|
+
`checkSite`.
|
|
620
|
+
|
|
621
|
+
```tsx
|
|
622
|
+
<SiteEditor checks={{ sampleImages: "block", missingForms: "warn" }} … />
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
| Key | Issue | Flags |
|
|
626
|
+
| --- | --- | --- |
|
|
627
|
+
| `sampleImages` | `sample-image` | a section still showing a starter sample picture |
|
|
628
|
+
| `missingForms` | `form-missing` | a form section naming no form you have (off: the host isn't asked) |
|
|
629
|
+
|
|
460
630
|
## The blog
|
|
461
631
|
|
|
462
632
|
A site's posts live beside its pages, each with a draft and a published
|
|
@@ -485,7 +655,11 @@ published post, `/rss.xml` is the feed, and every page links to it.
|
|
|
485
655
|
Moving a blog in: `importPosts(siteId, posts)` takes up to 500 posts once,
|
|
486
656
|
each with its slug and its old `publishedAt`. A slug the site already has is
|
|
487
657
|
skipped, and a post that fails a check comes in as a draft with its
|
|
488
|
-
`issues`, so nothing goes live unchecked.
|
|
658
|
+
`issues`, so nothing goes live unchecked. A date must be a real one from
|
|
659
|
+
1970 on, and a later one than now becomes now. A post imported as a draft
|
|
660
|
+
keeps its date (`imported_published_at`, migration
|
|
661
|
+
`0003_genesis_sites_post_dates.sql`) and goes live under it when first
|
|
662
|
+
published. Re-host its pictures first (see
|
|
489
663
|
Importing a site) and run `rewriteUrls` over each document.
|
|
490
664
|
|
|
491
665
|
Anon reads posts only through `genesis_sites.live_posts(site_id)` (the
|
|
@@ -595,7 +769,16 @@ import { SiteEditor } from "@marktiderman/genesis-sites/editor";
|
|
|
595
769
|
</div>;
|
|
596
770
|
```
|
|
597
771
|
|
|
598
|
-
`SiteEditor` fills its parent, so give the parent a height.
|
|
772
|
+
`SiteEditor` fills its parent, so give the parent a height. On Vite, an app
|
|
773
|
+
that leaves genesis-sites out of `optimizeDeps` (to keep its generated assets
|
|
774
|
+
out of the pre-bundle) must pre-bundle its CommonJS dependencies itself, or
|
|
775
|
+
the editor's preview fails in dev ("no export named renderToReadableStream"):
|
|
776
|
+
|
|
777
|
+
```ts
|
|
778
|
+
optimizeDeps: { exclude: ["@marktiderman/genesis-sites"], include: ["@puckeditor/core", "react-dom/server"] },
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
Props:
|
|
599
782
|
|
|
600
783
|
| Prop | |
|
|
601
784
|
|---|---|
|
package/SKILL.md
CHANGED
|
@@ -46,5 +46,20 @@ Then, as `genesis add` prints:
|
|
|
46
46
|
(`landing.directory`, `/go` by default), made in the editor's Landing pages section or with
|
|
47
47
|
`createLandingPage`; it is a page like any other, edited and published in the same editor and
|
|
48
48
|
release, never a second builder.
|
|
49
|
+
- A site's 404 page is its page at `/404` (`NOT_FOUND_PATH`), made in the editor's Page not found
|
|
50
|
+
section and edited with the site's sections. With `unknownPath: "not-found"`, an unknown path
|
|
51
|
+
shows it with status 404 and `noindex`; a site without one shows the built-in text. A host that
|
|
52
|
+
answers a miss in its own reserved paths can serve it too: `handleSiteRequest` on `/404`.
|
|
53
|
+
- A redirect is added in the editor's Redirects section, not by writing `site.redirects`: its
|
|
54
|
+
picker lists the site's pages and landing pages and what the host passes as `SiteEditor`'s
|
|
55
|
+
`destinations` (forms, offers, anything the app serves on the site's address), with no chains.
|
|
56
|
+
- An old section of a site (legacy `/people/*`, `/tag/*`) is one redirect with "This address and
|
|
57
|
+
everything under it" (`match: "prefix"`, optionally `keepRest`), not one per old page; pages
|
|
58
|
+
under it still show. There are no pattern redirects: list stray old addresses one by one.
|
|
59
|
+
|
|
60
|
+
- A page that must disappear (or appear) at a set time gets Show dates in its Publish tab
|
|
61
|
+
(`showFrom`/`showUntil`); never a scheduled publish. With `unknownPath: "not-found"` its cache ends
|
|
62
|
+
at the boundary and no purge job is needed; with the default `"fall-through"` the host serves and
|
|
63
|
+
caches its own 404, so keep that 404 out of the shared cache.
|
|
49
64
|
|
|
50
65
|
Details: the package README and [docs/SITES.md](https://github.com/marktiderman/genesis/blob/main/docs/SITES.md).
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* First-party, server-side analytics for a site: the page sends a small
|
|
5
|
+
* beacon to its own address (`/_gs/e`), and the host forwards events (those
|
|
6
|
+
* beacons, and the conversions its own server code records) to Google
|
|
7
|
+
* Analytics 4 through the Measurement Protocol and to Meta through the
|
|
8
|
+
* Conversions API. No third-party script runs on the page, nothing is stored
|
|
9
|
+
* on the visitor's device, and the Content-Security-Policy doesn't change.
|
|
10
|
+
*
|
|
11
|
+
* Personal data:
|
|
12
|
+
* - A visitor is a daily hash of their IP address and browser with a secret
|
|
13
|
+
* salt (`visitorId`), so a day's visits count once and nothing identifies
|
|
14
|
+
* them; the hash changes every day.
|
|
15
|
+
* - Events carry personal data (an email or phone, hashed; the IP address;
|
|
16
|
+
* the browser) only when the person agreed to it (`consent.personalData`),
|
|
17
|
+
* such as by ticking a form's or an offer's consent. Meta gets only events
|
|
18
|
+
* with consent: without it, it gets nothing.
|
|
19
|
+
* - A browser that sends Global Privacy Control (`Sec-GPC: 1`) is never sent
|
|
20
|
+
* to Meta, whatever the consent.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** The page's events, sent by the islands loader. */
|
|
24
|
+
declare const BEACON_EVENTS: readonly ["page_view", "click", "outbound", "download"];
|
|
25
|
+
/** The events the host's server records where they happen. */
|
|
26
|
+
declare const CONVERSION_EVENTS: readonly ["lead", "sign_up", "submit_form", "schedule", "start_trial", "purchase"];
|
|
27
|
+
type BeaconEventName = (typeof BEACON_EVENTS)[number];
|
|
28
|
+
type ConversionEventName = (typeof CONVERSION_EVENTS)[number];
|
|
29
|
+
type SiteEventName = BeaconEventName | ConversionEventName;
|
|
30
|
+
/** The path a site page sends its beacon to, under the site's base path. */
|
|
31
|
+
declare const BEACON_PATH = "/_gs/e";
|
|
32
|
+
/** The most a beacon's body may be. */
|
|
33
|
+
declare const BEACON_MAX_BYTES = 2048;
|
|
34
|
+
/** What the islands loader sends: short keys, no personal data. */
|
|
35
|
+
declare const SiteBeacon: z.ZodObject<{
|
|
36
|
+
n: z.ZodEnum<{
|
|
37
|
+
page_view: "page_view";
|
|
38
|
+
click: "click";
|
|
39
|
+
outbound: "outbound";
|
|
40
|
+
download: "download";
|
|
41
|
+
}>;
|
|
42
|
+
p: z.ZodString;
|
|
43
|
+
r: z.ZodOptional<z.ZodString>;
|
|
44
|
+
e: z.ZodOptional<z.ZodString>;
|
|
45
|
+
h: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
type SiteBeacon = z.infer<typeof SiteBeacon>;
|
|
48
|
+
interface SiteEventUser {
|
|
49
|
+
email?: string | undefined;
|
|
50
|
+
phone?: string | undefined;
|
|
51
|
+
firstName?: string | undefined;
|
|
52
|
+
lastName?: string | undefined;
|
|
53
|
+
/** The host's own id for the person (hashed before it leaves). */
|
|
54
|
+
externalId?: string | undefined;
|
|
55
|
+
}
|
|
56
|
+
/** One event to forward. */
|
|
57
|
+
interface SiteEvent {
|
|
58
|
+
name: SiteEventName;
|
|
59
|
+
/** When it happened (default now). */
|
|
60
|
+
at?: Date | undefined;
|
|
61
|
+
/** An id unique to this event, so a destination counts a retried send once. */
|
|
62
|
+
id: string;
|
|
63
|
+
/** The page's full address. */
|
|
64
|
+
url: string;
|
|
65
|
+
referrer?: string | undefined;
|
|
66
|
+
/** From `visitorId`. */
|
|
67
|
+
visitor: string;
|
|
68
|
+
/** The click's event name, or the link's address (outbound, download). */
|
|
69
|
+
label?: string | undefined;
|
|
70
|
+
href?: string | undefined;
|
|
71
|
+
/** A purchase's (or a booking's) value. */
|
|
72
|
+
value?: number | undefined;
|
|
73
|
+
currency?: string | undefined;
|
|
74
|
+
/** A purchase's order id, or what was booked or claimed. */
|
|
75
|
+
transactionId?: string | undefined;
|
|
76
|
+
item?: string | undefined;
|
|
77
|
+
/** Rough place, from the host's edge (country and region codes, city). */
|
|
78
|
+
location?: {
|
|
79
|
+
country?: string | undefined;
|
|
80
|
+
region?: string | undefined;
|
|
81
|
+
city?: string | undefined;
|
|
82
|
+
} | undefined;
|
|
83
|
+
/** Whether the person agreed to personal data in this event, and whether the browser asked not to be tracked. */
|
|
84
|
+
consent: {
|
|
85
|
+
personalData: boolean;
|
|
86
|
+
gpc?: boolean | undefined;
|
|
87
|
+
};
|
|
88
|
+
/** Sent only with `consent.personalData`. */
|
|
89
|
+
user?: SiteEventUser | undefined;
|
|
90
|
+
ip?: string | undefined;
|
|
91
|
+
userAgent?: string | undefined;
|
|
92
|
+
}
|
|
93
|
+
/** A site's destinations: either, both or neither. */
|
|
94
|
+
interface AnalyticsDestinations {
|
|
95
|
+
ga4?: {
|
|
96
|
+
measurementId: string;
|
|
97
|
+
apiSecret: string;
|
|
98
|
+
} | null | undefined;
|
|
99
|
+
meta?: {
|
|
100
|
+
pixelId: string;
|
|
101
|
+
accessToken: string;
|
|
102
|
+
testEventCode?: string | undefined;
|
|
103
|
+
} | null | undefined;
|
|
104
|
+
}
|
|
105
|
+
declare const GA4_MEASUREMENT_ID: RegExp;
|
|
106
|
+
declare const META_PIXEL_ID: RegExp;
|
|
107
|
+
/**
|
|
108
|
+
* The visitor's id for a day: a hash of the salt, the site, the day, the IP
|
|
109
|
+
* address and the browser. The salt is the host's secret; a new day gives a
|
|
110
|
+
* new id, so visitors can't be followed across days.
|
|
111
|
+
*/
|
|
112
|
+
declare function visitorId(input: {
|
|
113
|
+
salt: string;
|
|
114
|
+
siteId: string;
|
|
115
|
+
ip: string;
|
|
116
|
+
userAgent: string;
|
|
117
|
+
at?: Date;
|
|
118
|
+
}): Promise<string>;
|
|
119
|
+
/** The normalised, hashed email (lowercase, trimmed), as Meta takes it. */
|
|
120
|
+
declare function hashEmail(email: string): Promise<string | undefined>;
|
|
121
|
+
/** The normalised, hashed phone: digits only, with the country code, as Meta takes it. */
|
|
122
|
+
declare function hashPhone(phone: string): Promise<string | undefined>;
|
|
123
|
+
/** A request to the destination, for `fetch`. */
|
|
124
|
+
interface DestinationRequest {
|
|
125
|
+
destination: "ga4" | "meta";
|
|
126
|
+
url: string;
|
|
127
|
+
init: {
|
|
128
|
+
method: "POST";
|
|
129
|
+
headers: Record<string, string>;
|
|
130
|
+
body: string;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/** The Measurement Protocol request for an event. */
|
|
134
|
+
declare function ga4Request(event: SiteEvent, ga4: NonNullable<AnalyticsDestinations["ga4"]>): Promise<DestinationRequest>;
|
|
135
|
+
/** The Conversions API request for an event, or null when Meta mustn't have it. */
|
|
136
|
+
declare function metaRequest(event: SiteEvent, meta: NonNullable<AnalyticsDestinations["meta"]>, graphVersion?: string): Promise<DestinationRequest | null>;
|
|
137
|
+
interface ForwardResult {
|
|
138
|
+
destination: "ga4" | "meta";
|
|
139
|
+
ok: boolean;
|
|
140
|
+
status?: number;
|
|
141
|
+
error?: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Sends an event to the site's destinations, both at once, with a time limit.
|
|
145
|
+
* Never throws: a destination that fails is reported, not retried.
|
|
146
|
+
*/
|
|
147
|
+
declare function forwardEvent(event: SiteEvent, destinations: AnalyticsDestinations, options?: {
|
|
148
|
+
fetch?: typeof fetch;
|
|
149
|
+
timeoutMs?: number;
|
|
150
|
+
}): Promise<ForwardResult[]>;
|
|
151
|
+
/** Whether the browser sent Global Privacy Control. */
|
|
152
|
+
declare const sendsGpc: (request: Request) => boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Reads a beacon's body: the event, or null when it isn't one (over
|
|
155
|
+
* `BEACON_MAX_BYTES` bytes, not JSON, unknown fields' values out of range).
|
|
156
|
+
* The page sends it as text/plain, which needs no preflight. The page's path
|
|
157
|
+
* comes as sent, query included: `beaconEvent` keeps only its campaign tags.
|
|
158
|
+
*/
|
|
159
|
+
declare function readBeacon(request: Request): Promise<SiteBeacon | null>;
|
|
160
|
+
/** The query keys a page address keeps for analytics: campaign tags and ad click ids, nothing else. */
|
|
161
|
+
declare const CAMPAIGN_QUERY_KEY: RegExp;
|
|
162
|
+
/**
|
|
163
|
+
* A page path with only its campaign query (utm_*, gclid, gbraid, wbraid):
|
|
164
|
+
* a query can carry a prefilled email or a token, which must not reach an
|
|
165
|
+
* analytics provider. The fragment goes too.
|
|
166
|
+
*/
|
|
167
|
+
declare function campaignPath(path: string): string;
|
|
168
|
+
/**
|
|
169
|
+
* An event from a page's beacon: the page address on the site's origin (the
|
|
170
|
+
* beacon's path already starts with the site's base path, as the browser
|
|
171
|
+
* shows it), with only its campaign query; the referrer and the link's
|
|
172
|
+
* address without their query or fragment; the visitor's daily id; and no
|
|
173
|
+
* personal data (a beacon never has consent).
|
|
174
|
+
*/
|
|
175
|
+
declare function beaconEvent(beacon: SiteBeacon, input: {
|
|
176
|
+
origin: string;
|
|
177
|
+
visitor: string;
|
|
178
|
+
id: string;
|
|
179
|
+
at?: Date;
|
|
180
|
+
location?: SiteEvent["location"];
|
|
181
|
+
gpc?: boolean;
|
|
182
|
+
}): SiteEvent;
|
|
183
|
+
|
|
184
|
+
export { type AnalyticsDestinations, BEACON_EVENTS, BEACON_MAX_BYTES, BEACON_PATH, type BeaconEventName, CAMPAIGN_QUERY_KEY, CONVERSION_EVENTS, type ConversionEventName, type DestinationRequest, type ForwardResult, GA4_MEASUREMENT_ID, META_PIXEL_ID, SiteBeacon, type SiteEvent, type SiteEventName, type SiteEventUser, beaconEvent, campaignPath, forwardEvent, ga4Request, hashEmail, hashPhone, metaRequest, readBeacon, sendsGpc, visitorId };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { BEACON_EVENTS, BEACON_MAX_BYTES, BEACON_PATH, CAMPAIGN_QUERY_KEY, CONVERSION_EVENTS, GA4_MEASUREMENT_ID, META_PIXEL_ID, SiteBeacon, beaconEvent, campaignPath, forwardEvent, ga4Request, hashEmail, hashPhone, metaRequest, readBeacon, sendsGpc, visitorId } from './chunk-5RYCQEEE.js';
|
|
2
|
+
//# sourceMappingURL=analytics.js.map
|
|
3
|
+
//# sourceMappingURL=analytics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"analytics.js"}
|