create-bearminion 1.8.0 → 1.10.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/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # create-bearminion
2
2
 
3
+ ## 1.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a10e4a7: New command `npx bearminion check form`. It reads the site's files and environment and names what keeps the Contact form from working: a missing handler or glue file, an import without `.js`, a Netlify function in the wrong folder or without a path, a Wrangler config without `main`, with the placeholder name or without `CONTACT_FROM` and `CONTACT_TO` under `vars`. Each problem comes with its fix. It writes nothing and cannot see the host's own settings. `--host` and `--json` work as for `add form`.
8
+
9
+ ## 1.9.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 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.
14
+
15
+ ## 1.9.2
16
+
17
+ ### Patch Changes
18
+
19
+ - 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.
20
+ - 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.
21
+
22
+ ## 1.9.1
23
+
24
+ ### Patch Changes
25
+
26
+ - 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`.
27
+
28
+ ## 1.9.0
29
+
30
+ ### Minor Changes
31
+
32
+ - 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).
33
+ - 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).
34
+ - 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.
35
+
36
+ ### Patch Changes
37
+
38
+ - 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.
39
+
3
40
  ## 1.8.0
4
41
 
5
42
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bearminion",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
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.
@@ -132,6 +132,8 @@ The Add section menu lists the types in the order of `order` in `sections/defini
132
132
 
133
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.
134
134
 
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
+
135
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.
136
138
 
137
139
  ## Atoms
@@ -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
  }
@@ -0,0 +1,278 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "template": "default",
4
+ "files": {
5
+ "src/components/atoms/Button.astro": {
6
+ "version": "1.10.0",
7
+ "hash": "7be42b3dc3a3b59bec169de32a9d801904689e2705473d1945724658dc799043"
8
+ },
9
+ "src/components/atoms/Emphasis.astro": {
10
+ "version": "1.10.0",
11
+ "hash": "a62835636e2df3a02acf51c1610ba309e1085b7165576ecfbb570a2241aab6b0"
12
+ },
13
+ "src/components/atoms/Image.astro": {
14
+ "version": "1.10.0",
15
+ "hash": "015e7e24d250e4bec58e1699eaf115dc1a92a713bdc317cc1a3f31fae163f09d"
16
+ },
17
+ "src/components/atoms/Typography.astro": {
18
+ "version": "1.10.0",
19
+ "hash": "56e7ea3cf08ef4159d6b72c97761d13334b5468476e0226d62b42effd1368fd2"
20
+ },
21
+ "src/components/atoms/button.ts": {
22
+ "version": "1.10.0",
23
+ "hash": "dfa3955ebb4416ecb1aea899f41b2d2abc26d163790615fbc8113a998a6cd6e6"
24
+ },
25
+ "src/components/atoms/image.ts": {
26
+ "version": "1.10.0",
27
+ "hash": "63361cdb18f0fb89af00cc089b6afd33164aee315decbe41c55a448e09050e42"
28
+ },
29
+ "src/components/atoms/options.ts": {
30
+ "version": "1.10.0",
31
+ "hash": "5fd517f2abfb3e650f740d37e68439807a7da4056aa57458dad60e322b6f5b62"
32
+ },
33
+ "src/components/atoms/typography.ts": {
34
+ "version": "1.10.0",
35
+ "hash": "a4310d2e1ffae64d245c3d8b3fce2d220f19c598bb38f70ed1bd17c0262840c6"
36
+ },
37
+ "src/components/molecules/CommandLine.astro": {
38
+ "version": "1.10.0",
39
+ "hash": "af11f7f28617129636ee1d0097c21427bdb7bfaa7d8ee2750faaa8bedcb67b06"
40
+ },
41
+ "src/components/molecules/MediaFrame.astro": {
42
+ "version": "1.10.0",
43
+ "hash": "f57a20d18beacb9f28acd9efe9eeb3487c594735239f47c7bb4311f1a4140886"
44
+ },
45
+ "src/components/molecules/Pill.astro": {
46
+ "version": "1.10.0",
47
+ "hash": "b7b32e8de70084159003552f61dbccaf8aa13d338f231183ca9443efa72c7644"
48
+ },
49
+ "src/components/molecules/SectionHeader.astro": {
50
+ "version": "1.10.0",
51
+ "hash": "b2692e02875362cc9dac3dc7a6c80bd056bf8d2af2973da1eb62d9d268d6b9ba"
52
+ },
53
+ "src/components/molecules/SectionShell.astro": {
54
+ "version": "1.10.0",
55
+ "hash": "dc57fc01c666f1fef4b1b9799c2c0728571ac123af1567df3cb6f1e6456d2843"
56
+ },
57
+ "src/components/sections/contact/Contact.astro": {
58
+ "version": "1.10.0",
59
+ "hash": "4247463ccd5cdde93ab263f12908ca2a87e5e6c2b51b6e6025f712c919b7ece1"
60
+ },
61
+ "src/components/sections/contact/definition.ts": {
62
+ "version": "1.10.0",
63
+ "hash": "9ce73d48688466dcbbb6a0943dcc88190d2be05c2aad8b60c8c2a189e78dad28"
64
+ },
65
+ "src/components/sections/contact/form.ts": {
66
+ "version": "1.10.0",
67
+ "hash": "18b1f2e2527525a74313ec5e9903e2033b9e5ccae955e5778efd6af10e5b58dd"
68
+ },
69
+ "src/components/sections/contact/wireframe.ts": {
70
+ "version": "1.10.0",
71
+ "hash": "91bbbf164a0c0eea2f526bf84fef2ba2ab02b298354049df6fbc73f171a1ce8f"
72
+ },
73
+ "src/components/sections/cta/Cta.astro": {
74
+ "version": "1.10.0",
75
+ "hash": "0ae98e77b6d645b71f58dbf790908333be59dd16c3c558e924021ce2bcb0d2dc"
76
+ },
77
+ "src/components/sections/cta/definition.ts": {
78
+ "version": "1.10.0",
79
+ "hash": "d6576c8a53ac59dae964644765d690f2938e589fc13b24c0a0993ead5ba62285"
80
+ },
81
+ "src/components/sections/cta/wireframe.ts": {
82
+ "version": "1.10.0",
83
+ "hash": "5c4e998a2a30a4185776d5112c0dcf09130002f3a04d4f31752bb1346ae7fc3f"
84
+ },
85
+ "src/components/sections/faq/Faq.astro": {
86
+ "version": "1.10.0",
87
+ "hash": "59843ad44db35cbe21acfc17c92b7455dcd0b293d5c4a91c5ce23daa70904039"
88
+ },
89
+ "src/components/sections/faq/definition.ts": {
90
+ "version": "1.10.0",
91
+ "hash": "b24bdd9077c471379130d611ecdcda487d88b1108ab22dba0a6307839243eac8"
92
+ },
93
+ "src/components/sections/faq/wireframe.ts": {
94
+ "version": "1.10.0",
95
+ "hash": "d3865d0b0d6fecf92eef5c9959cf495253527f7e73592726c42fa87fc2e21d38"
96
+ },
97
+ "src/components/sections/features/Features.astro": {
98
+ "version": "1.10.0",
99
+ "hash": "fa2d4de7ada18b6fc9159c99db54aa9c09d8209b421db574251cec695e7abf9d"
100
+ },
101
+ "src/components/sections/features/definition.ts": {
102
+ "version": "1.10.0",
103
+ "hash": "127837186fa07885e95a61f7a00dc6a965b3a74ffc589de3e3c9e31b360c13ca"
104
+ },
105
+ "src/components/sections/features/wireframe.ts": {
106
+ "version": "1.10.0",
107
+ "hash": "20194a8cba45ed2da0625a6ff9d22d98cfd44188d73a477a2dda81a74a998c94"
108
+ },
109
+ "src/components/sections/gallery/Gallery.astro": {
110
+ "version": "1.10.0",
111
+ "hash": "eaebd59bd511c49992172e95050fd868fc5d77e42ca1bf5f5004a914568f03f3"
112
+ },
113
+ "src/components/sections/gallery/definition.ts": {
114
+ "version": "1.10.0",
115
+ "hash": "6fa007861bc9190421c8460d483cc51bd64a68da42b0d7e5cf7bb98aa319d838"
116
+ },
117
+ "src/components/sections/gallery/lightbox.ts": {
118
+ "version": "1.10.0",
119
+ "hash": "887bbf98d40418a14d76561299162838fe28fd044170c3e7723e03975aad9932"
120
+ },
121
+ "src/components/sections/gallery/wireframe.ts": {
122
+ "version": "1.10.0",
123
+ "hash": "85b3f742088b3c71be557aeac7927d2c69b831df4589413220c87484c49f2a81"
124
+ },
125
+ "src/components/sections/hero/Hero.astro": {
126
+ "version": "1.10.0",
127
+ "hash": "65e50177ddc8b73ded1bf1fc71f2ae950ff1102457b73719e40ceec6467d56d9"
128
+ },
129
+ "src/components/sections/hero/HeroBadge.astro": {
130
+ "version": "1.10.0",
131
+ "hash": "6467a7bb27d4dc718c568f069187385b507fedfb9f79ded3929ee0893126ce6f"
132
+ },
133
+ "src/components/sections/hero/definition.ts": {
134
+ "version": "1.10.0",
135
+ "hash": "db17e42d4e7cc7ebf61e978c405cd9b5ef5c399c6a44c80beddec4e9784882a6"
136
+ },
137
+ "src/components/sections/hero/wireframe.ts": {
138
+ "version": "1.10.0",
139
+ "hash": "4bbe971afb2d4f3af5166c3b525bffe6564627d4a6a3da218073fd5d6eaa68c0"
140
+ },
141
+ "src/components/sections/logo-strip/LogoStrip.astro": {
142
+ "version": "1.10.0",
143
+ "hash": "0bb887f0282bf9d7d0ae65a3afc7f3813c58247c0aa70a4962a6a5e35b8e1c71"
144
+ },
145
+ "src/components/sections/logo-strip/definition.ts": {
146
+ "version": "1.10.0",
147
+ "hash": "de761c20c0ce0b5f4fcc1ad96535addf6f7fb668abd1954709d2f68f72ccffdd"
148
+ },
149
+ "src/components/sections/logo-strip/wireframe.ts": {
150
+ "version": "1.10.0",
151
+ "hash": "aab635e481146a6d361cd16e2155654bbeaa202c19d7855251561f4d588144ed"
152
+ },
153
+ "src/components/sections/media/Media.astro": {
154
+ "version": "1.10.0",
155
+ "hash": "1df9f736daf07b6a4a2768463896b477197d1baa68a445e4ee1de92080b227c2"
156
+ },
157
+ "src/components/sections/media/MediaPlayer.astro": {
158
+ "version": "1.10.0",
159
+ "hash": "e2444c6ff067276b4aeb5a7f6da368a0ce7e6db4feaac7303d508f3df28eadad"
160
+ },
161
+ "src/components/sections/media/definition.ts": {
162
+ "version": "1.10.0",
163
+ "hash": "520d1d78d234c8a005abeffe99fdfe12201cc78e56023bf627869b562974aa3c"
164
+ },
165
+ "src/components/sections/media/source.ts": {
166
+ "version": "1.10.0",
167
+ "hash": "737f87a8352e226469968cdaae3d3240c3e1c9395ba0a4279fb6505ec039fb49"
168
+ },
169
+ "src/components/sections/media/wireframe.ts": {
170
+ "version": "1.10.0",
171
+ "hash": "9afe102c0d66136de50dbe75b4d668b53897283950f71ba26c8e1e70e7abfc9f"
172
+ },
173
+ "src/components/sections/pricing/Pricing.astro": {
174
+ "version": "1.10.0",
175
+ "hash": "611e1ee0cbd7dfd0f504f57966b6073e2559b35b7e33feb2caea4dbe5e2b71b8"
176
+ },
177
+ "src/components/sections/pricing/definition.ts": {
178
+ "version": "1.10.0",
179
+ "hash": "447ad99f5b636a7ff566389102e9beb93b661bb2df969a6e93e740a9ca6ae216"
180
+ },
181
+ "src/components/sections/pricing/wireframe.ts": {
182
+ "version": "1.10.0",
183
+ "hash": "a905ac85fe875c749d080e39929d5d8db51a47380c803b2930aa64fd2fd437d2"
184
+ },
185
+ "src/components/sections/shared.ts": {
186
+ "version": "1.10.0",
187
+ "hash": "84a080557c50b73b14f6eac8fd00cabfb92700c07e1988989a6b699fdcbb695a"
188
+ },
189
+ "src/components/sections/stats/Stats.astro": {
190
+ "version": "1.10.0",
191
+ "hash": "3a5f6cce7b45fd521a383185442571c125922efe4becbf765bd44f33ba394918"
192
+ },
193
+ "src/components/sections/stats/definition.ts": {
194
+ "version": "1.10.0",
195
+ "hash": "c3550fc34e966fa41f5e1804cb439af5382cd09d47d7a68bee2ceccf6cebf568"
196
+ },
197
+ "src/components/sections/stats/wireframe.ts": {
198
+ "version": "1.10.0",
199
+ "hash": "12e6123c53875eaaf2b110a92bd7ccb296e9e46cf47ff8e8343a596cc9b40efb"
200
+ },
201
+ "src/components/sections/steps/Steps.astro": {
202
+ "version": "1.10.0",
203
+ "hash": "4b4895329a51a9da2c5e9984a55fead610a15582b05f8b5bed43635731307470"
204
+ },
205
+ "src/components/sections/steps/definition.ts": {
206
+ "version": "1.10.0",
207
+ "hash": "c5f3f0b1dba9a2bc06f5c266f07256e6f8d9a3de5376544fa92c0e7d9e3a09b4"
208
+ },
209
+ "src/components/sections/steps/icons.ts": {
210
+ "version": "1.10.0",
211
+ "hash": "12f7ca22de575d819a9789615a8b311aa55536884ce3be41e7b2a73c1a6358c1"
212
+ },
213
+ "src/components/sections/steps/wireframe.ts": {
214
+ "version": "1.10.0",
215
+ "hash": "108888fc5cc4349c5c856db836cbfb10456338c403cd11d4edb2c463fc6bb8b0"
216
+ },
217
+ "src/components/sections/testimonials/Testimonials.astro": {
218
+ "version": "1.10.0",
219
+ "hash": "113229d028ed6f742aa9d8ae6dbc1cfe67ac0602961265347b9f6df94b38eac1"
220
+ },
221
+ "src/components/sections/testimonials/definition.ts": {
222
+ "version": "1.10.0",
223
+ "hash": "6fe3e4489be66ab1745670fb0d1f9fbc6e347375464470de975df1757b9e181c"
224
+ },
225
+ "src/components/sections/testimonials/wireframe.ts": {
226
+ "version": "1.10.0",
227
+ "hash": "42ed8f23ed4ecc805c9477ffd1088a0a2d6a9e3b61f22ee0a726533cfa3eca53"
228
+ },
229
+ "src/components/sections/text-image/TextImage.astro": {
230
+ "version": "1.10.0",
231
+ "hash": "8fdadd5ca3ee5412b726162f7f3681ec7d662c00f06c4959b0f27e6699142120"
232
+ },
233
+ "src/components/sections/text-image/definition.ts": {
234
+ "version": "1.10.0",
235
+ "hash": "630028579eae5df29879e3b9e2230d4aa45c09d99de8e992de1f1b67da7154f9"
236
+ },
237
+ "src/components/sections/text-image/wireframe.ts": {
238
+ "version": "1.10.0",
239
+ "hash": "af9a266f1120eee687823afe114ea3cdb656e1e0911eda30fb5574501544f96d"
240
+ },
241
+ "src/components/sections/text/Text.astro": {
242
+ "version": "1.10.0",
243
+ "hash": "36204dc4282a98533581f1098ccf824ea175669b4b22b83af34df14f713a4f46"
244
+ },
245
+ "src/components/sections/text/definition.ts": {
246
+ "version": "1.10.0",
247
+ "hash": "48f89d37e0154fc397d0f9092d36271661a657e9e1903c5ad90314d38ae04b10"
248
+ },
249
+ "src/components/sections/text/wireframe.ts": {
250
+ "version": "1.10.0",
251
+ "hash": "fb55bafc2fa8dd9fee1cfa24ca54de644114d557e4610f7e083b9b01ed258522"
252
+ },
253
+ "src/lib/assets.ts": {
254
+ "version": "1.10.0",
255
+ "hash": "8efa10327696d29ad9f4d2fc85a3962d969ba80db1cb63184b148000b7147450"
256
+ },
257
+ "src/lib/cn.ts": {
258
+ "version": "1.10.0",
259
+ "hash": "ce39955d9af5f01f57eb69071fe2e4645e9091b240bc7185652cf4541ecb91fa"
260
+ },
261
+ "src/lib/contact-form.ts": {
262
+ "version": "1.10.0",
263
+ "hash": "b52d5520d87e37f6c5f33128637aca671f744ede65588d751b2d69b3fcef849d"
264
+ },
265
+ "src/lib/hidden-text.ts": {
266
+ "version": "1.10.0",
267
+ "hash": "44ae57dcbfaa71586589b212fe9a3eefcc5c5763d219e8d175095ea2b6722dcf"
268
+ },
269
+ "src/lib/image-url.ts": {
270
+ "version": "1.10.0",
271
+ "hash": "47e51f06b5bfc3c0fc595bd18d13d71f9f68d063c3d12e5514ecb8098a114131"
272
+ },
273
+ "src/lib/link-attrs.ts": {
274
+ "version": "1.10.0",
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.8.0",
22
+ "bearminion": "^1.10.0",
23
23
  "class-variance-authority": "^0.7.1",
24
24
  "sharp": "^0.35.5",
25
25
  "tailwind-merge": "^3.7.0",
@@ -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
  }
@@ -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.'