@bettercms-ai/astro 0.13.0 → 0.14.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 +41 -5
- package/components/BcmsVisualEditing.astro +4 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -29,12 +29,28 @@ export default defineConfig({
|
|
|
29
29
|
});
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
### Environment variables
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
Every public value resolves in this order: `bettercms({ ... })` option, then env, then the
|
|
35
|
+
`bcms-content.json` snapshot the deploy workflow writes before the build.
|
|
36
|
+
|
|
37
|
+
| Variable | Option | Read | Default / notes |
|
|
38
|
+
| --- | --- | --- | --- |
|
|
39
|
+
| `PUBLIC_BCMS_API_URL` | `apiUrl` | config time | Required (option, env or snapshot) |
|
|
40
|
+
| `PUBLIC_BCMS_WORKSPACE` | `workspace` | config time | Required (option, env or snapshot) |
|
|
41
|
+
| `PUBLIC_BCMS_PROJECT_ID` | `projectId` | config time | Optional project scope for forms |
|
|
42
|
+
| `PUBLIC_BCMS_MEDIA_URL` | `mediaUrl` | config time | `https://cdn.bettercms.ai` |
|
|
43
|
+
| `PUBLIC_BCMS_STUDIO_URL` | `studioUrl` | config time | Unset. `<BcmsVisualEditing>` falls back to `https://bettercms.ai` |
|
|
44
|
+
| `BCMS_API_KEY` | none | server runtime | `content:read`, or `content:read:draft` for draft previews. Never bundled |
|
|
45
|
+
| `BCMS_DRAFT_SECRET` | none | server runtime | Signs the draft cookie. Runtime `process.env` wins over a build-time value. Without it `/api/bcms/draft/enable` returns 500 |
|
|
46
|
+
|
|
47
|
+
The BetterCMS-generated deploy workflow sets `PUBLIC_BCMS_API_URL`, `PUBLIC_BCMS_WORKSPACE`
|
|
48
|
+
and `PUBLIC_BCMS_PROJECT_ID` for the build. Its repo secret `BCMS_API_KEY` reaches only the
|
|
49
|
+
content-fetch step, never the build. On your own host, set the two server variables yourself.
|
|
50
|
+
|
|
51
|
+
This package ships no revalidation route. Point the project's revalidation webhook
|
|
52
|
+
(Project → Settings) at your rebuild hook. Its secret (the dashboard calls it
|
|
53
|
+
`BETTERCMS_WEBHOOK_SECRET`) signs the body as `x-bettercms-signature: sha256=<hmac>`.
|
|
38
54
|
|
|
39
55
|
Add the virtual-module + `Astro.locals` types to `src/env.d.ts`:
|
|
40
56
|
|
|
@@ -170,3 +186,23 @@ The integration injects `/api/bcms/draft/enable?token=<jwt>&redirect=/path` and
|
|
|
170
186
|
`/api/bcms/draft/disable`. Generate the preview-token link from the dashboard;
|
|
171
187
|
visiting `enable` validates the token against the backend, sets a signed cookie,
|
|
172
188
|
and subsequent loads return draft content. Disable with the `disable` route.
|
|
189
|
+
|
|
190
|
+
### Two draft lanes
|
|
191
|
+
|
|
192
|
+
| Lane | Build | How the canvas shows a draft |
|
|
193
|
+
| --- | --- | --- |
|
|
194
|
+
| SSR | `output: "server"` + the draft routes above + `BCMS_DRAFT_SECRET` + a `content:read:draft` `BCMS_API_KEY` | The loaders read the draft on every request, so hand-written layouts preview too |
|
|
195
|
+
| Static | Any static build, with the page body rendered through `<BcmsLiveBlocks>` | The editor pushes the draft block tree to the island over `postMessage`. No fetch, no key in the page. Only the `BcmsLiveBlocks` region updates |
|
|
196
|
+
|
|
197
|
+
## Headless projects (your own host)
|
|
198
|
+
|
|
199
|
+
BetterCMS never builds, releases or deploys a headless project. Any build, artifact or deploy
|
|
200
|
+
request for one returns **409 `HEADLESS_NO_BUILD`**.
|
|
201
|
+
|
|
202
|
+
- **Deploy:** push to your repository. Your provider (Vercel, Netlify or Cloudflare Pages)
|
|
203
|
+
builds it. For fresh content on publish, point the revalidation webhook at the provider's
|
|
204
|
+
rebuild hook.
|
|
205
|
+
- **Draft:** use your framework's draft route on the provider's **preview** deployment URL.
|
|
206
|
+
For Astro that is the SSR lane above: `output: "server"`, the injected
|
|
207
|
+
`/api/bcms/draft/*` routes, `BCMS_DRAFT_SECRET`, and a `BCMS_API_KEY` carrying
|
|
208
|
+
`content:read:draft`. Keep the draft key off production.
|
|
@@ -16,11 +16,10 @@
|
|
|
16
16
|
interface Props {
|
|
17
17
|
studioUrl?: string;
|
|
18
18
|
}
|
|
19
|
-
// `
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
const { studioUrl = "https://demo.bettercms.ai" } = Astro.props;
|
|
19
|
+
// `bettercms.ai` is the studio origin — the one the dashboard's integration snippets hand out
|
|
20
|
+
// as `PUBLIC_BCMS_STUDIO_URL`, and the default of @bettercms-ai/next's <VisualEditing>.
|
|
21
|
+
// `demo.bettercms.ai` is a stale alias; `dashboard.bettercms.ai` resolves but 404s.
|
|
22
|
+
const { studioUrl = "https://bettercms.ai" } = Astro.props;
|
|
24
23
|
const src = `${studioUrl.replace(/\/+$/, "")}/bcms-visual-editing.js`;
|
|
25
24
|
---
|
|
26
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bettercms-ai/astro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The BetterCMS adapter for Astro — a `bettercms()` integration, a `bettercms:client` virtual module, typed content loaders, draft preview, and native .astro rendering components.",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@bettercms-ai/image-url": "^0.3.0",
|
|
57
|
-
"@bettercms-ai/sdk": "^1.
|
|
57
|
+
"@bettercms-ai/sdk": "^1.20.0",
|
|
58
58
|
"@bettercms-ai/types": "^1.11.0",
|
|
59
59
|
"@bettercms-ai/ui": "^0.7.0",
|
|
60
60
|
"@bettercms-ai/richtext": "^0.3.0",
|
|
61
|
-
"@bettercms-ai/next": "^0.
|
|
61
|
+
"@bettercms-ai/next": "^0.13.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"astro": ">=4",
|