inlaycms 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +18 -709
  2. package/assets/admin/admin.css +1 -1
  3. package/assets/admin/editor.js +63 -46
  4. package/assets/site/consent.js +1 -0
  5. package/dist/adapters/admin/context.d.ts +1 -1
  6. package/dist/adapters/admin/context.js +1 -0
  7. package/dist/adapters/admin/routes.d.ts +2 -0
  8. package/dist/adapters/admin/routes.js +2 -0
  9. package/dist/adapters/admin/screens/backups.js +2 -2
  10. package/dist/adapters/admin/screens/editor.js +2 -1
  11. package/dist/adapters/admin/screens/integrations.d.ts +4 -0
  12. package/dist/adapters/admin/screens/integrations.js +140 -0
  13. package/dist/adapters/admin/screens/lists.js +2 -1
  14. package/dist/adapters/admin/screens/releases.js +1 -1
  15. package/dist/adapters/admin/views/layout.js +3 -0
  16. package/dist/adapters/cli/bin.js +8 -3
  17. package/dist/adapters/mcp/tools/read.js +17 -2
  18. package/dist/adapters/mcp/tools/write.js +4 -0
  19. package/dist/adapters/site/cache.d.ts +8 -2
  20. package/dist/adapters/site/cache.js +13 -4
  21. package/dist/adapters/site/code-files.d.ts +44 -0
  22. package/dist/adapters/site/code-files.js +212 -0
  23. package/dist/adapters/site/consent.d.ts +9 -0
  24. package/dist/adapters/site/consent.js +26 -0
  25. package/dist/adapters/site/context.d.ts +5 -0
  26. package/dist/adapters/site/context.js +97 -20
  27. package/dist/adapters/site/csp.d.ts +11 -0
  28. package/dist/adapters/site/csp.js +36 -0
  29. package/dist/adapters/site/head.js +1 -14
  30. package/dist/adapters/site/headers.d.ts +5 -2
  31. package/dist/adapters/site/headers.js +13 -6
  32. package/dist/adapters/site/integrations.d.ts +48 -0
  33. package/dist/adapters/site/integrations.js +118 -0
  34. package/dist/adapters/site/media-routes.d.ts +2 -0
  35. package/dist/adapters/site/media-routes.js +2 -1
  36. package/dist/adapters/site/plugin.d.ts +2 -0
  37. package/dist/adapters/site/plugin.js +64 -34
  38. package/dist/adapters/site/render.d.ts +31 -14
  39. package/dist/adapters/site/render.js +26 -5
  40. package/dist/adapters/site/routes.d.ts +3 -0
  41. package/dist/adapters/site/routes.js +7 -3
  42. package/dist/adapters/site/scripts.d.ts +6 -0
  43. package/dist/adapters/site/scripts.js +27 -0
  44. package/dist/core/auth/roles.d.ts +1 -1
  45. package/dist/core/auth/roles.js +1 -0
  46. package/dist/core/boot.d.ts +2 -0
  47. package/dist/core/boot.js +3 -0
  48. package/dist/core/content/shipped-input.js +1 -2
  49. package/dist/core/content/validate.d.ts +7 -0
  50. package/dist/core/content/validate.js +24 -1
  51. package/dist/core/core.d.ts +29 -0
  52. package/dist/core/core.js +10 -2
  53. package/dist/core/db/migrate.js +2 -0
  54. package/dist/core/db/migrations/0008_integrations.d.ts +3 -0
  55. package/dist/core/db/migrations/0008_integrations.js +11 -0
  56. package/dist/core/db/schema.d.ts +11 -0
  57. package/dist/core/export/export.js +4 -0
  58. package/dist/core/export/format.d.ts +11 -0
  59. package/dist/core/export/format.js +4 -0
  60. package/dist/core/export/import.js +2 -1
  61. package/dist/core/export/replace.d.ts +6 -1
  62. package/dist/core/export/replace.js +4 -1
  63. package/dist/core/export/report.d.ts +6 -0
  64. package/dist/core/export/report.js +7 -0
  65. package/dist/core/fields/builtins.d.ts +4 -0
  66. package/dist/core/fields/builtins.js +11 -1
  67. package/dist/core/fields/widgets.js +5 -1
  68. package/dist/core/integrations/integrations.d.ts +32 -0
  69. package/dist/core/integrations/integrations.js +80 -0
  70. package/dist/core/integrations/warnings.d.ts +4 -0
  71. package/dist/core/integrations/warnings.js +29 -0
  72. package/dist/core/media/store.d.ts +2 -0
  73. package/dist/core/media/store.js +17 -1
  74. package/dist/core/media/variants.d.ts +14 -0
  75. package/dist/core/media/variants.js +54 -0
  76. package/dist/core/messages/en.d.ts +73 -0
  77. package/dist/core/messages/en.js +73 -0
  78. package/dist/core/registry/code-image.d.ts +16 -0
  79. package/dist/core/registry/code-image.js +13 -0
  80. package/dist/core/registry/define.d.ts +7 -0
  81. package/dist/core/registry/define.js +2 -0
  82. package/dist/core/registry/designed.d.ts +6 -0
  83. package/dist/core/registry/designed.js +8 -0
  84. package/dist/core/registry/integration.d.ts +48 -0
  85. package/dist/core/registry/integration.js +29 -0
  86. package/dist/core/registry/js.d.ts +9 -0
  87. package/dist/core/registry/js.js +39 -0
  88. package/dist/core/registry/registry.js +46 -0
  89. package/dist/core/registry/render.d.ts +39 -4
  90. package/dist/core/release/bundle.d.ts +3 -1
  91. package/dist/core/release/bundle.js +169 -11
  92. package/dist/core/release/manifest.d.ts +29 -1
  93. package/dist/core/release/manifest.js +26 -1
  94. package/dist/core/release/pack.js +13 -2
  95. package/dist/core/release/pointer.js +14 -3
  96. package/dist/core/release/read.d.ts +2 -0
  97. package/dist/core/release/read.js +1 -0
  98. package/dist/core/report.d.ts +3 -0
  99. package/dist/core/richtext/headings.d.ts +10 -0
  100. package/dist/core/richtext/headings.js +37 -0
  101. package/dist/core/richtext/html.d.ts +10 -1
  102. package/dist/core/richtext/html.js +17 -6
  103. package/dist/core/richtext/markdown-text.d.ts +24 -0
  104. package/dist/core/richtext/markdown-text.js +38 -0
  105. package/dist/core/richtext/markdown.js +44 -3
  106. package/dist/core/richtext/schema.d.ts +12 -3
  107. package/dist/core/richtext/schema.js +34 -0
  108. package/dist/core/site/live.d.ts +6 -0
  109. package/dist/core/site/live.js +25 -0
  110. package/dist/host/app.d.ts +2 -0
  111. package/dist/host/app.js +1 -0
  112. package/dist/host/diff.d.ts +11 -0
  113. package/dist/host/diff.js +40 -0
  114. package/dist/host/ipc.d.ts +2 -0
  115. package/dist/host/ipc.js +5 -1
  116. package/dist/host/preview-worker.js +2 -2
  117. package/dist/host/primary.js +15 -4
  118. package/dist/host/push.js +1 -1
  119. package/dist/host/serve.js +1 -1
  120. package/dist/host/store.d.ts +1 -2
  121. package/dist/host/store.js +32 -6
  122. package/dist/image-modules.d.ts +29 -0
  123. package/dist/image-modules.js +1 -0
  124. package/dist/index.d.ts +7 -1
  125. package/dist/index.js +4 -0
  126. package/dist/site.d.ts +8 -1
  127. package/dist/site.js +5 -0
  128. package/package.json +5 -1
package/README.md CHANGED
@@ -2,37 +2,25 @@
2
2
 
3
3
  Inlay is a CMS for content sites. You build the site in code: its templates, the blocks they're made of, its collections, site-wide content and languages. The site's owner fills in the content, in the slots you cut for it. Everything lives in one SQLite file. Inlay is the whole server: you pack the site into a signed release, push it to a host running `inlaycms serve`, preview it on the live content and activate it when it's ready.
4
4
 
5
- ## Why we made it
5
+ It's built for owners who run their site mostly by talking to an AI assistant, without ever being able to break the design the developer built:
6
6
 
7
- The CMSs we tried all sat at the wrong point:
8
-
9
- - **Schema in the database** (WordPress-style systems, Directus). The content model is reshaped at runtime, so rebuilding a site from code means replaying seed files, and editors and plugins can move the walls.
10
- - **App frameworks** (Payload, Strapi). The right model, with the schema in code, but heavy: you end up building a whole app.
11
- - **Git- or file-based** (Keystatic, Tina, Decap). Also the right model, but too light: there's no real server, so no history, no sign-in, and nothing for an assistant to talk to.
12
-
13
- Inlay sits between them. Templates and schema are code, the database only ever holds content, and the server is real enough to provide history, drafts and publishing, accounts, backups and an MCP server.
14
-
15
- That last one matters most. We expect most owners to run their site by talking to an AI assistant: "change the home page headline", "write a post from these notes", "translate About into Spanish". The admin is for looking, checking and fixing, and has full hand-editing as the fallback. The goal is a site a non-technical owner can run mostly through an assistant, without ever being able to break the design the developer built.
16
-
17
- A few things follow from that:
18
-
19
- - **No page builder.** Editors fill slots. They never rearrange the layout or add sections, so every arrangement a page can take is one the developer designed.
20
- - **Problems are caught before deploy.** `inlaycms check` tells you whether the content fits new site code before you ship it, rather than a running site finding out.
21
- - **The site belongs to its owner.** It runs on their server, with their data and their backups, and the export format is documented well enough to read without Inlay.
7
+ - **No page builder.** Editors fill slots, so every arrangement a page can take is one the developer designed.
8
+ - **Problems are caught before deploy.** `inlaycms check` tells you whether the content fits new site code before you ship it.
9
+ - **The site belongs to its owner.** It runs on their server, with their data and their backups, and a documented export format.
22
10
  - **One install per site.** An agency with ten clients runs ten installs, and can come back months later to push an update.
23
11
 
12
+ Read [why we made it](https://donstephan.github.io/inlaycms/why).
13
+
24
14
  ## Quickstart
25
15
 
26
- Inlay needs Node 24 or newer, and Fastify 5. Or skip Node altogether and run every command through the Docker image: see [Without Node: the Docker image](#without-node-the-docker-image).
16
+ Inlay needs Node 24 or newer, and Fastify 5. Or skip Node altogether and run every command through the Docker image: see [Without Node: the Docker image](https://donstephan.github.io/inlaycms/docs/docker).
27
17
 
28
18
  ```sh
29
19
  npm install inlaycms fastify
30
20
  npm install --save-dev typescript
31
21
  ```
32
22
 
33
- TypeScript is optional: `inlaycms pack` type-checks the site when it's installed. The CLI loads the site's TypeScript and JSX itself, so no loader such as tsx is needed.
34
-
35
- Templates render with JSX, so point your `tsconfig.json` at Inlay's runtime. Inlay bundles the site's code itself, so type-check it as bundled code, which also needs no `"type": "module"` in `package.json`:
23
+ Templates render with JSX, so point your `tsconfig.json` at Inlay's runtime:
36
24
 
37
25
  ```json
38
26
  {
@@ -60,6 +48,7 @@ const Page = defineTemplate({
60
48
  }),
61
49
  render: ({ fields }, ctx) => (
62
50
  <html lang={ctx.locale}>
51
+ <head><title>{fields.title}</title></head>
63
52
  <body>
64
53
  <h1>{fields.title}</h1>
65
54
  {ctx.richText(fields.body)}
@@ -89,8 +78,6 @@ export const site = defineSite({
89
78
  })
90
79
  ```
91
80
 
92
- Labels and `help` are what editors and their assistants see, so write them for the owner, not for yourself. `content` is the content shipped with the site: `defineContent` for a singleton or global, `defineEntries` for a collection's entries, each with a stable `key`. Bump an `edition` to replace what the client has with the new shipped content; an equal or lower edition leaves their edits alone. Collections, globals, blocks, slots and more languages work the same way. `example/site.tsx` uses all of them.
93
-
94
81
  Point Inlay at it with `inlay.config.ts`, next to `site.tsx`:
95
82
 
96
83
  ```ts
@@ -100,703 +87,25 @@ import { site } from './site.js'
100
87
  export default defineConfig({ site })
101
88
  ```
102
89
 
103
- Then run it from source:
90
+ Then run it from source, and open `http://localhost:3000/admin` to create the owner account:
104
91
 
105
92
  ```sh
106
93
  npx inlaycms dev
107
94
  ```
108
95
 
109
- `inlaycms dev` serves the site at `http://localhost:3000` (`--port` changes the port, `--config` the config file) and restarts it whenever you save a file in the site's folder. Its database, media and backups go in `data/` next to the config file; keep that folder out of git. It needs no settings: `INLAY_BASE_URL` defaults to the local address and `INLAY_SECRET` to a fixed development value, and any other `INLAY_` setting from [Running a host](#running-a-host) can still be set. Set the secrets the site declares in the environment, as on a host.
110
-
111
- On each start, Inlay brings the database up to date and applies the shipped content: documents that don't exist yet are created, and ones with a newer edition are replaced. Stored content is read against the current code: values that fit are used and the rest take their defaults, so a schema change never stops the site from starting. Open `http://localhost:3000` for the site and `http://localhost:3000/admin` to create the owner account.
112
-
113
- To put the site online, pack it into a release and run it on a host with `inlaycms serve`: see [Packing a release](#packing-a-release) and [Running a host](#running-a-host).
114
-
115
- ### The CLI
116
-
117
- The commands that work on a site's code or database (`check`, `backup`, `export`, `import`, `restore-backup`, `create-owner`, `create-token`, `reset-password`, `keygen`, `pack`, `push`) read `inlay.config.ts` (or `.js`, `.mjs`) in the current directory, or the file given with `--config`. On a host, which has no config file, `backup`, `export`, `import`, `restore-backup`, `create-owner`, `create-token` and `reset-password` work on its data folder instead (see [Running a host](#running-a-host)):
118
-
119
- ```ts
120
- import { defineConfig } from 'inlaycms/site'
121
- import { site } from './site.js'
122
-
123
- export default defineConfig({ site, db: './data/inlay.db' })
124
- ```
125
-
126
- Paths in it are relative to the config file.
127
-
128
- ```sh
129
- npx inlaycms check
130
- ```
131
-
132
- Run `inlaycms check` before every deploy. When the config's database doesn't exist yet, as in a fresh checkout or CI, it checks the code alone; `--db` names a database it must check against. `npx inlaycms --help` lists every command and option.
133
-
134
- ### Packing a release
135
-
136
- A release is your whole site in one signed file: the bundled site code, the shipped content and its images, and the files in `public/`. Secret values are never in it; it lists only the secret names the site declares (`secrets` in `defineSite`), and the host provides the values.
137
-
138
- Make a signing key pair once, on the machine you release from:
139
-
140
- ```sh
141
- npx inlaycms keygen --out keys --name release
142
- ```
143
-
144
- This writes `keys/release.key` (the private key: keep it secret and out of the repo) and `keys/release.pub`, a one-line public key such as `ed25519:...`. Give the public key to every host that should run your releases: a host only accepts a release whose signature verifies against one of its trusted keys, and refuses it before reading anything else in it.
145
-
146
- Then pack:
147
-
148
- ```sh
149
- npx inlaycms pack --key keys/release.key --out release.tgz
150
- ```
151
-
152
- `pack` type-checks the site first when a `tsconfig.json` sits next to the config (`--no-typecheck` skips that). The key can also come from `INLAY_SIGNING_KEY`, as the key itself or a path to it.
153
-
154
- Site code imports Inlay from `inlaycms/site` (and JSX from `inlaycms/jsx-runtime`), never from `inlaycms` itself, which is the host's side. `pack` refuses a site that imports anything else it can't bundle, such as Node's built-in modules or `inlaycms`, and site code that uses `process`, `require`, `eval` or `Function` (also as `globalThis.eval` and the like) or an `import()` of a computed name. An `import()` of a template under a relative folder, such as ``import(`./locales/${lang}.js`)``, is fine: every matching file is bundled. Those checks catch mistakes; they don't make a release safe to run. What makes a release trusted is its signature: a host runs only releases signed with a key it trusts, so trust a key only if you trust everyone who can sign with it.
155
-
156
- The example site in `example/` commits a key pair in `example/keys/` (`dev.key`, `dev.pub`) so `pnpm run example:pack` works out of the box. It is for development only: never trust `example/keys/dev.pub` on a real host.
157
-
158
- ### Running a host
159
-
160
- `inlaycms serve` runs the site and the admin from a data folder, with its settings in `INLAY_` environment variables: `INLAY_DATA_DIR` (the folder holding `inlay.db`, `media/`, `backups/` and `releases/`), `INLAY_BASE_URL`, `INLAY_SECRET` (32 characters or more) and `INLAY_TRUSTED_KEYS` (the public keys whose releases it accepts; or `INLAY_TRUSTED_KEYS_FILE`). The secrets a release declares are read from the host's environment by name. The optional ones are `INLAY_PORT` (default 3000), `INLAY_HOST` (default `0.0.0.0`), `INLAY_RATE_LIMIT` (`on` or `off`), `INLAY_TRUST_PROXY` (the reverse proxies to trust; see [Behind a reverse proxy](#behind-a-reverse-proxy)), `INLAY_UPLOAD_MAX_BYTES`, `INLAY_BACKUP_KEEP`, `INLAY_PUBLIC_MAX_AGE`, `INLAY_CDN_MAX_AGE` and `INLAY_CDN_STALE_IF_ERROR`.
161
-
162
- ```sh
163
- export INLAY_DATA_DIR=/srv/inlay INLAY_BASE_URL=https://example.com
164
- export INLAY_SECRET="$(cat /etc/inlay/secret)" INLAY_TRUSTED_KEYS="$(cat release.pub)"
165
- npx inlaycms activate release.tgz # the first release, while the server is stopped
166
- npx inlaycms serve
167
- ```
168
-
169
- `serve` runs the live release in a worker process and keeps the database untouched at start: shipped content is applied only when a release is activated. With no release yet, the site shows a plain "no site yet" page (status 200, not indexed) and the admin works. When a live site can't be served (its release is missing from the data folder, needs another version of Inlay, or keeps crashing), visitors get a "temporarily unavailable" page instead, with status 503 and `Retry-After`, so search engines keep the site; the admin still works. A worker that crashes is started again. On SIGTERM or SIGINT it finishes the requests in flight, closes the database and exits.
170
-
171
- The Docker image, `ghcr.io/donstephan/inlaycms` (also the CLI: see [Without Node: the Docker image](#without-node-the-docker-image)), runs `inlaycms serve` with `INLAY_DATA_DIR=/data` on a volume and port 3000. With `INLAY_SECRET` and `INLAY_TRUSTED_KEYS` set in your shell:
172
-
173
- ```sh
174
- docker run -d --name inlay --restart unless-stopped -p 3000:3000 -v inlay-data:/data \
175
- -e INLAY_SECRET -e INLAY_TRUSTED_KEYS ghcr.io/donstephan/inlaycms
176
- ```
177
-
178
- Run `inlaycms activate` in a container on the same volume to give it its first release. The release file must be inside the container, so mount it: `docker run --rm -v inlay-data:/data -v "$PWD/release.tgz:/release.tgz:ro" ghcr.io/donstephan/inlaycms inlaycms activate /release.tgz`. The image holds the packed `inlaycms` with its production dependencies only, with `inlaycms` on the `PATH`. Every release of Inlay is tagged with its version (`ghcr.io/donstephan/inlaycms:0.2.0`, and `0.2` for the newest patch of 0.2); `latest` is the newest release. In this repository, `docker compose up serve` builds the image from source and runs it.
179
-
180
- To give a host its first release, or to make a release live while it is stopped:
181
-
182
- ```sh
183
- npx inlaycms activate release.tgz [--data <dir>] [--name <name>]
184
- npx inlaycms activate <release-id>
185
- npx inlaycms releases [--data <dir>] [--json]
186
- ```
187
-
188
- `activate` with a file stores the release (its signature must verify against a trusted key) and makes it live; with an ID it makes a release already on the host live again, which is how you roll back. A release made for another version of Inlay is refused. It applies the release's shipped content, runs its migration functions and prints what it did; a backup is taken first when the site has content (and before the database structure is updated, when this version of Inlay needs to). A shipped slug or path that is already taken doesn't stop it: the document keeps the slug and path it had (a new one gets a free slug and no path of its own), and a warning says so; `inlaycms check` reports these as problems. Activation writes its changes in one database transaction that locks the database for writing from start to end; the media files the shipped content names are stored before it starts, but the release's migration functions run inside it. While it runs, saves in the admin wait up to 5 seconds and then fail, so keep migration functions quick and activate when few people are editing. It uses the same environment as `serve`, and `--data` stands in for `INLAY_DATA_DIR`. Stop the server first: a running server wouldn't see the change, so `activate` refuses while the database looks in use (see [Backups from the command line](#backups-from-the-command-line)); add `--server-stopped` if the server crashed and left files behind. `releases` lists every release on the host with its ID, name, state and when it was pushed and made live; it needs only the data folder and works while the server runs.
189
-
190
- On a host, `backup`, `export`, `import`, `restore-backup`, `create-owner`, `create-token` and `reset-password` take the data folder from `--data <dir>`, or from `INLAY_DATA_DIR` when there's no config file in the current directory, and need no config file. When both are there, the command says which one it uses. `export`, `import` and `create-owner` use the site of the live release; `import` refuses when there is none.
191
-
192
- ### Deploying
193
-
194
- Once a host is running, send it releases from your machine or CI with `inlaycms push`, which needs a push token: an owner's API key that may push releases. An owner makes one in the admin (an API key with "Can push releases" turned on), or on the host with the CLI, which prints the key once (alone on standard output, so a script can capture it) and works whether the server is running or not:
195
-
196
- ```sh
197
- npx inlaycms create-token --email owner@example.com --name ci --push [--data <dir>]
198
- ```
199
-
200
- Then push:
201
-
202
- ```sh
203
- export INLAY_PUSH_TOKEN=... # or --token <token>
204
- npx inlaycms push https://example.com --key keys/release.key
205
- ```
206
-
207
- `push` packs the site into a temporary file (as `pack` does, type check included; `--key` or `INLAY_SIGNING_KEY`, `--name`, `--no-typecheck`), or sends the release file given with `--file`. The host checks its signature, the Inlay version and the secrets it needs, keeps it as staged (not live yet) and answers with what it would change, which `push` prints one line per item: content types, slots, languages and fields added or removed (removed content is hidden, never deleted), the published documents a new required field leaves with a gap, the shipped documents it will create or replace, migration functions, routes, code redirects and secrets. It also warns about shipped content that changed while its edition didn't ("`home` content changed but is still edition 2; it won't be applied"): bump the edition to have it applied. Several releases can be staged at once.
208
-
209
- A staged release also gets a preview link, which `push` prints: opening it shows the whole site as that release would, on a copy of the live content, for 24 hours, in that browser only. Nothing can be changed in a preview; the admin stays the live site's. Exit the preview at `/_inlay/preview/exit`.
210
-
211
- Owners can do the same from the admin's **Releases** screen (see [Releases](#releases)): upload a release file, see what it would change, preview it, activate it and delete releases that aren't live.
212
-
213
- A push runs the release's code on the host straight away, a dry run too: the host starts the release's preview to work out what it would change in your content. So the signature is what stands between the host and the code it runs: only trust keys whose private half you control, and keep that half out of the repository.
214
-
215
- - `--dry-run` reports the same and keeps nothing on the host. It can't be combined with `--activate`.
216
- - `--activate` makes the release live right after: the host starts the new release next to the old one and switches over once it is ready, so no request is refused, then prints what activating did. If the connection drops or a proxy gives up before the answer, the push may still have gone through: `push` says so, and `inlaycms releases <host>` shows where things stand.
217
- - `inlaycms activate <host> <id>` makes a staged or earlier release live. That is also how you roll back: activate the release that was live before.
218
- - `inlaycms releases <host> [--json]` lists the releases on the host with their IDs and states.
219
-
220
- All three take the token from `--token` or `INLAY_PUSH_TOKEN`. They exit 1 when the host refuses (printing its reason, such as a release signed with a key it doesn't trust, or a token that may not push) and 2 when the token, signing key or release file is missing. A host address starts with `http://` or `https://`; without one, `activate` and `releases` work offline on the data folder as described above. The token is only sent over plain `http://` to this computer (`localhost`, `127.0.0.1`, `[::1]`), unless you add `--insecure`; and it is never sent on to another address the host redirects to.
221
-
222
- ### Type-checking your site
223
-
224
- If your site's `tsconfig.json` has `skipLibCheck: false`, `tsc` reports one error from better-auth's own type files, which Inlay depends on: `Cannot find module 'bun:sqlite'`. It comes from types for running under Bun, has no effect on a Node site, and isn't something your code or Inlay can fix. Leave `skipLibCheck` on (`true`), or ignore that one error.
225
-
226
- ### Testing your site
227
-
228
- `inlaycms/testing` boots your site the way `inlaycms dev` does, with its shipped content, in a temporary folder, and answers requests in process: no ports, no child processes, and any test runner works (`fastify` is already a peer dependency). `createTestSite(options)` takes:
229
-
230
- - `config`: your `inlay.config.ts`, as a path relative to the working directory or a `file:` URL.
231
- - `baseUrl`: used for canonical, Open Graph and sitemap URLs. Default `http://localhost`.
232
- - `secrets`: values for the secrets your site declares.
233
- - `fetch`: what routes get as `ctx.fetch`. Default: the global `fetch`.
234
- - `now`: the clock. Default: real time.
235
-
236
- It returns `{ fetch(path, init?), paths(), close() }`. Here are four checks written for vitest:
237
-
238
- ```ts
239
- import { createTestSite, type TestSite } from 'inlaycms/testing'
240
- import { afterAll, beforeAll, expect, it } from 'vitest'
241
-
242
- let site: TestSite
243
- beforeAll(async () => {
244
- site = await createTestSite({ config: './inlay.config.ts', baseUrl: 'https://example.com' })
245
- })
246
- afterAll(() => site.close())
247
-
248
- it('serves every sitemap page with one <h1> and JSON-LD', async () => {
249
- for (const path of await site.paths()) {
250
- const res = await site.fetch(path)
251
- expect(res.status, path).toBe(200)
252
- const html = await res.text()
253
- expect(html.match(/<h1[\s>]/g)?.length, path).toBe(1)
254
- expect(html, path).toContain('<script type="application/ld+json">')
255
- }
256
- })
257
-
258
- it('sends old URLs to their new pages', async () => {
259
- const res = await site.fetch('/About-Us')
260
- expect(res.status).toBe(301)
261
- expect(res.headers.get('location')).toBe('/about')
262
- })
263
-
264
- it('answers unknown paths with 404', async () => {
265
- expect((await site.fetch('/no-such-page')).status).toBe(404)
266
- })
267
- ```
268
-
269
- The JSON-LD check applies to sites that add JSON-LD through `ctx.head`; Inlay doesn't add it on its own. A site whose imports `inlaycms pack` would refuse makes `createTestSite` throw. `fetch` takes a path that starts with `/` and a body that is a string or `URLSearchParams`; HEAD, 204, 205 and 304 answers have no body. Redirects aren't followed. `paths()` is the sitemap's paths, code routes with `sitemap: true` included. `secrets` and `fetch` are how a route's outgoing requests are tested. Each test site is independent.
270
-
271
- ## Content model
272
-
273
- What a site's fields can hold, beyond plain text and the basics of `f.richText`.
274
-
275
- ### Inline code
276
-
277
- Rich text and inline text hold inline code, on by default: a command, a file name or a placeholder, shown in a monospace font. In Markdown it is text between backticks (`` Run `npm test` first ``); a span holding a backtick is fenced with more of them (``` ``a`b`` ```). It renders as `<code>`. Code can go inside a link (``[`npm test`](/docs/testing)``) and in table cells, but it can't be bold or italic: Markdown that puts code inside bold or italic text is refused with the line it is on. Code blocks aren't supported. To leave code out of a field, list its `features` without `'code'`.
278
-
279
- ### Tables
280
-
281
- Rich text holds tables, on by default. In Markdown (what assistants send and get back, and what shipped content is written in) a table is a GitHub-style table:
282
-
283
- ```md
284
- | Plan | Price |
285
- | --- | --- |
286
- | **Pro** | [Buy](https://example.com/buy) |
287
- | *Lite* | free |
288
- ```
289
-
290
- The first row is always the header row. A cell holds one line of text with bold, italic, code and links; images and line breaks can't go in a cell, and a table can't go inside a list or a quote. Write a `|` inside a cell as `\|`. Alignment markers (`:---:`) are accepted and dropped, short rows are padded with empty cells, and cells past the header's width are dropped. To leave tables out of a field, list its `features` without `'table'`: `f.richText({ label: 'Body', features: ['bold', 'italic', 'link'] })`.
291
-
292
- A table renders as plain HTML with no attributes, for your site's CSS to style: `<table>`, a `<thead>` holding the header row's `<th>` cells, and a `<tbody>` of `<td>` cells when there are rows below the header.
293
-
294
- ### Inline text
295
-
296
- `f.inlineText({ label, maxLength })` is one line of formatted text, for a headline or a tagline that may need a word in bold or a link: bold, italic, code and links, and nothing else. It is stored as rich text holding a single paragraph, and the admin edits it on one line. `maxLength` counts the characters of the text, not of its formatting.
297
-
298
- Assistants and shipped content write it as one line of Markdown, such as `'**Big** news, see [the plans](inlay:key/pages/pricing)'`. A blank line (a second paragraph), a heading, a list, a line break or an image is refused.
299
-
300
- In a template, `ctx.inline(fields.headline)` renders the text without a `<p>`, so it fits inside an `<h1>`; a string is escaped, and `null` gives nothing. `ctx.richText` renders it with its `<p>`. `plainText(fields.headline)`, imported from `inlaycms/site`, gives the text without its formatting, for a `<title>` or an `alt`.
301
-
302
- An inline-text field can't be a collection's `titleField`, which must be plain text. Keep a plain `f.text` title beside it:
303
-
304
- ```ts
305
- fields: z.object({
306
- title: f.text({ label: 'Title' }),
307
- headline: f.inlineText({ label: 'Headline', maxLength: 80 }),
308
- }),
309
- ```
310
-
311
- ### Publish dates
312
-
313
- `entry.publishedAt` (from `ctx.entries` and `ctx.query`) and `page.publishedAt` (in a template) are when Inlay first published the document, as an ISO time, or `null` for a draft that was never published (seen in preview) and for a route's page. It is set once and never moves, however often the document is edited or republished. A page of `ogType: 'article'` gets it as `article:published_time`.
314
-
315
- `ctx.query('posts', { sort: 'published' })` lists the newest first-publish first, with never-published entries last; ties keep the newest-created first. A post migrated from another site keeps its original date in its own `f.date` field, which you can sort by with `{ sort: { field: 'date', direction: 'desc' } }`.
316
-
317
- ### Multi-select
318
-
319
- `f.multiSelect(options, { label, min, max })` picks any number of a fixed list of options, such as tags:
320
-
321
- ```ts
322
- tags: f.multiSelect(['green', 'blue', 'red'] as const, { label: 'Tags', min: 0, max: 3 }),
323
- ```
324
-
325
- The value is an array of the options, saved in the options' order without duplicates, and `[]` when nothing is chosen. A draft may hold any number of them; `min` and `max` are checked when it is published. The admin shows one checkbox per option, labelled with the option itself, as `f.select` does. Assistants read and write the array as it is.
326
-
327
- To list the entries with a tag, filter them in a template:
328
-
329
- ```ts
330
- const faqs = await ctx.query('faqs', { filter: (e) => e.fields.tags.includes('green') })
331
- ```
332
-
333
- An option you remove from the code drops out of the value when it is read, in the admin, on the site and over MCP, while the other options stay; the next save stores the value without it. Export keeps what is stored, so a backup loses nothing.
334
-
335
- ### Nested lists
336
-
337
- Lists can hold lists, to any depth, and the admin shows every level with its own add, remove and move buttons. A mega menu is three deep: menu items hold columns, and columns hold links.
338
-
339
- ```ts
340
- const Menu = defineTemplate({
341
- name: 'menu',
342
- label: 'Menu',
343
- fields: z.object({
344
- menu: f.list(
345
- z.object({
346
- title: f.text({ label: 'Title' }),
347
- columns: f.list(
348
- z.object({
349
- heading: f.text({ label: 'Heading' }),
350
- links: f.list(
351
- z.object({
352
- label: f.text({ label: 'Label' }),
353
- href: f.text({ label: 'Address' }),
354
- description: f.textarea({ label: 'Description' }).optional(),
355
- }),
356
- { label: 'Links', itemLabel: 'Link' },
357
- ),
358
- }),
359
- { label: 'Columns', itemLabel: 'Column' },
360
- ),
361
- }),
362
- { label: 'Menu', itemLabel: 'Menu item' },
363
- ),
364
- promo: f.group({ text: f.text({ label: 'Text' }), link: f.link({ label: 'Link' }) }, { label: 'Promo' }),
365
- }),
366
- })
367
- ```
368
-
369
- A template loops over each level:
370
-
371
- ```tsx
372
- <nav>
373
- {fields.menu.map((item) => (
374
- <div>
375
- <span>{item.title}</span>
376
- {item.columns.map((column) => (
377
- <section>
378
- <h3>{column.heading}</h3>
379
- <ul>
380
- {column.links.map((link) => (
381
- <li><a href={link.href}>{link.label}</a></li>
382
- ))}
383
- </ul>
384
- </section>
385
- ))}
386
- </div>
387
- ))}
388
- </nav>
389
- ```
390
-
391
- ### Images in shipped content
392
-
393
- Rich text in shipped content can show images from the site's folder (the folder holding `inlay.config.ts`). Name each one by its path from that folder, or by a `file:` URL:
394
-
395
- ```ts
396
- defineContent('about', {
397
- edition: 1,
398
- content: {
399
- en: {
400
- fields: {
401
- body: [
402
- '![Our team](images/team.png)',
403
- '![The 2026 chart](<images/my chart (1).png>)',
404
- `![Logo](${new URL('./images/logo.png', import.meta.url)})`,
405
- ].join('\n\n'),
406
- },
407
- },
408
- },
409
- })
410
- ```
411
-
412
- The alt text is kept. Write a path with spaces or parentheses inside `<…>`. Each file is checked like an upload and added to the media library once, however many documents or ways of writing its path name it; `images/team.png`, `./images/team.png` and its `file:` URL are the same image. `inlaycms pack` puts the files in the release, so a host shows them without the site's folder.
413
-
414
- Refused, each with the line it is on: an image on another website (`https://…`; a release never downloads anything, so download it into the folder), a path starting with `/` (that is an address on the site, not a file), a file outside the site's folder (`../`, or a link that leads out of it), a file that doesn't exist, and a file that isn't an image. An image already in the media library can still be named as `inlay:media/<id>`.
415
-
416
- ### Markdown files
417
-
418
- Long rich text, such as a blog post, can live in its own `.md` file. Import it, and the import is the file's text:
419
-
420
- ```ts
421
- import hello from './posts/hello.md'
422
-
423
- defineEntries('posts', [
424
- { key: 'hello', edition: 1, content: { en: { slug: 'hello', fields: { title: 'Hello', body: hello } } } },
425
- ])
426
- ```
427
-
428
- The whole file is the Markdown: there is no front matter, so the title, dates and other fields stay in your code. An image path in the file is relative to the file itself, so `posts/hello.md` names `posts/chart.png` as `![A chart](chart.png)` or `![A chart](./chart.png)`. The image must still be inside the site's folder, and is checked and packed as above. Write each image inline: an image written as a reference (`![A chart][chart]` with `[chart]: chart.png` further down) is refused, and `inlaycms dev`, `check` and `pack` name the file and line. The types for `.md` imports come with `inlaycms/site`, so TypeScript knows the import is a string.
429
-
430
- ## Without Node: the Docker image
431
-
432
- The Inlay image holds the whole CLI as well as the host, so a computer with Docker needs no Node or npm. It's published on GitHub's container registry as `ghcr.io/donstephan/inlaycms`. Install the `inlaycms` script it carries:
433
-
434
- ```sh
435
- docker run --rm ghcr.io/donstephan/inlaycms cat /opt/inlaycms/wrapper/inlaycms > ~/.local/bin/inlaycms
436
- chmod +x ~/.local/bin/inlaycms
437
- ```
438
-
439
- Then use `inlaycms` in a site's folder as anywhere else in this README: `inlaycms dev`, `inlaycms check`, `inlaycms pack`, `inlaycms push`. A site needs no `node_modules`: its `inlaycms` imports load the image's copy, and `inlaycms pack` type-checks with the image's TypeScript when the site has a `tsconfig.json`. A site that uses npm packages installs them as usual, with npm or through the image (`docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:$PWD" -w "$PWD" -e HOME=/tmp ghcr.io/donstephan/inlaycms npm install <package>`).
440
-
441
- The script runs the image on the current folder, mounted at the same path, so paths mean the same inside and out; files outside the folder aren't visible to the command. What it writes belongs to you. `dev` and `serve` publish their port on this computer only (`127.0.0.1`). Without `INLAY_DATA_DIR`, `dev` and the database commands keep their data in the site folder, as without Docker; with it, that folder is mounted too. Its settings:
442
-
443
- - `INLAY_IMAGE`: the image to run (default `ghcr.io/donstephan/inlaycms`, the newest release you have pulled), such as a version (`ghcr.io/donstephan/inlaycms:0.2.0`) or an image built from this repository with `pnpm run image` (`inlaycms`).
444
- - `INLAY_DOCKER_ARGS`: more `docker run` options, split on spaces. Pass a secret the site declares with `-e CAPTCHA_SECRET`, and reach a server on this computer for `inlaycms push http://localhost:3000` with `--network host`.
445
- - Every other `INLAY_` variable is passed to the command.
446
-
447
- `docker pull ghcr.io/donstephan/inlaycms` updates the image to the newest release. The image's default command is `inlaycms serve`, with its data in a volume at `/data` (see [Running a host](#running-a-host)).
448
-
449
- ### Types in your editor
450
-
451
- Without `node_modules`, an editor on your computer can't find Inlay's types. Open the site in a dev container on the image instead (VS Code's Dev Containers, or any editor that reads `.devcontainer/devcontainer.json`): the editor runs inside the image, where `inlaycms` resolves from any folder.
452
-
453
- ```json
454
- {
455
- "name": "Inlay site",
456
- "image": "ghcr.io/donstephan/inlaycms",
457
- "containerEnv": { "INLAY_DATA_DIR": "" },
458
- "forwardPorts": [3000]
459
- }
460
- ```
461
-
462
- In its terminal, run `inlaycms dev` and the other commands directly, without the script. Or install `inlaycms` with npm only for the types and keep using the image to run it.
463
-
464
- ## Connect your assistant
465
-
466
- Editors run the site from an AI assistant such as Claude, through the MCP server at `https://<your-site>/mcp`.
467
-
468
- 1. **First run.** Open `https://<your-site>/admin`. With no users yet, it sends you to `/admin/setup`, where you create the owner account. On a server without a browser, `inlaycms create-owner --email <email> --name <name>` does the same and reads the password from stdin. If you are locked out of the only owner account, run `inlaycms reset-password --email <email>` on the server to set a new password.
469
- 2. **Connect.** Add `https://<your-site>/mcp` to your assistant as a custom connector. In Claude Code, that's `claude mcp add --transport http inlay https://<your-site>/mcp`.
470
- 3. **Log in.** The assistant opens the Inlay login page. Sign in with your Inlay account, then allow the assistant on the consent page. The consent page names the assistant and where it will send you back to, so check both before you allow it.
471
-
472
- Every change the assistant makes is a draft with a preview link. Nothing goes live until you confirm a publish, either in the assistant or on the confirmation page it links to.
473
-
474
- `describe_site` tells the assistant the name of the release the site runs and, per type, how many published pages and entries are missing something the site now requires (a required field a release added after they were published). `list_gaps` lists those pages and entries with each missing field, so the assistant can fill them in and publish again. Content a release hid (types or languages the site no longer has) isn't readable over MCP; `describe_type` on such a type says it is hidden. Releases can't be pushed or activated over MCP.
475
-
476
- The manual check against Claude clients is in `docs/mcp-acceptance.md`.
477
-
478
- ## Admin
479
-
480
- The admin lives at `https://<your-site>/admin`. Owners and editors use it to edit pages, entries and site-wide content, preview and publish, look back through history, and manage media and redirects. Owners also manage users, backups and releases there.
481
-
482
- When a release adds a required field, published content that leaves it empty stays live as it is, but the admin points it out: the dashboard counts it per type ("Missing information on the live site"), lists mark each page or entry with "Needs attention", and the editor says which fields to fill in before publishing again.
483
-
484
- ### Releases
485
-
486
- Owners find every release on the host under **Releases**: its name, state (live, ready to activate, previously live or deleted), who pushed it and when, and when it was made live. A release's page shows what it would change against the live release (as `inlaycms push` reports it), the secrets it needs, the key it was signed with and its migration functions; the live release's page also lists the content it hides (types, languages, slots and fields the site no longer has, with how many documents hold them). From there an owner can:
487
-
488
- - **Upload** a release file, which goes through the same checks as `inlaycms push` (signature, Inlay version, secrets) and is kept as staged. Without the running host (under `inlaycms dev`) the signature and Inlay version are checked on upload, and the secrets when the release is activated. A host with no trusted keys refuses uploads.
489
- - **Preview** a staged release, which opens the preview link in a new tab.
490
- - **Activate** a staged or earlier release, which makes it live the same way `push --activate` does; this is also how you roll back from the admin.
491
- - **Delete** a release that isn't live, which removes its files and stops its preview.
492
-
493
- Preview, activation and the part of the diff that looks at your content need the site to run under `inlaycms serve`. Under `inlaycms dev` the screen still lists, compares, uploads and deletes releases in the data folder, and says that activation needs the host. Inside a staged release's preview the admin is read-only, with a banner naming the release.
494
-
495
- ### Branding
496
-
497
- Set `admin` in `defineSite` to put your name, logo and colors on it:
498
-
499
- ```ts
500
- export const site = defineSite({
501
- ...,
502
- admin: {
503
- name: 'Example Studio', // shown in the header and the page titles; defaults to "Inlay"
504
- logo: '/public/logo.svg', // a URL path under /public/
505
- theme: 'corporate', // or custom colors, below
506
- },
507
- })
508
- ```
509
-
510
- - **`logo`** is the URL of an image the site serves under `/public/`, shown as an image in the admin's header. The brand name is the logo's alt text.
511
- - **`theme`** is one of daisyUI's built-in theme names (`light`, `dark`, `corporate`, `nord`, `dracula`, `emerald`, `business`, `winter` and the rest), or custom colors laid over a base theme:
512
-
513
- ```ts
514
- theme: {
515
- base: 'corporate', // optional; Inlay's own `inlay` theme by default
516
- scheme: 'light', // optional; 'light' or 'dark', for browser controls such as scrollbars
517
- colors: { primary: '#0b5fff', 'primary-content': '#ffffff' },
518
- }
519
- ```
520
-
521
- The color keys are daisyUI's (`base-100`, `base-200`, `base-300`, `base-content`, and `primary`, `secondary`, `accent`, `neutral`, `info`, `success`, `warning` and `error`, each with a `-content` partner). Values are hex (`#0b5fff`) or CSS color functions such as `oklch(…)`. Anything else stops the site at startup.
522
- - **Contrast warnings.** When a text color and its background are both hex values and their contrast is below 4.5:1 (WCAG AA), Inlay logs a warning once at startup. The site still starts. Inlay's default theme passes AA.
523
-
524
- ### Menu groups
525
-
526
- A collection's `group` puts it under its own heading in the admin's menu. Custom groups sit between Content and Building blocks, in the order the site first uses them. Without a group, a collection with pages of its own (a `route` or `customPaths`) goes under Content, and any other collection goes under Building blocks. A group named "Content" or "Building blocks" adds the collection to that heading. Pages, Site-wide content and Media always stay under Content.
527
-
528
- ```ts
529
- collections: [
530
- defineCollection({ name: 'plans', label: 'Plans', template: plan, group: 'Pricing' }),
531
- defineCollection({ name: 'discounts', label: 'Discounts', template: discount, group: 'Pricing' }),
532
- ],
533
- ```
534
-
535
- ### Suggested length
536
-
537
- `f.text` and `f.textarea` take `suggestedLength`, a soft limit beside `maxLength`. The admin shows a character counter under the field and, past the number, a hint that the text may be cut off where it's shown. It doesn't block saving or publishing, and the number is reported to assistants too. `f.seo()` suggests 70 characters for the title (at most 300) and 160 for the description (at most 500).
538
-
539
- ### Custom field widgets
540
-
541
- Every built-in field brings its own control. A field you define with `defineField` can bring one too, through `admin`: `render` draws the control for one value, and `parse` reads it back from the submitted form.
542
-
543
- ```tsx
544
- import { defineField, z, type AdminWidget } from 'inlaycms/site'
545
-
546
- const colorWidget: AdminWidget = {
547
- render: ({ id, name, value, describedBy, invalid, readOnly }) => (
548
- <input
549
- type="color"
550
- id={id}
551
- name={name}
552
- value={typeof value === 'string' ? value : '#000000'}
553
- disabled={readOnly}
554
- aria-describedby={describedBy}
555
- aria-invalid={invalid ? 'true' : undefined}
556
- class="input input-bordered w-full"
557
- />
558
- ),
559
- parse: (form, name) => form.get(name),
560
- }
561
-
562
- export const color = (opts: { label: string; help?: string }) =>
563
- defineField(z.string().regex(/^#[0-9a-f]{6}$/i), { kind: 'color', ...opts, admin: colorWidget })
564
- ```
565
-
566
- - The form supplies the label, the help text and any problems. Give the main control `id`, and pass `describedBy` and `invalid` on so screen readers hear the hints. A widget with several controls sets `fieldset: true`, and the form then wraps it in a `<fieldset>` with the label as its `<legend>`.
567
- - `parse` returns `undefined` when the value is absent. Its `optional` argument says whether the field may be left out.
568
- - The admin's CSS is prebuilt, so use classes the admin already uses (daisyUI's `input`, `select`, `textarea`, `btn` and so on) rather than new Tailwind classes.
569
- - A field without `admin` gets a text box holding its value as JSON.
570
-
571
- ### JavaScript
572
-
573
- Most of the admin is plain forms and works without JavaScript. Choosing images, files and linked pages, and editing formatted text, need it; the admin says so when it is off.
574
-
575
- ## Search and sharing
576
-
577
- Inlay writes the head of every page it renders, just before the template's `</head>`: the `<title>`, the meta description, the canonical link, `hreflang` alternates (with `x-default`) for a translated page, Open Graph tags (`og:type`, `og:title`, `og:description`, `og:url`, `og:image`), Twitter card tags, and `robots: noindex` in preview and on pages with no URL of their own. A template's `f.seo()` field sets the page's own title, description and share image.
578
-
579
- Site-wide defaults go in `defineSite`:
580
-
581
- ```ts
582
- export const site = defineSite({
583
- ...,
584
- seo: {
585
- titleTemplate: '%s | Example Studio', // %s exactly once, where the page's title goes
586
- description: 'Websites for small studios.',
587
- image: '/public/share.png', // a file under public/
588
- },
589
- })
590
- ```
591
-
592
- All three are optional. To let owners and editors change them in the admin, add `f.seoDefaults()` to one of your globals (once per site, as a top-level field, with `.optional()` so the global can ship empty):
593
-
594
- ```ts
595
- const Settings = defineTemplate({
596
- name: 'settings',
597
- label: 'Site settings',
598
- fields: z.object({ defaults: f.seoDefaults().optional() }),
599
- })
600
- ```
601
-
602
- Each default comes from the global when it's filled in, then from the code, then there's none. Preview uses the global's draft, as it does for any global, and publishing the global updates every page.
603
-
604
- - **Title.** A page's `f.seo()` title is used exactly as written. Otherwise the page's title goes through the title template, except on the home page (`/`, or a language's root such as `/es`), which keeps its plain title. The 404 page and pages from code routes get the template too. `og:title` and `twitter:title` are the final title.
605
- - **Description.** The page's `f.seo()` description, then the default.
606
- - **Share image.** The page's `f.seo()` image, then the global's default image, then the code's `/public` image. Images from the media library are shared as their 1280px JPEG. A `/public` image is an absolute URL versioned like `ctx.asset`'s; if the file isn't there the URL has no version, and the page still renders.
607
- - **`ogType`.** `defineTemplate({ ogType: 'article' })` makes the template's pages `og:type` `article`, with `article:published_time` (`publishedAt`, left out while it is `null`) and `article:modified_time` (the last change). The default is `website`.
608
- - **Twitter cards.** `twitter:card` is `summary_large_image` when the page has a share image and `summary` when it doesn't. `twitter:title`, `twitter:description` and `twitter:image` repeat the Open Graph values.
609
-
610
- ### Tags from templates
611
-
612
- Templates and blocks can add tags to the head through `ctx.head` while they render. They land after Inlay's own tags: metas, then links, then JSON-LD.
613
-
614
- ```tsx
615
- const Faq = defineBlock({
616
- name: 'faq',
617
- label: 'FAQ',
618
- schema: z.object({ question: f.text({ label: 'Question' }), answer: f.text({ label: 'Answer' }) }),
619
- render: (p, ctx) => {
620
- ctx.head.jsonLd({
621
- '@context': 'https://schema.org',
622
- '@type': 'FAQPage',
623
- mainEntity: [{ '@type': 'Question', name: p.question, acceptedAnswer: { '@type': 'Answer', text: p.answer } }],
624
- })
625
- ctx.head.meta({ name: 'author', content: 'Example Studio' })
626
- ctx.head.link({ rel: 'alternate', type: 'application/rss+xml', href: '/feed.xml' })
627
- return <section>…</section>
628
- },
629
- })
630
- ```
631
-
632
- - **`jsonLd(value)`** adds a `<script type="application/ld+json">`. It's escaped so nothing in it can end the script. Each call adds its own script, and a value JSON can't write (`undefined`, a function, a BigInt) fails the render.
633
- - **`meta({ name, content })` or `meta({ property, content })`** replaces Inlay's meta with the same name or property (`og:type`, `og:image`, `description`, `robots`…), and the last call for a key wins. `<title>` stays Inlay's.
634
- - **`link({ rel, href, … })`** replaces Inlay's link with the same `rel` and `hreflang` (so `rel: 'canonical'` replaces the canonical link, while an RSS `alternate` without `hreflang` leaves the language alternates alone). Other links are kept in call order, once each when identical. `href` must be a path on the site or an `http(s)` URL.
635
- - **Twitter tags** follow the final `og:*` values, so `meta({ property: 'og:image', … })` also sets `twitter:image` and the large card. A `twitter:*` meta of your own wins over the mirrored one.
636
- - **Preview** always stays `noindex`: a `robots` meta from a template is dropped there.
637
-
638
- Values are escaped, so `ctx.head` can only add tags to the head. For anything else (raw HTML, scripts, styles), write it in the template's own `<head>`.
639
-
640
- ### Routes in the sitemap
641
-
642
- `defineRoute({ method: 'GET', path, sitemap: true, handler })` lists the route in the sitemap. The pages its `ctx.render` returns get a canonical link and can be indexed. Other routes stay `noindex`.
643
-
644
- ## Backups, export and restore
645
-
646
- Inlay keeps two kinds of copy, for different jobs.
647
-
648
- - **A backup** is the whole site as it is on disk: the database (users, sessions and API keys too), the media and, on a host, the live release. Use it to recover the same install, for example after a disk failure or a bad deploy.
649
- - **An export** is the content only: documents, their history, redirects and media, in a documented format ([docs/export-format.md](docs/export-format.md)). It has no users or passwords. Use it to move content to another install, or to a newer version of your site code.
650
-
651
- ### Daily and post-publish backups
652
-
653
- Inlay writes a backup once a day and keeps the newest 14. It checks when the site starts and every hour after that, and backs up when the newest daily backup is 24 hours old or older, so restarts never skip or double a day.
654
-
655
- On the same hourly check, if something was published or unpublished after the newest backup of any kind, Inlay writes a post-publish backup. So published changes are in a backup within about an hour, and a busy day of publishing makes at most one backup an hour. It keeps the newest 14 of these too.
656
-
657
- Only daily and post-publish backups are pruned. Backups made by hand, before a migration, before an import or before a release went live are kept.
658
-
659
- On a host, `INLAY_BACKUP_KEEP` sets how many of each kind are kept (default 14). Backups go to `backups/` in the data folder (under `inlaycms dev`, next to the database). Copy them somewhere off the server.
660
-
661
- ### Backups from the command line
662
-
663
- ```sh
664
- npx inlaycms backup
665
- npx inlaycms restore-backup <file> [--server-stopped]
666
- ```
667
-
668
- Stop the server before `restore-backup`. It refuses to run while the database looks in use; if the server crashed and left files behind, add `--server-stopped`.
669
-
670
- "Looks in use" means the database's `-wal` or `-shm` file is still there. SQLite removes them only when the last connection closes cleanly, which `inlaycms serve` and `inlaycms dev` do when they get SIGTERM or SIGINT, so `docker stop` leaves nothing behind. A server that was killed does, and then `restore-backup` and `import` think it is still running. On a host, give the data folder with `--data` (`npx inlaycms backup --data /srv/inlay`), or set `INLAY_DATA_DIR`. The database and media you replace are kept next to the originals as `*.before-restore-*`, and the command prints their paths. A bare file name that isn't in the current directory is looked up in the backups folder. The next start applies any pending migrations.
671
-
672
- On a host, a backup also holds the release that was live (`release.tgz` and `release.json` in the archive), and `restore-backup` puts it back in `releases/` and makes it the live one again, so a host restored onto a fresh machine serves the site without pushing the release again. The release file must be the one the backup's database recorded, and must suit the running version of Inlay; when `INLAY_TRUSTED_KEYS` (or `INLAY_TRUSTED_KEYS_FILE`) is set, its signature is checked too, and otherwise the command says it wasn't. Releases that weren't live aren't backed up; push them again if you need them. Restoring an older backup without a release leaves the stored releases alone, but none of them is live afterwards: activate one to bring the site back.
673
-
674
- ### Export and import
675
-
676
- ```sh
677
- npx inlaycms export [--out <file>]
678
- npx inlaycms import <file> [--dry-run] [--server-stopped]
679
- npx inlaycms check --export <file>
680
- ```
681
-
682
- `import` always dry-runs first. `--dry-run` and `check --export` print the report and change nothing. A real import first takes a "before restoring content" backup, then replaces the content (documents, history, redirects and media) in one step. Users, sessions and API keys stay as they are. Like `restore-backup`, a real import refuses while the server is running.
683
-
684
- The report says what would happen to each content type:
685
-
686
- - **compatible**: restored and read against your site code. Values that fit are used and the rest take their defaults.
687
- - **hidden**: your site code doesn't have it. The content is kept and stays hidden.
688
-
689
- For each type, the report also counts the documents that will need attention because a required field is empty (gaps). Languages are reported the same way. Problems with the export as a whole refuse the import (exit code 1).
690
-
691
- Owners can also export and import from the **Backups & export** screen in the admin. Restoring a backup is command-line only, and none of this is available to assistants over MCP.
692
-
693
- ## Behind a reverse proxy
694
-
695
- If the site runs behind a reverse proxy (nginx, Caddy, a load balancer), set `INLAY_TRUST_PROXY` to the proxy's address, so Inlay takes each visitor's address from the `X-Forwarded-For` header the proxy adds:
696
-
697
- ```sh
698
- INLAY_TRUST_PROXY=127.0.0.1 # a proxy on the same machine
699
- INLAY_TRUST_PROXY=10.0.0.0/8,192.168.0.0/16 # proxies in these ranges
700
- INLAY_TRUST_PROXY=uniquelocal # private networks, such as Docker's
701
- ```
702
-
703
- It takes IP addresses and ranges, separated by commas, and the names `loopback`, `linklocal` and `uniquelocal`; the default is `off`. There's no setting that trusts every address.
704
-
705
- Login attempts are rate-limited per visitor address, so this matters:
706
-
707
- - **Without it**, every visitor seems to come from the proxy. Anyone can then use up the shared limit with wrong passwords and keep the owner from logging in.
708
- - **Trusting every address** would let anyone send a made-up `X-Forwarded-For` with every attempt and never hit the limit. That's why the setting only takes the proxies' own addresses: a header from anyone else is ignored.
709
-
710
- Inlay logs a warning on the first request when `INLAY_BASE_URL` is https, Inlay isn't serving https itself, and no proxy is trusted.
711
-
712
- ## Behind a CDN
713
-
714
- Inlay keeps rendered pages in memory and clears them on every publish, so a single server serves a site from memory on its own. In front of a CDN or caching proxy, published pages also carry the headers shared caches need, with no provider-specific setup:
715
-
716
- - An `ETag` over the rendered page. A request with a matching `If-None-Match` gets a 304 without rendering, so unchanged pages cost the origin almost nothing to revalidate.
717
- - `Cache-Control: public, max-age=0, s-maxage=15, stale-if-error=86400`. Browsers revalidate on every visit, so an editor who publishes and refreshes sees the change at once. Shared caches may serve a page for 15 seconds before checking back, and keep serving the last good copy for a day if the origin is down.
718
- - Media files are content-addressed and sent with a one-year immutable lifetime.
719
-
720
- To cache a site file for a year, link it with `ctx.asset('site.css')` in a template or route. It gives `/public/site.css?v=<hash>`, where the hash comes from the file's contents, and a `/public` URL whose `v` matches is served `immutable` for a year, so an edited file gets a new URL. Other `/public` URLs keep `INLAY_PUBLIC_MAX_AGE`. A file that isn't there gives the plain `/public` URL, with no `v`.
721
-
722
- Tune the shared lifetime with `INLAY_CDN_MAX_AGE` (seconds, default 15) and `INLAY_CDN_STALE_IF_ERROR` (seconds, default 86400). `INLAY_CDN_MAX_AGE=0` makes shared caches revalidate on every request, which still saves bandwidth through the 304s. Preview pages are never cached (`no-store`), so a draft cannot reach a shared cache. Published pages are marked `Vary: Cookie`; if your CDN ignores that header for HTML, add a rule to bypass its cache when the `inlay_preview` cookie is present, or editors with a preview cookie may be served the cached public page.
723
-
724
- ## Redirects
725
-
726
- Redirects that belong to the site go in its code, so they ship with each release:
727
-
728
- ```ts
729
- export const site = defineSite({
730
- ...,
731
- redirects: [
732
- { from: '/about-us', to: '/about' },
733
- { from: '/blog/:slug', to: '/:slug' },
734
- { from: '/g2', to: 'https://www.g2.com/products/example/reviews' },
735
- { from: '/old-landing', to: '/', status: 302 },
736
- ],
737
- })
738
- ```
739
-
740
- `from` is a path or a pattern with `:name` segments, `to` is a site path (with those names filled in) or an `https://` address, and `status` is `301` (the default) or `302`.
741
-
742
- - A published page at a rule's `from` wins over the rule, and so does a code route. An admin redirect with the same `from` overrides a code rule, and deleting it brings the code rule back. A delete that would leave visitors going round in a loop is refused, as a new redirect that would loop is. The admin's Redirects screen and the `list_redirects` tool show code rules read-only.
743
- - Rules ship with each release, so they follow activation and rollback: a rule is live only while its release is.
744
- - `inlaycms check` warns about rules that loop, and about rules that never fire because published pages answer at their `from` (in every language the rule applies in), without failing.
745
- - A redirect to an `https://` address, whether it comes from code, the admin, a CSV import or the MCP tools, doesn't pass the visitor's query string on. Redirects within the site still do.
746
- - Paths are case-sensitive. The one exception: a path with an uppercase letter that would otherwise be a 404 is redirected when something answers at its lowercase form. A page or a code route there gets a 301 to the lowercase path. A redirect rule there sends the visitor straight to the rule's target with the rule's own status, so a `302` rule stays a 302. That doesn't apply to reserved paths (`/admin`, `/media`, `/public` and the like) or to paths whose last segment contains a `.`.
747
-
748
- ## Security headers
749
-
750
- Every response carries `X-Content-Type-Options: nosniff`, `Referrer-Policy: strict-origin-when-cross-origin` and `Content-Security-Policy: frame-ancestors 'self'` (only the site itself may frame its pages). When the site's base URL is `https://`, responses also carry `Strict-Transport-Security: max-age=31536000`, so browsers keep to https for a year. The admin sends its own stricter policy, and a response that sets one of these headers itself keeps its own.
751
-
752
- A site changes or adds headers with `headers` in `defineSite`. A value replaces Inlay's default and `false` leaves the default out:
753
-
754
- ```ts
755
- export const site = defineSite({
756
- ...,
757
- headers: {
758
- 'Content-Security-Policy': "default-src 'self'; img-src 'self' https://images.example.com; frame-ancestors 'none'",
759
- 'Permissions-Policy': 'camera=(), microphone=(), geolocation=()',
760
- 'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload',
761
- },
762
- })
763
- ```
764
-
765
- A CSP set here replaces the default one, so include `frame-ancestors` in it. If your reverse proxy already sends HSTS, set `'Strict-Transport-Security': false` so browsers don't get it twice.
766
-
767
- ## Site password
768
-
769
- An owner can lock the whole public site behind one shared password from the admin's **Security** page, for a site that isn't launched yet or a staging copy. While the lock is on, every public request gets a neutral password screen instead: pages, media, the sitemap and the site's own routes. After the right password the visitor returns to the page they asked for, and stays unlocked in that browser for 30 days, or until an owner changes the password. People signed in to the admin and people opening a preview link skip the screen. `robots.txt` answers `Disallow: /` while the site is locked.
770
-
771
- These stay reachable without the password: the admin (`/admin`), sign-in (`/api/auth`), MCP (`/mcp` and `/.well-known/*`), the site's files under `/public/`, and Inlay's own `/_inlay/*` paths. To keep one of the site's own routes open, such as a load balancer's health check, list its path in the site's `publicPaths`. Entries are exact paths, so `/healthz` doesn't open `/healthz/x`:
772
-
773
- ```ts
774
- export const site = defineSite({
775
- ...,
776
- routes: [defineRoute({ method: 'GET', path: '/healthz', handler: async () => ({ body: 'ok' }) })],
777
- publicPaths: ['/healthz'],
778
- })
779
- ```
780
-
781
- While the lock is on, every response carries `X-Robots-Tag: noindex`, and what unlocked visitors get is sent as `Cache-Control: private` instead of `public`, so CDNs and proxies don't store it. The password screen itself is `no-store`. With the lock off, responses are exactly as described above.
782
-
783
- A CDN keeps whatever it cached while the site was public until it's purged, and Inlay can't purge it. Turn the lock on before the site is ever public, or purge the CDN after locking a site that was public.
784
-
785
- ## Working on Inlay
96
+ The [full quickstart](https://donstephan.github.io/inlaycms/docs/quickstart) explains each step, and what happens next.
786
97
 
787
- The repo uses pnpm, not npm.
98
+ ## Documentation
788
99
 
789
- - `pnpm test` runs the tests and `pnpm run typecheck` checks the types. `pnpm run build` builds the package into `dist/`.
790
- - `pnpm run dev` runs the example site in `example/` through `inlaycms dev` at `http://localhost:3000`, with its data in `example/data/`: it restarts the site when a file in `example/` changes and rebuilds the admin's assets when `client/admin/` changes. A change to Inlay's own code in `src/` restarts `inlaycms dev` itself. Reload the page to see a change. `docker compose up dev` does the same in a container. It joins the external `inlay-dev` network, which you create once with `docker network create inlay-dev`.
791
- - The admin's CSS and JavaScript are built from `client/admin/` into `assets/admin/`, which ships in the package. `pnpm run build:admin` builds them once. `pnpm run build` runs it first, and `pnpm test` runs it when the files are missing.
792
- - `pnpm run example:pack` packs the example site into `example/data/release.tgz`, signed with the development key in `example/keys/`.
793
- - `docker compose run --rm pack-test` packs Inlay, installs the tarball into a fresh copy of `example/`, packs the example into a release, activates it offline into a fresh data folder, runs `inlaycms serve` on it, pushes a second release to the running host and rolls back, and checks the site, admin, MCP and every CLI command. Run it before a release.
100
+ The docs are at [donstephan.github.io/inlaycms](https://donstephan.github.io/inlaycms/):
794
101
 
795
- ### Trying the deploy path locally
102
+ - **Get started**: the quickstart, running Inlay through the Docker image without Node, and why Inlay exists.
103
+ - **Guides**: the content model, rich text, shipped content, releases and hosting, testing, connecting an assistant, the admin, search and sharing, backups, redirects, integrations and consent, security, proxies and CDNs, and the site password.
104
+ - **Reference**: every CLI command, config option, field type and environment variable.
796
105
 
797
- `docker compose run --rm pack-test` is the deploy path end to end: it makes the first release and an owner offline, mints a push key with `inlaycms create-token --push`, starts `inlaycms serve`, pushes a second release with `inlaycms push --activate`, checks the diff and the site, confirms that a `--dry-run` push changes nothing, and rolls back with `inlaycms activate <host> <id>`. To try it by hand, run `docker compose up serve` (see [Running a host](#running-a-host)), create a push key in the same container, and push to `http://localhost:3000`.
106
+ ## Contributing
798
107
 
799
- The manual checks in a real browser and against Claude clients are in `docs/admin-acceptance.md` and `docs/mcp-acceptance.md`.
108
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
800
109
 
801
110
  ## License
802
111