create-bearminion 1.7.0 → 1.9.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # create-bearminion
2
2
 
3
+ ## 1.9.3
4
+
5
+ ### Patch Changes
6
+
7
+ - e94dcc1: Fix the release of `create-bearminion`, which was never published after 1.8.0: publishing both packages rebuilt them at the same time, and bearminion's build emptied the files create-bearminion's build was reading. The release now builds each package once, in order.
8
+
9
+ ## 1.9.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 9c0466c: `npx bearminion add form resend --host netlify` and `--host cloudflare` write the Netlify Function (`netlify/functions/contact.mts`) and a Cloudflare Worker (`worker.ts`, plus a `wrangler.jsonc` when the site has no Wrangler config) next to the handler. A real message has gone through Resend on Vercel, Netlify and Cloudflare. A failed handler now logs its message as text, which Cloudflare's logs had dropped. `.env.example` no longer spells out Cloudflare's test keys, which made Netlify's secrets scan fail a build that used them, and the Forms guide says how to keep the public site key out of that scan.
14
+ - 6fb095f: The Contact form's Turnstile check turns on by itself when `TURNSTILE_SECRET_KEY` is in the environment, so the widget on the page can no longer sit in front of a server that checks nothing. `turnstile: true` still requires it and `turnstile: false` turns it off. A genuine token is also refused when Cloudflare says the widget was served on a host other than the one the function runs on; `turnstile: { hostnames }` lists others. The visitor address sent to Turnstile now comes from the host's own header, or the last `x-forwarded-for` entry, not the first, which the visitor can set. A site that had the secret key set and no option now checks tokens: if its page has no site key, the form refuses every message until the site key is set.
15
+
16
+ ## 1.9.1
17
+
18
+ ### Patch Changes
19
+
20
+ - dd5c397: The Vercel function that `npx bearminion add form resend --host vercel` writes now imports the handler as `../src/forms/contact.js`. Vercel runs the function as an ES module, which does not guess file extensions, so the extensionless import failed with `ERR_MODULE_NOT_FOUND`. A site that already has the old `api/contact.ts` needs the same one-word change, or `npx bearminion add form resend --host vercel --overwrite`.
21
+
22
+ ## 1.9.0
23
+
24
+ ### Minor Changes
25
+
26
+ - d1c211b: `npx bearminion add <section...>` copies a section into an existing site, with the atoms, molecules and helpers it imports, and lists it in the generated section files. It writes a file only when the site has none, or has an earlier release's copy that nobody changed; a file you changed stops it, and nothing is written unless you pass `--overwrite`. `--list`, `--dry-run`, `--yes`, `--diff`, `--install` and `--json` are there for people and for scripts. New sites start with a `bearminion.lock.json`, and `add` keeps it up to date. The files come from a registry that ships inside the package, so nothing is downloaded. See [The command line](https://github.com/langehelp-software/bearminion/blob/main/docs/cli.md).
27
+ - 7819b98: `npx bearminion add form resend --host vercel` writes the Contact form's handler to `src/forms/contact.ts` and the Vercel function that runs it. It is the first form recipe sent through a real service; Formspree, Web3Forms, Postmark, Slack and the Netlify, Cloudflare and Astro glue stay in the Forms guide as files to copy until each has been tried. The handler is written with example `FROM` and `TO` addresses and refuses to send until you change them. The command never replaces a handler you wrote unless you pass `--overwrite`, and it notes the files in `bearminion.lock.json`. `BEARMINION_FORMS=required` in the host's build environment makes `astro build` fail while a Contact form has no handler. See [The command line](https://github.com/langehelp-software/bearminion/blob/main/docs/cli.md#add-a-form-handler).
28
+ - 7819b98: A detail in the Contact section has a **Hide from crawlers** switch. Switched on, the built page carries the email address or phone number scrambled and a few lines of script show it when the page loads, so crawlers that only read the HTML find nothing to collect. It is off by default and changes nothing for existing sites. The editor can now show an optional on/off switch on a list item that does not have it yet. The form recipe for Resend reads the sender and receiver from `CONTACT_FROM` and `CONTACT_TO`, so no address is written into the repository.
29
+
30
+ ### Patch Changes
31
+
32
+ - 75bf724: A text field you edit in the sidebar now shows on the page before you save. It used to update only when the same text was typed on the page itself, so a change to, say, a Contact detail or an eyebrow stayed invisible until you saved and reloaded.
33
+
34
+ ## 1.8.0
35
+
36
+ ### Minor Changes
37
+
38
+ - 305d094: A section type is now a directory, and nothing else has to be edited. `npx bearminion sync` (new command) writes `definitions.gen.ts` and `components.gen.ts` from the directories under `sections/`; the starter's hand-written `registry.ts` and the `case` per section in `SectionList.astro` are gone. The new `sectionsDir` option makes `astro build`, `astro check` and `astro sync` stop when the generated files are stale, and `astro dev` warn. `npx bearminion sync --check` is the same test for CI.
39
+
40
+ Sites created before this release keep working as they are. To move one over, copy `definitions.ts`, `SectionList.astro` and `astro.config.ts` from a new site, delete `registry.ts`, run `npx bearminion sync`, and read [Add a section type](https://github.com/langehelp-software/bearminion/blob/main/templates/default/README.md#add-a-section-type).
41
+
3
42
  ## 1.7.0
4
43
 
5
44
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bearminion",
3
- "version": "1.7.0",
3
+ "version": "1.9.3",
4
4
  "description": "Create a BearMinion site: an Astro website you edit by clicking on it. No database, no server.",
5
5
  "license": "MIT",
6
6
  "author": "Jakub Lange",
@@ -4,13 +4,22 @@
4
4
 
5
5
  # --- Cloudflare Turnstile, the spam check for the Contact form -------------------------------------------------------
6
6
  # The site key is public. Astro reads it when the site is built, so set it where the site is built and rebuild after a change.
7
- # The secret key stays on the server. Set both, or neither.
8
- # To try it, Cloudflare publishes keys that always pass: site key 1x00000000000000000000AA, secret key 1x0000000000000000000000000000000AA
7
+ # The secret key stays on the server, and setting it is what turns the check on. Set both, or neither.
8
+ # To try it, Cloudflare publishes keys that always pass; they are in the Forms guide (Turnstile, Testing).
9
9
  # PUBLIC_TURNSTILE_SITE_KEY=
10
10
  # TURNSTILE_SECRET_KEY=
11
11
 
12
12
  # --- Your form handler, src/forms/contact.ts ------------------------------------------------------------------------
13
13
  # Whatever the handler reads from `env` (a service key, a webhook URL): add the names you use, and set the same names in your host's settings.
14
+ # `npx bearminion add form resend` writes a handler that reads these three:
15
+ # RESEND_API_KEY=
16
+ # CONTACT_FROM=Website <contact@your-domain.example>
17
+ # CONTACT_TO=you@your-domain.example
18
+
19
+ # --- Production builds -----------------------------------------------------------------------------------------------
20
+ # Set this in your host's build environment (not here): the build fails while a Contact form has no src/forms/contact.ts,
21
+ # instead of only warning. It cannot check that the host has the glue file or the secrets.
22
+ # BEARMINION_FORMS=required
14
23
 
15
24
  # --- astro dev -------------------------------------------------------------------------------------------------------
16
25
  # While `astro dev` runs, /api/contact only prints the message (a dry run). Turn this on to run your handler for real.
@@ -38,7 +38,7 @@ src/components/
38
38
  atoms/ Typography, Button, Image, LogoMark, Emphasis
39
39
  molecules/ SectionShell, SectionHeader, MediaFrame, Pill, CommandLine
40
40
  organisms/ Header, Navigation, MobileMenu, Footer, plus site-definition.ts (header and footer layouts, limits)
41
- sections/ one directory per type, plus definitions.ts, registry.ts, shared.ts, SectionList.astro
41
+ sections/ one directory per type, plus definitions.ts, shared.ts, SectionList.astro and the generated definitions.gen.ts, components.gen.ts
42
42
  hero/ definition.ts (zod schema, defaults, options), wireframe.ts (picker thumbnail), Hero.astro, Hero.stories.ts
43
43
  logo-strip/ steps/ gallery/ features/ text/ text-image/ stats/ testimonials/ pricing/ media/ faq/ cta/ contact/
44
44
  seo/ Seo
@@ -48,7 +48,7 @@ src/components/
48
48
 
49
49
  ## Add a section type
50
50
 
51
- A section type is one directory under `src/components/sections/` plus three one-line registrations. This walks through a `quote` section: a pull quote with an attribution.
51
+ A section type is one directory under `src/components/sections/` and one command, `npx bearminion sync`. This walks through a `quote` section: a pull quote with an attribution.
52
52
 
53
53
  **1. The definition** (`quote/definition.ts`). The Zod schema validates the JSON and drives the editor's Content fields; `defaults` is what a new section starts with and must pass the schema.
54
54
 
@@ -120,15 +120,21 @@ const field = (path: string) => `sections.${index}.props.${path}`
120
120
  </SectionShell>
121
121
  ```
122
122
 
123
- **4. Register it** in three places:
123
+ **4. Register it** with one command:
124
124
 
125
- - `sections/definitions.ts`: add `quote` to `sectionDefinitions`. This is the schema side, loaded by `astro.config.ts` and the editor, so it must not import `.astro` files.
126
- - `sections/registry.ts`: add `quote: Quote`. The `satisfies Record<SectionType, unknown>` check fails until you do.
127
- - `sections/SectionList.astro`: add a `case 'quote'` that renders `<Quote section={section} index={index} motion={motion} />`. The switch is what gives each component its exact section type.
125
+ ```sh
126
+ npx bearminion sync
127
+ ```
128
+
129
+ It lists every directory under `sections/` that holds a `definition.ts` in two generated files, `definitions.gen.ts` (the schemas, with no `.astro` imports, so `astro.config.ts` and the editor can load them) and `components.gen.ts` (type → component). The names follow the directory: `quote/` exports `quote` from `definition.ts` and `Quote` from `Quote.astro`, and `logo-strip/` becomes `logoStrip` and `LogoStrip`. `SectionList.astro` renders whatever the map holds, so it needs no edit. Do not edit the generated files; commit them. `astro build`, `astro check` and `astro sync` stop with a reminder when they are stale, and `astro dev` warns. `npx bearminion sync --check` is the same test for CI.
130
+
131
+ The Add section menu lists the types in the order of `order` in `sections/definitions.ts`; a type that is not listed there (yours) comes last, by name.
128
132
 
129
133
  Restart `npm run dev`. The section appears in the Add section picker, its fields in the sidebar, and `npm run typecheck` checks the component against the schema. Add a `Quote.stories.ts` next to it if you use Storybook.
130
134
 
131
- Removing a section type later is safe: pages that still hold it open in the editor with an "Unknown" section you can delete, and `astro build` fails until they are cleaned up.
135
+ A section from a newer release comes into an existing site with `npx bearminion add <name>`; see [The command line](../../docs/cli.md).
136
+
137
+ Removing a section type later means deleting its directory and running `npx bearminion sync`. It is safe: pages that still hold it open in the editor with an "Unknown" section you can delete, and `astro build` fails until they are cleaned up.
132
138
 
133
139
  ## Atoms
134
140
 
@@ -7,7 +7,7 @@ import type { AstroIntegration } from 'astro'
7
7
  import { defineConfig } from 'astro/config'
8
8
  import { contentDirectory } from './src/lib/content-dir'
9
9
  import { contentModel } from './src/lib/content-model'
10
- import { hasFormHandler, unhandledFormMessage, unhandledForms } from './src/lib/form-check'
10
+ import { formsRequired, hasFormHandler, requiredFormsError, unhandledFormMessage, unhandledForms } from './src/lib/form-check'
11
11
  import { createSitemapFilter } from './src/lib/sitemap'
12
12
 
13
13
  const contentDir = contentDirectory()
@@ -31,7 +31,10 @@ const formsDir = process.env.BEARMINION_FORMS_DIR
31
31
  ? path.resolve(process.env.BEARMINION_FORMS_DIR)
32
32
  : fileURLToPath(new URL('./src/forms', import.meta.url))
33
33
 
34
- /** A form without a handler is a warning, not an error: a new site must still start and build. */
34
+ /**
35
+ * A form without a handler is a warning, not an error: a new site must still start and build. `BEARMINION_FORMS=required`
36
+ * (set in the host's build environment) turns the warning into a failed build.
37
+ */
35
38
  const formCheck: AstroIntegration = {
36
39
  name: 'bearminion-site:form-check',
37
40
  hooks: {
@@ -39,7 +42,10 @@ const formCheck: AstroIntegration = {
39
42
  for (const form of unhandledForms(content.pages, hasFormHandler(formsDir))) logger.warn(unhandledFormMessage(form))
40
43
  },
41
44
  'astro:build:start': ({ logger }) => {
42
- for (const form of unhandledForms(content.pages, hasFormHandler(formsDir))) logger.warn(unhandledFormMessage(form))
45
+ const forms = unhandledForms(content.pages, hasFormHandler(formsDir))
46
+ const failure = formsRequired(process.env.BEARMINION_FORMS) ? requiredFormsError(forms) : undefined
47
+ if (failure) throw failure
48
+ for (const form of forms) logger.warn(unhandledFormMessage(form))
43
49
  },
44
50
  },
45
51
  }
@@ -50,6 +56,8 @@ export default defineConfig({
50
56
  bearminion({
51
57
  contentDir,
52
58
  ...contentModel,
59
+ // `astro build` stops when the files `bearminion sync` writes no longer match the section directories.
60
+ sectionsDir: 'src/components/sections',
53
61
  git: process.env.BEARMINION_GIT === 'true',
54
62
  uploadsDir: process.env.BEARMINION_UPLOADS_DIR
55
63
  ? path.resolve(process.env.BEARMINION_UPLOADS_DIR)
@@ -0,0 +1,278 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "template": "default",
4
+ "files": {
5
+ "src/components/atoms/Button.astro": {
6
+ "version": "1.9.3",
7
+ "hash": "7be42b3dc3a3b59bec169de32a9d801904689e2705473d1945724658dc799043"
8
+ },
9
+ "src/components/atoms/Emphasis.astro": {
10
+ "version": "1.9.3",
11
+ "hash": "a62835636e2df3a02acf51c1610ba309e1085b7165576ecfbb570a2241aab6b0"
12
+ },
13
+ "src/components/atoms/Image.astro": {
14
+ "version": "1.9.3",
15
+ "hash": "015e7e24d250e4bec58e1699eaf115dc1a92a713bdc317cc1a3f31fae163f09d"
16
+ },
17
+ "src/components/atoms/Typography.astro": {
18
+ "version": "1.9.3",
19
+ "hash": "56e7ea3cf08ef4159d6b72c97761d13334b5468476e0226d62b42effd1368fd2"
20
+ },
21
+ "src/components/atoms/button.ts": {
22
+ "version": "1.9.3",
23
+ "hash": "dfa3955ebb4416ecb1aea899f41b2d2abc26d163790615fbc8113a998a6cd6e6"
24
+ },
25
+ "src/components/atoms/image.ts": {
26
+ "version": "1.9.3",
27
+ "hash": "63361cdb18f0fb89af00cc089b6afd33164aee315decbe41c55a448e09050e42"
28
+ },
29
+ "src/components/atoms/options.ts": {
30
+ "version": "1.9.3",
31
+ "hash": "5fd517f2abfb3e650f740d37e68439807a7da4056aa57458dad60e322b6f5b62"
32
+ },
33
+ "src/components/atoms/typography.ts": {
34
+ "version": "1.9.3",
35
+ "hash": "a4310d2e1ffae64d245c3d8b3fce2d220f19c598bb38f70ed1bd17c0262840c6"
36
+ },
37
+ "src/components/molecules/CommandLine.astro": {
38
+ "version": "1.9.3",
39
+ "hash": "af11f7f28617129636ee1d0097c21427bdb7bfaa7d8ee2750faaa8bedcb67b06"
40
+ },
41
+ "src/components/molecules/MediaFrame.astro": {
42
+ "version": "1.9.3",
43
+ "hash": "f57a20d18beacb9f28acd9efe9eeb3487c594735239f47c7bb4311f1a4140886"
44
+ },
45
+ "src/components/molecules/Pill.astro": {
46
+ "version": "1.9.3",
47
+ "hash": "b7b32e8de70084159003552f61dbccaf8aa13d338f231183ca9443efa72c7644"
48
+ },
49
+ "src/components/molecules/SectionHeader.astro": {
50
+ "version": "1.9.3",
51
+ "hash": "b2692e02875362cc9dac3dc7a6c80bd056bf8d2af2973da1eb62d9d268d6b9ba"
52
+ },
53
+ "src/components/molecules/SectionShell.astro": {
54
+ "version": "1.9.3",
55
+ "hash": "dc57fc01c666f1fef4b1b9799c2c0728571ac123af1567df3cb6f1e6456d2843"
56
+ },
57
+ "src/components/sections/contact/Contact.astro": {
58
+ "version": "1.9.3",
59
+ "hash": "4247463ccd5cdde93ab263f12908ca2a87e5e6c2b51b6e6025f712c919b7ece1"
60
+ },
61
+ "src/components/sections/contact/definition.ts": {
62
+ "version": "1.9.3",
63
+ "hash": "9ce73d48688466dcbbb6a0943dcc88190d2be05c2aad8b60c8c2a189e78dad28"
64
+ },
65
+ "src/components/sections/contact/form.ts": {
66
+ "version": "1.9.3",
67
+ "hash": "18b1f2e2527525a74313ec5e9903e2033b9e5ccae955e5778efd6af10e5b58dd"
68
+ },
69
+ "src/components/sections/contact/wireframe.ts": {
70
+ "version": "1.9.3",
71
+ "hash": "91bbbf164a0c0eea2f526bf84fef2ba2ab02b298354049df6fbc73f171a1ce8f"
72
+ },
73
+ "src/components/sections/cta/Cta.astro": {
74
+ "version": "1.9.3",
75
+ "hash": "0ae98e77b6d645b71f58dbf790908333be59dd16c3c558e924021ce2bcb0d2dc"
76
+ },
77
+ "src/components/sections/cta/definition.ts": {
78
+ "version": "1.9.3",
79
+ "hash": "d6576c8a53ac59dae964644765d690f2938e589fc13b24c0a0993ead5ba62285"
80
+ },
81
+ "src/components/sections/cta/wireframe.ts": {
82
+ "version": "1.9.3",
83
+ "hash": "5c4e998a2a30a4185776d5112c0dcf09130002f3a04d4f31752bb1346ae7fc3f"
84
+ },
85
+ "src/components/sections/faq/Faq.astro": {
86
+ "version": "1.9.3",
87
+ "hash": "59843ad44db35cbe21acfc17c92b7455dcd0b293d5c4a91c5ce23daa70904039"
88
+ },
89
+ "src/components/sections/faq/definition.ts": {
90
+ "version": "1.9.3",
91
+ "hash": "b24bdd9077c471379130d611ecdcda487d88b1108ab22dba0a6307839243eac8"
92
+ },
93
+ "src/components/sections/faq/wireframe.ts": {
94
+ "version": "1.9.3",
95
+ "hash": "d3865d0b0d6fecf92eef5c9959cf495253527f7e73592726c42fa87fc2e21d38"
96
+ },
97
+ "src/components/sections/features/Features.astro": {
98
+ "version": "1.9.3",
99
+ "hash": "fa2d4de7ada18b6fc9159c99db54aa9c09d8209b421db574251cec695e7abf9d"
100
+ },
101
+ "src/components/sections/features/definition.ts": {
102
+ "version": "1.9.3",
103
+ "hash": "127837186fa07885e95a61f7a00dc6a965b3a74ffc589de3e3c9e31b360c13ca"
104
+ },
105
+ "src/components/sections/features/wireframe.ts": {
106
+ "version": "1.9.3",
107
+ "hash": "20194a8cba45ed2da0625a6ff9d22d98cfd44188d73a477a2dda81a74a998c94"
108
+ },
109
+ "src/components/sections/gallery/Gallery.astro": {
110
+ "version": "1.9.3",
111
+ "hash": "eaebd59bd511c49992172e95050fd868fc5d77e42ca1bf5f5004a914568f03f3"
112
+ },
113
+ "src/components/sections/gallery/definition.ts": {
114
+ "version": "1.9.3",
115
+ "hash": "6fa007861bc9190421c8460d483cc51bd64a68da42b0d7e5cf7bb98aa319d838"
116
+ },
117
+ "src/components/sections/gallery/lightbox.ts": {
118
+ "version": "1.9.3",
119
+ "hash": "887bbf98d40418a14d76561299162838fe28fd044170c3e7723e03975aad9932"
120
+ },
121
+ "src/components/sections/gallery/wireframe.ts": {
122
+ "version": "1.9.3",
123
+ "hash": "85b3f742088b3c71be557aeac7927d2c69b831df4589413220c87484c49f2a81"
124
+ },
125
+ "src/components/sections/hero/Hero.astro": {
126
+ "version": "1.9.3",
127
+ "hash": "65e50177ddc8b73ded1bf1fc71f2ae950ff1102457b73719e40ceec6467d56d9"
128
+ },
129
+ "src/components/sections/hero/HeroBadge.astro": {
130
+ "version": "1.9.3",
131
+ "hash": "6467a7bb27d4dc718c568f069187385b507fedfb9f79ded3929ee0893126ce6f"
132
+ },
133
+ "src/components/sections/hero/definition.ts": {
134
+ "version": "1.9.3",
135
+ "hash": "db17e42d4e7cc7ebf61e978c405cd9b5ef5c399c6a44c80beddec4e9784882a6"
136
+ },
137
+ "src/components/sections/hero/wireframe.ts": {
138
+ "version": "1.9.3",
139
+ "hash": "4bbe971afb2d4f3af5166c3b525bffe6564627d4a6a3da218073fd5d6eaa68c0"
140
+ },
141
+ "src/components/sections/logo-strip/LogoStrip.astro": {
142
+ "version": "1.9.3",
143
+ "hash": "0bb887f0282bf9d7d0ae65a3afc7f3813c58247c0aa70a4962a6a5e35b8e1c71"
144
+ },
145
+ "src/components/sections/logo-strip/definition.ts": {
146
+ "version": "1.9.3",
147
+ "hash": "de761c20c0ce0b5f4fcc1ad96535addf6f7fb668abd1954709d2f68f72ccffdd"
148
+ },
149
+ "src/components/sections/logo-strip/wireframe.ts": {
150
+ "version": "1.9.3",
151
+ "hash": "aab635e481146a6d361cd16e2155654bbeaa202c19d7855251561f4d588144ed"
152
+ },
153
+ "src/components/sections/media/Media.astro": {
154
+ "version": "1.9.3",
155
+ "hash": "1df9f736daf07b6a4a2768463896b477197d1baa68a445e4ee1de92080b227c2"
156
+ },
157
+ "src/components/sections/media/MediaPlayer.astro": {
158
+ "version": "1.9.3",
159
+ "hash": "e2444c6ff067276b4aeb5a7f6da368a0ce7e6db4feaac7303d508f3df28eadad"
160
+ },
161
+ "src/components/sections/media/definition.ts": {
162
+ "version": "1.9.3",
163
+ "hash": "520d1d78d234c8a005abeffe99fdfe12201cc78e56023bf627869b562974aa3c"
164
+ },
165
+ "src/components/sections/media/source.ts": {
166
+ "version": "1.9.3",
167
+ "hash": "737f87a8352e226469968cdaae3d3240c3e1c9395ba0a4279fb6505ec039fb49"
168
+ },
169
+ "src/components/sections/media/wireframe.ts": {
170
+ "version": "1.9.3",
171
+ "hash": "9afe102c0d66136de50dbe75b4d668b53897283950f71ba26c8e1e70e7abfc9f"
172
+ },
173
+ "src/components/sections/pricing/Pricing.astro": {
174
+ "version": "1.9.3",
175
+ "hash": "611e1ee0cbd7dfd0f504f57966b6073e2559b35b7e33feb2caea4dbe5e2b71b8"
176
+ },
177
+ "src/components/sections/pricing/definition.ts": {
178
+ "version": "1.9.3",
179
+ "hash": "447ad99f5b636a7ff566389102e9beb93b661bb2df969a6e93e740a9ca6ae216"
180
+ },
181
+ "src/components/sections/pricing/wireframe.ts": {
182
+ "version": "1.9.3",
183
+ "hash": "a905ac85fe875c749d080e39929d5d8db51a47380c803b2930aa64fd2fd437d2"
184
+ },
185
+ "src/components/sections/shared.ts": {
186
+ "version": "1.9.3",
187
+ "hash": "84a080557c50b73b14f6eac8fd00cabfb92700c07e1988989a6b699fdcbb695a"
188
+ },
189
+ "src/components/sections/stats/Stats.astro": {
190
+ "version": "1.9.3",
191
+ "hash": "3a5f6cce7b45fd521a383185442571c125922efe4becbf765bd44f33ba394918"
192
+ },
193
+ "src/components/sections/stats/definition.ts": {
194
+ "version": "1.9.3",
195
+ "hash": "c3550fc34e966fa41f5e1804cb439af5382cd09d47d7a68bee2ceccf6cebf568"
196
+ },
197
+ "src/components/sections/stats/wireframe.ts": {
198
+ "version": "1.9.3",
199
+ "hash": "12e6123c53875eaaf2b110a92bd7ccb296e9e46cf47ff8e8343a596cc9b40efb"
200
+ },
201
+ "src/components/sections/steps/Steps.astro": {
202
+ "version": "1.9.3",
203
+ "hash": "4b4895329a51a9da2c5e9984a55fead610a15582b05f8b5bed43635731307470"
204
+ },
205
+ "src/components/sections/steps/definition.ts": {
206
+ "version": "1.9.3",
207
+ "hash": "c5f3f0b1dba9a2bc06f5c266f07256e6f8d9a3de5376544fa92c0e7d9e3a09b4"
208
+ },
209
+ "src/components/sections/steps/icons.ts": {
210
+ "version": "1.9.3",
211
+ "hash": "12f7ca22de575d819a9789615a8b311aa55536884ce3be41e7b2a73c1a6358c1"
212
+ },
213
+ "src/components/sections/steps/wireframe.ts": {
214
+ "version": "1.9.3",
215
+ "hash": "108888fc5cc4349c5c856db836cbfb10456338c403cd11d4edb2c463fc6bb8b0"
216
+ },
217
+ "src/components/sections/testimonials/Testimonials.astro": {
218
+ "version": "1.9.3",
219
+ "hash": "113229d028ed6f742aa9d8ae6dbc1cfe67ac0602961265347b9f6df94b38eac1"
220
+ },
221
+ "src/components/sections/testimonials/definition.ts": {
222
+ "version": "1.9.3",
223
+ "hash": "6fe3e4489be66ab1745670fb0d1f9fbc6e347375464470de975df1757b9e181c"
224
+ },
225
+ "src/components/sections/testimonials/wireframe.ts": {
226
+ "version": "1.9.3",
227
+ "hash": "42ed8f23ed4ecc805c9477ffd1088a0a2d6a9e3b61f22ee0a726533cfa3eca53"
228
+ },
229
+ "src/components/sections/text-image/TextImage.astro": {
230
+ "version": "1.9.3",
231
+ "hash": "8fdadd5ca3ee5412b726162f7f3681ec7d662c00f06c4959b0f27e6699142120"
232
+ },
233
+ "src/components/sections/text-image/definition.ts": {
234
+ "version": "1.9.3",
235
+ "hash": "630028579eae5df29879e3b9e2230d4aa45c09d99de8e992de1f1b67da7154f9"
236
+ },
237
+ "src/components/sections/text-image/wireframe.ts": {
238
+ "version": "1.9.3",
239
+ "hash": "af9a266f1120eee687823afe114ea3cdb656e1e0911eda30fb5574501544f96d"
240
+ },
241
+ "src/components/sections/text/Text.astro": {
242
+ "version": "1.9.3",
243
+ "hash": "36204dc4282a98533581f1098ccf824ea175669b4b22b83af34df14f713a4f46"
244
+ },
245
+ "src/components/sections/text/definition.ts": {
246
+ "version": "1.9.3",
247
+ "hash": "48f89d37e0154fc397d0f9092d36271661a657e9e1903c5ad90314d38ae04b10"
248
+ },
249
+ "src/components/sections/text/wireframe.ts": {
250
+ "version": "1.9.3",
251
+ "hash": "fb55bafc2fa8dd9fee1cfa24ca54de644114d557e4610f7e083b9b01ed258522"
252
+ },
253
+ "src/lib/assets.ts": {
254
+ "version": "1.9.3",
255
+ "hash": "8efa10327696d29ad9f4d2fc85a3962d969ba80db1cb63184b148000b7147450"
256
+ },
257
+ "src/lib/cn.ts": {
258
+ "version": "1.9.3",
259
+ "hash": "ce39955d9af5f01f57eb69071fe2e4645e9091b240bc7185652cf4541ecb91fa"
260
+ },
261
+ "src/lib/contact-form.ts": {
262
+ "version": "1.9.3",
263
+ "hash": "b52d5520d87e37f6c5f33128637aca671f744ede65588d751b2d69b3fcef849d"
264
+ },
265
+ "src/lib/hidden-text.ts": {
266
+ "version": "1.9.3",
267
+ "hash": "44ae57dcbfaa71586589b212fe9a3eefcc5c5763d219e8d175095ea2b6722dcf"
268
+ },
269
+ "src/lib/image-url.ts": {
270
+ "version": "1.9.3",
271
+ "hash": "47e51f06b5bfc3c0fc595bd18d13d71f9f68d063c3d12e5514ecb8098a114131"
272
+ },
273
+ "src/lib/link-attrs.ts": {
274
+ "version": "1.9.3",
275
+ "hash": "648802476e4dfaaeab6c4172313c683420c1fb66898de8f8c74ca4adf876cd37"
276
+ }
277
+ }
278
+ }
@@ -19,7 +19,7 @@
19
19
  "@fontsource/jetbrains-mono": "^5.3.0",
20
20
  "@tailwindcss/vite": "^4.1.12",
21
21
  "astro": "^7.4.1",
22
- "bearminion": "^1.7.0",
22
+ "bearminion": "^1.9.3",
23
23
  "class-variance-authority": "^0.7.1",
24
24
  "sharp": "^0.35.5",
25
25
  "tailwind-merge": "^3.7.0",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  import type { Section } from './definitions'
3
- import { sectionComponents } from './registry'
3
+ import { sectionComponents } from './components.gen'
4
4
 
5
5
  interface Props {
6
6
  sections: Section[]
@@ -8,58 +8,15 @@ interface Props {
8
8
  motion?: boolean
9
9
  }
10
10
 
11
+ /** What every section component takes. Each one narrows `section` to its own type. */
12
+ type SectionComponent = (props: { section: Section; index: number; motion?: boolean }) => unknown
13
+
11
14
  const { sections, motion = true } = Astro.props
12
- const Hero = sectionComponents.hero
13
- const LogoStrip = sectionComponents.logoStrip
14
- const Steps = sectionComponents.steps
15
- const Gallery = sectionComponents.gallery
16
- const Features = sectionComponents.features
17
- const Text = sectionComponents.text
18
- const TextImage = sectionComponents.textImage
19
- const Stats = sectionComponents.stats
20
- const Testimonials = sectionComponents.testimonials
21
- const Pricing = sectionComponents.pricing
22
- const Media = sectionComponents.media
23
- const Faq = sectionComponents.faq
24
- const Cta = sectionComponents.cta
25
- const Contact = sectionComponents.contact
26
15
  ---
27
16
 
28
17
  {
29
18
  sections.map((section, index) => {
30
- switch (section.type) {
31
- case 'hero':
32
- return <Hero section={section} index={index} motion={motion} />
33
- case 'logoStrip':
34
- return <LogoStrip section={section} index={index} motion={motion} />
35
- case 'steps':
36
- return <Steps section={section} index={index} motion={motion} />
37
- case 'gallery':
38
- return <Gallery section={section} index={index} motion={motion} />
39
- case 'features':
40
- return <Features section={section} index={index} motion={motion} />
41
- case 'text':
42
- return <Text section={section} index={index} motion={motion} />
43
- case 'textImage':
44
- return <TextImage section={section} index={index} motion={motion} />
45
- case 'stats':
46
- return <Stats section={section} index={index} motion={motion} />
47
- case 'testimonials':
48
- return <Testimonials section={section} index={index} motion={motion} />
49
- case 'pricing':
50
- return <Pricing section={section} index={index} motion={motion} />
51
- case 'media':
52
- return <Media section={section} index={index} motion={motion} />
53
- case 'faq':
54
- return <Faq section={section} index={index} motion={motion} />
55
- case 'cta':
56
- return <Cta section={section} index={index} motion={motion} />
57
- case 'contact':
58
- return <Contact section={section} index={index} motion={motion} />
59
- default: {
60
- const unreachable: never = section
61
- return unreachable
62
- }
63
- }
19
+ const Component = sectionComponents[section.type] as unknown as SectionComponent
20
+ return <Component section={section} index={index} motion={motion} />
64
21
  })
65
22
  }
@@ -1,3 +1,4 @@
1
+ // Generated by `bearminion sync`. Do not edit: add or remove a directory under sections/ and run it again.
1
2
  import type { SectionType } from './definitions'
2
3
  import Contact from './contact/Contact.astro'
3
4
  import Cta from './cta/Cta.astro'
@@ -14,20 +15,20 @@ import Testimonials from './testimonials/Testimonials.astro'
14
15
  import Text from './text/Text.astro'
15
16
  import TextImage from './text-image/TextImage.astro'
16
17
 
17
- /** Maps a content section `type` to the component that renders it. Definitions live in `definitions.ts`. */
18
+ /** Maps a content section `type` to the component that renders it. */
18
19
  export const sectionComponents = {
20
+ contact: Contact,
21
+ cta: Cta,
22
+ faq: Faq,
23
+ features: Features,
24
+ gallery: Gallery,
19
25
  hero: Hero,
20
26
  logoStrip: LogoStrip,
27
+ media: Media,
28
+ pricing: Pricing,
29
+ stats: Stats,
21
30
  steps: Steps,
22
- gallery: Gallery,
23
- features: Features,
31
+ testimonials: Testimonials,
24
32
  text: Text,
25
33
  textImage: TextImage,
26
- stats: Stats,
27
- testimonials: Testimonials,
28
- pricing: Pricing,
29
- media: Media,
30
- faq: Faq,
31
- cta: Cta,
32
- contact: Contact,
33
34
  } satisfies Record<SectionType, unknown>
@@ -5,6 +5,7 @@ import Emphasis from '../../atoms/Emphasis.astro'
5
5
  import Typography from '../../atoms/Typography.astro'
6
6
  import SectionHeader from '../../molecules/SectionHeader.astro'
7
7
  import SectionShell from '../../molecules/SectionShell.astro'
8
+ import { HIDDEN_FALLBACK, hide } from '../../../lib/hidden-text'
8
9
 
9
10
  interface Props {
10
11
  section: Extract<Section, { type: 'contact' }>
@@ -17,6 +18,10 @@ const props = section.props
17
18
  const field = (path: string) => `sections.${index}.props.${path}`
18
19
  const reveal = section.motion ?? motion
19
20
  const formId = `contact-form-${section.id}`
21
+ // A detail marked "hide from crawlers" is written into the HTML scrambled, and form.ts puts the value back in the browser.
22
+ const hidden = (detail: { value: string; hideFromCrawlers?: boolean | undefined }) =>
23
+ detail.hideFromCrawlers ? { 'data-hidden-value': hide(detail.value) } : {}
24
+ const shown = (detail: { value: string; hideFromCrawlers?: boolean | undefined }) => (detail.hideFromCrawlers ? HIDDEN_FALLBACK : detail.value)
20
25
  // The form always posts to /api/contact, where the site's own handler (src/forms/contact.ts) answers. The public
21
26
  // Turnstile site key comes from the environment at build time, so it never lives in the content files.
22
27
  const turnstileKey: string | undefined = import.meta.env.PUBLIC_TURNSTILE_SITE_KEY || undefined
@@ -43,7 +48,7 @@ const formAttrs = {
43
48
  <dt class="font-mono text-[0.75rem] tracking-[0.06em] text-muted uppercase" data-field={field(`details.${detailIndex}.label`)}>
44
49
  {detail.label}
45
50
  </dt>
46
- <dd data-field={field(`details.${detailIndex}.value`)}>{detail.value}</dd>
51
+ <dd data-field={field(`details.${detailIndex}.value`)} {...hidden(detail)}>{shown(detail)}</dd>
47
52
  </div>
48
53
  ))}
49
54
  </dl>
@@ -197,7 +202,7 @@ const formAttrs = {
197
202
  {props.details.map((detail, detailIndex) => (
198
203
  <div>
199
204
  <dt class="font-mono text-[0.6875rem] tracking-[0.08em] text-muted uppercase" data-field={field(`details.${detailIndex}.label`)}>{detail.label}</dt>
200
- <dd class="mt-1" data-field={field(`details.${detailIndex}.value`)}>{detail.value}</dd>
205
+ <dd class="mt-1" data-field={field(`details.${detailIndex}.value`)} {...hidden(detail)}>{shown(detail)}</dd>
201
206
  </div>
202
207
  ))}
203
208
  </dl>
@@ -9,6 +9,8 @@ export const contactDetailSchema = z
9
9
  .object({
10
10
  label: textSchema,
11
11
  value: textSchema,
12
+ // The built page carries the value scrambled and a few lines of script show it, so a crawler that only reads the HTML finds none.
13
+ hideFromCrawlers: z.boolean().optional(),
12
14
  })
13
15
  .strict()
14
16
 
@@ -35,7 +37,7 @@ export const contact = defineSection({
35
37
  heading: 'Get in touch.',
36
38
  marks: accent('Get in touch.', 'in touch.'),
37
39
  body: 'Tell people what they can contact you about and when they will hear back.',
38
- details: [{ label: 'Email', value: 'hello@example.com' }],
40
+ details: [{ label: 'Email', value: 'hello@example.com', hideFromCrawlers: false }],
39
41
  topics: ['General'],
40
42
  note: 'We only use your details to reply to you.',
41
43
  thanks: 'Thanks, your message is on its way.',
@@ -44,7 +46,7 @@ export const contact = defineSection({
44
46
  defaultVariant: 'split',
45
47
  // The form posts to /api/contact: the handler is `src/forms/contact.ts`, written in code, never configured here.
46
48
  form: 'contact',
47
- optional: { props: ['eyebrow', 'heading', 'body', 'note', 'thanks'] },
49
+ optional: { props: ['eyebrow', 'heading', 'body', 'note', 'thanks'], items: { details: ['hideFromCrawlers'] } },
48
50
  counts: { details: { recommended: 3 }, topics: { recommended: 3 } },
49
51
  wireframe: contactWireframe,
50
52
  })
@@ -8,6 +8,7 @@ import {
8
8
  collectSubmission,
9
9
  readResponse,
10
10
  } from '../../../lib/contact-form'
11
+ import { reveal } from '../../../lib/hidden-text'
11
12
 
12
13
  /**
13
14
  * Wires every Contact form on the page: the states idle, sending, sent and error, field errors under their fields,
@@ -289,8 +290,24 @@ function bind(root: HTMLElement) {
289
290
  })
290
291
  }
291
292
 
293
+ /** Puts back the contact details the page was built without (`hideFromCrawlers`). The marker goes, so it runs once. */
294
+ function revealHidden(root: HTMLElement): void {
295
+ for (const element of root.querySelectorAll('[data-hidden-value]')) {
296
+ const hidden = element.getAttribute('data-hidden-value')
297
+ element.removeAttribute('data-hidden-value')
298
+ if (hidden === null) continue
299
+ try {
300
+ element.textContent = reveal(hidden)
301
+ } catch {
302
+ // A damaged value stays as the "turn on JavaScript" line rather than breaking the form.
303
+ }
304
+ }
305
+ }
306
+
292
307
  export function bindContacts(): void {
293
308
  for (const root of document.querySelectorAll('[data-contact]')) {
294
- if (root instanceof HTMLElement) bind(root)
309
+ if (!(root instanceof HTMLElement)) continue
310
+ revealHidden(root)
311
+ bind(root)
295
312
  }
296
313
  }
@@ -0,0 +1,33 @@
1
+ // Generated by `bearminion sync`. Do not edit: add or remove a directory under sections/ and run it again.
2
+ import type { SectionRegistry } from 'bearminion'
3
+ import { contact } from './contact/definition'
4
+ import { cta } from './cta/definition'
5
+ import { faq } from './faq/definition'
6
+ import { features } from './features/definition'
7
+ import { gallery } from './gallery/definition'
8
+ import { hero } from './hero/definition'
9
+ import { logoStrip } from './logo-strip/definition'
10
+ import { media } from './media/definition'
11
+ import { pricing } from './pricing/definition'
12
+ import { stats } from './stats/definition'
13
+ import { steps } from './steps/definition'
14
+ import { testimonials } from './testimonials/definition'
15
+ import { text } from './text/definition'
16
+ import { textImage } from './text-image/definition'
17
+
18
+ export const sectionDefinitions = {
19
+ contact,
20
+ cta,
21
+ faq,
22
+ features,
23
+ gallery,
24
+ hero,
25
+ logoStrip,
26
+ media,
27
+ pricing,
28
+ stats,
29
+ steps,
30
+ testimonials,
31
+ text,
32
+ textImage,
33
+ } satisfies SectionRegistry
@@ -1,49 +1,42 @@
1
- import {
2
- createPageSchema,
3
- createSectionSchema,
4
- type Option,
5
- type Page as ContentPage,
6
- type SectionOf,
7
- type SectionRegistry,
8
- } from 'bearminion'
9
- import { contact } from './contact/definition'
10
- import { cta } from './cta/definition'
11
- import { faq } from './faq/definition'
12
- import { features } from './features/definition'
13
- import { gallery } from './gallery/definition'
14
- import { hero } from './hero/definition'
15
- import { logoStrip } from './logo-strip/definition'
16
- import { media } from './media/definition'
17
- import { pricing } from './pricing/definition'
18
- import { stats } from './stats/definition'
19
- import { steps } from './steps/definition'
20
- import { testimonials } from './testimonials/definition'
21
- import { text } from './text/definition'
22
- import { textImage } from './text-image/definition'
1
+ import { createPageSchema, createSectionSchema, type Option, type Page as ContentPage, type SectionOf } from 'bearminion'
2
+ import { sectionDefinitions as generated } from './definitions.gen'
23
3
 
24
4
  /**
25
- * Every section type of this site. Each one is defined in its own directory:
26
- * `definition.ts` (zod schema, defaults, options), `wireframe.ts` (the Add section thumbnail),
27
- * and the Astro component. Add a directory and list it here (and in `registry.ts`) to add a type.
5
+ * Where a section type sits in the editor's Add section menu and on the variants page. A type that is not listed
6
+ * (one you added) comes after these, by name.
7
+ */
8
+ const order = [
9
+ 'hero',
10
+ 'logoStrip',
11
+ 'steps',
12
+ 'gallery',
13
+ 'features',
14
+ 'text',
15
+ 'textImage',
16
+ 'stats',
17
+ 'testimonials',
18
+ 'pricing',
19
+ 'media',
20
+ 'faq',
21
+ 'cta',
22
+ 'contact',
23
+ ] as const
24
+
25
+ const rank = (type: string) => {
26
+ const index = (order as readonly string[]).indexOf(type)
27
+ return index === -1 ? order.length : index
28
+ }
29
+
30
+ /**
31
+ * Every section type of this site. A type is a directory next to this file with a `definition.ts` (zod schema,
32
+ * defaults, options), a `wireframe.ts` (the Add section thumbnail) and the Astro component. `bearminion sync` lists
33
+ * the directories in `definitions.gen.ts` and `components.gen.ts`: add a directory, run it, and the type exists.
28
34
  *
29
35
  * It holds no `.astro` imports, so `astro.config.ts` and the editor can load it.
30
36
  */
31
- export const sectionDefinitions = {
32
- hero,
33
- logoStrip,
34
- steps,
35
- gallery,
36
- features,
37
- text,
38
- textImage,
39
- stats,
40
- testimonials,
41
- pricing,
42
- media,
43
- faq,
44
- cta,
45
- contact,
46
- } satisfies SectionRegistry
37
+ export const sectionDefinitions = Object.fromEntries(
38
+ Object.entries(generated).sort(([a], [b]) => rank(a) - rank(b) || a.localeCompare(b)),
39
+ ) as typeof generated
47
40
 
48
41
  export type SectionType = keyof typeof sectionDefinitions
49
42
  export type Section = SectionOf<typeof sectionDefinitions>
@@ -36,3 +36,19 @@ export function unhandledForms(pages: readonly CheckedPage[], handled: boolean):
36
36
  export function unhandledFormMessage(form: UnhandledForm): string {
37
37
  return `The contact form "${form.section}" on page "${form.page}" posts to /api/${CONTACT_HANDLER}, but src/forms/${CONTACT_HANDLER}.ts does not exist. Visitors who send it get an error. Create the file: https://docs.bearminion.com/forms`
38
38
  }
39
+
40
+ /**
41
+ * With `BEARMINION_FORMS=required` the build stops instead of warning, so a production deploy cannot go out with a Contact
42
+ * form nobody answers. Set it in the host's build environment, not in `.env`: a new site and `astro dev` stay as they are.
43
+ * The section is never hidden, because a page that loses a section without a word is worse than a build that says why.
44
+ */
45
+ export function formsRequired(value: string | undefined): boolean {
46
+ return value?.trim().toLowerCase() === 'required'
47
+ }
48
+
49
+ export function requiredFormsError(forms: readonly UnhandledForm[]): Error | undefined {
50
+ if (forms.length === 0) return undefined
51
+ return new Error(
52
+ `${forms.map(unhandledFormMessage).join('\n')}\nBEARMINION_FORMS=required stops the build while a contact form has no handler.`,
53
+ )
54
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Keeps a contact detail (an email address, a phone number) out of the page's HTML, so a crawler that only reads markup
3
+ * does not harvest it. `hide` runs at build time and `reveal` in the browser.
4
+ *
5
+ * This is obfuscation, not encryption: the page has to show the value, so a browser, and any crawler that runs the
6
+ * page's script, can recover it. It stops the scrapers that match `@` and digits in the HTML, which is most of them.
7
+ */
8
+
9
+ const KEY = 'bearminion'
10
+
11
+ function scramble(bytes: Uint8Array): Uint8Array {
12
+ return bytes.map((byte, index) => byte ^ (KEY.charCodeAt(index % KEY.length) & 0xff))
13
+ }
14
+
15
+ /** `value` as a short ASCII string that contains none of its characters. */
16
+ export function hide(value: string): string {
17
+ const scrambled = scramble(new TextEncoder().encode(value))
18
+ let binary = ''
19
+ for (const byte of scrambled) binary += String.fromCharCode(byte)
20
+ return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')
21
+ }
22
+
23
+ /** The value `hide` was given. */
24
+ export function reveal(hidden: string): string {
25
+ const base64 = hidden.replace(/-/g, '+').replace(/_/g, '/')
26
+ const binary = atob(base64 + '='.repeat((4 - (base64.length % 4)) % 4))
27
+ const bytes = Uint8Array.from(binary, (character) => character.charCodeAt(0))
28
+ return new TextDecoder().decode(scramble(bytes))
29
+ }
30
+
31
+ /** What a visitor without JavaScript reads where the value would be. */
32
+ export const HIDDEN_FALLBACK = 'Turn on JavaScript to see this, or use the form.'