inlaycms 0.1.0 → 0.3.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 (121) hide show
  1. package/README.md +344 -8
  2. package/assets/admin/admin.css +1 -1
  3. package/assets/admin/admin.js +1 -1
  4. package/assets/admin/editor.js +59 -44
  5. package/dist/adapters/admin/screens/redirects.js +12 -3
  6. package/dist/adapters/admin/views/layout.js +27 -7
  7. package/dist/adapters/cli/remote.js +9 -1
  8. package/dist/adapters/mcp/tools/redirects.js +16 -2
  9. package/dist/adapters/site/assets.d.ts +11 -0
  10. package/dist/adapters/site/assets.js +71 -0
  11. package/dist/adapters/site/cache.d.ts +2 -1
  12. package/dist/adapters/site/cache.js +6 -1
  13. package/dist/adapters/site/context.d.ts +6 -0
  14. package/dist/adapters/site/context.js +38 -13
  15. package/dist/adapters/site/head.d.ts +30 -7
  16. package/dist/adapters/site/head.js +145 -20
  17. package/dist/adapters/site/headers.d.ts +5 -0
  18. package/dist/adapters/site/headers.js +31 -0
  19. package/dist/adapters/site/plugin.d.ts +2 -0
  20. package/dist/adapters/site/plugin.js +32 -9
  21. package/dist/adapters/site/public.js +7 -24
  22. package/dist/adapters/site/render.d.ts +5 -0
  23. package/dist/adapters/site/render.js +23 -8
  24. package/dist/adapters/site/routes.d.ts +6 -0
  25. package/dist/adapters/site/routes.js +8 -3
  26. package/dist/adapters/site/seo.d.ts +20 -0
  27. package/dist/adapters/site/seo.js +45 -0
  28. package/dist/adapters/site/sitemap.d.ts +1 -1
  29. package/dist/adapters/site/sitemap.js +1 -1
  30. package/dist/config.js +3 -2
  31. package/dist/core/agent/format.js +1 -1
  32. package/dist/core/agent/schema.js +3 -0
  33. package/dist/core/boot.js +7 -0
  34. package/dist/core/check.js +6 -1
  35. package/dist/core/content/dry-run.d.ts +7 -6
  36. package/dist/core/content/dry-run.js +8 -8
  37. package/dist/core/content/publish.d.ts +1 -1
  38. package/dist/core/content/publish.js +5 -3
  39. package/dist/core/content/read.d.ts +3 -0
  40. package/dist/core/content/reader.js +3 -2
  41. package/dist/core/content/refs.js +1 -1
  42. package/dist/core/content/search.js +2 -2
  43. package/dist/core/content/shipped-images.d.ts +32 -0
  44. package/dist/core/content/shipped-images.js +62 -0
  45. package/dist/core/content/shipped-input.d.ts +9 -3
  46. package/dist/core/content/shipped-input.js +165 -28
  47. package/dist/core/content/shipped.js +8 -3
  48. package/dist/core/content/validate.js +7 -1
  49. package/dist/core/core.d.ts +5 -1
  50. package/dist/core/core.js +5 -4
  51. package/dist/core/db/connection.d.ts +6 -0
  52. package/dist/core/db/connection.js +13 -1
  53. package/dist/core/db/migrate.js +2 -0
  54. package/dist/core/db/migrations/0007_published_at.d.ts +3 -0
  55. package/dist/core/db/migrations/0007_published_at.js +16 -0
  56. package/dist/core/db/schema.d.ts +1 -0
  57. package/dist/core/export/export.js +3 -1
  58. package/dist/core/export/format.d.ts +8 -1
  59. package/dist/core/export/format.js +3 -2
  60. package/dist/core/export/read.js +7 -0
  61. package/dist/core/export/stage.d.ts +1 -1
  62. package/dist/core/export/stage.js +24 -1
  63. package/dist/core/fields/builtins.d.ts +28 -0
  64. package/dist/core/fields/builtins.js +103 -11
  65. package/dist/core/fields/define.d.ts +6 -0
  66. package/dist/core/fields/widgets.d.ts +7 -0
  67. package/dist/core/fields/widgets.js +76 -28
  68. package/dist/core/messages/en.d.ts +70 -6
  69. package/dist/core/messages/en.js +70 -6
  70. package/dist/core/redirects/collapse.d.ts +17 -1
  71. package/dist/core/redirects/collapse.js +19 -3
  72. package/dist/core/redirects/redirects.d.ts +13 -12
  73. package/dist/core/redirects/redirects.js +141 -53
  74. package/dist/core/redirects/rule.d.ts +25 -0
  75. package/dist/core/redirects/rule.js +55 -0
  76. package/dist/core/registry/define.d.ts +40 -0
  77. package/dist/core/registry/define.js +3 -0
  78. package/dist/core/registry/registry.d.ts +21 -0
  79. package/dist/core/registry/registry.js +114 -6
  80. package/dist/core/registry/render.d.ts +37 -1
  81. package/dist/core/registry/route.d.ts +4 -0
  82. package/dist/core/release/bundle.js +30 -5
  83. package/dist/core/release/manifest.d.ts +14 -0
  84. package/dist/core/release/manifest.js +42 -17
  85. package/dist/core/release/markdown-file.d.ts +21 -0
  86. package/dist/core/release/markdown-file.js +172 -0
  87. package/dist/core/release/pack.js +2 -2
  88. package/dist/core/release/read.js +4 -1
  89. package/dist/core/release/site-dir.d.ts +4 -0
  90. package/dist/core/release/site-dir.js +8 -0
  91. package/dist/core/report.d.ts +8 -2
  92. package/dist/core/richtext/html.d.ts +3 -1
  93. package/dist/core/richtext/html.js +16 -4
  94. package/dist/core/richtext/inline.d.ts +22 -0
  95. package/dist/core/richtext/inline.js +33 -0
  96. package/dist/core/richtext/markdown.d.ts +16 -1
  97. package/dist/core/richtext/markdown.js +137 -14
  98. package/dist/core/richtext/schema.d.ts +16 -4
  99. package/dist/core/richtext/schema.js +71 -1
  100. package/dist/core/site/live.d.ts +1 -0
  101. package/dist/core/site/live.js +1 -0
  102. package/dist/core/site/paths.d.ts +6 -0
  103. package/dist/core/site/paths.js +13 -0
  104. package/dist/core/site/resolve.d.ts +1 -1
  105. package/dist/core/site/resolve.js +119 -30
  106. package/dist/core/site/sitemap.d.ts +1 -1
  107. package/dist/core/site/sitemap.js +4 -0
  108. package/dist/core/types.d.ts +28 -3
  109. package/dist/host/app.d.ts +5 -0
  110. package/dist/host/app.js +8 -0
  111. package/dist/host/dev.js +3 -7
  112. package/dist/host/diff.d.ts +19 -1
  113. package/dist/host/diff.js +32 -2
  114. package/dist/index.d.ts +2 -2
  115. package/dist/markdown-modules.d.ts +8 -0
  116. package/dist/markdown-modules.js +1 -0
  117. package/dist/site.d.ts +8 -3
  118. package/dist/site.js +6 -0
  119. package/dist/testing.d.ts +22 -0
  120. package/dist/testing.js +155 -0
  121. package/package.json +6 -1
package/README.md CHANGED
@@ -168,7 +168,14 @@ npx inlaycms serve
168
168
 
169
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
170
 
171
- The Docker image (`Dockerfile`, 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: `docker compose up serve` with `INLAY_SECRET` and `INLAY_TRUSTED_KEYS` set in your shell. Run `inlaycms activate` in the same container to give it its first release. The release file must be inside the container, so mount it: `docker compose run --rm -v "$PWD/release.tgz:/release.tgz:ro" serve inlaycms activate /release.tgz`. The image holds the packed `inlaycms` with its production dependencies only, with `inlaycms` on the `PATH`.
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.
172
179
 
173
180
  To give a host its first release, or to make a release live while it is stopped:
174
181
 
@@ -197,7 +204,7 @@ export INLAY_PUSH_TOKEN=... # or --token <token>
197
204
  npx inlaycms push https://example.com --key keys/release.key
198
205
  ```
199
206
 
200
- `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 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.
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.
201
208
 
202
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`.
203
210
 
@@ -216,24 +223,224 @@ All three take the token from `--token` or `INLAY_PUSH_TOKEN`. They exit 1 when
216
223
 
217
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.
218
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://realciso.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
+ ### Tables
276
+
277
+ 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:
278
+
279
+ ```md
280
+ | Plan | Price |
281
+ | --- | --- |
282
+ | **Pro** | [Buy](https://example.com/buy) |
283
+ | *Lite* | free |
284
+ ```
285
+
286
+ The first row is always the header row. A cell holds one line of text with bold, italic 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'] })`.
287
+
288
+ 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.
289
+
290
+ ### Inline text
291
+
292
+ `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 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.
293
+
294
+ 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.
295
+
296
+ 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`.
297
+
298
+ An inline-text field can't be a collection's `titleField`, which must be plain text. Keep a plain `f.text` title beside it:
299
+
300
+ ```ts
301
+ fields: z.object({
302
+ title: f.text({ label: 'Title' }),
303
+ headline: f.inlineText({ label: 'Headline', maxLength: 80 }),
304
+ }),
305
+ ```
306
+
307
+ ### Publish dates
308
+
309
+ `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`.
310
+
311
+ `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' } }`.
312
+
313
+ ### Multi-select
314
+
315
+ `f.multiSelect(options, { label, min, max })` picks any number of a fixed list of options, such as tags:
316
+
317
+ ```ts
318
+ tags: f.multiSelect(['hipaa', 'cmmc', 'soc2'] as const, { label: 'Tags', min: 0, max: 3 }),
319
+ ```
320
+
321
+ 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.
322
+
323
+ To list the entries with a tag, filter them in a template:
324
+
325
+ ```ts
326
+ const faqs = await ctx.query('faqs', { filter: (e) => e.fields.tags.includes('hipaa') })
327
+ ```
328
+
329
+ 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.
330
+
331
+ ### Nested lists
332
+
333
+ 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.
334
+
335
+ ```ts
336
+ const Menu = defineTemplate({
337
+ name: 'menu',
338
+ label: 'Menu',
339
+ fields: z.object({
340
+ menu: f.list(
341
+ z.object({
342
+ title: f.text({ label: 'Title' }),
343
+ columns: f.list(
344
+ z.object({
345
+ heading: f.text({ label: 'Heading' }),
346
+ links: f.list(
347
+ z.object({
348
+ label: f.text({ label: 'Label' }),
349
+ href: f.text({ label: 'Address' }),
350
+ description: f.textarea({ label: 'Description' }).optional(),
351
+ }),
352
+ { label: 'Links', itemLabel: 'Link' },
353
+ ),
354
+ }),
355
+ { label: 'Columns', itemLabel: 'Column' },
356
+ ),
357
+ }),
358
+ { label: 'Menu', itemLabel: 'Menu item' },
359
+ ),
360
+ promo: f.group({ text: f.text({ label: 'Text' }), link: f.link({ label: 'Link' }) }, { label: 'Promo' }),
361
+ }),
362
+ })
363
+ ```
364
+
365
+ A template loops over each level:
366
+
367
+ ```tsx
368
+ <nav>
369
+ {fields.menu.map((item) => (
370
+ <div>
371
+ <span>{item.title}</span>
372
+ {item.columns.map((column) => (
373
+ <section>
374
+ <h3>{column.heading}</h3>
375
+ <ul>
376
+ {column.links.map((link) => (
377
+ <li><a href={link.href}>{link.label}</a></li>
378
+ ))}
379
+ </ul>
380
+ </section>
381
+ ))}
382
+ </div>
383
+ ))}
384
+ </nav>
385
+ ```
386
+
387
+ ### Images in shipped content
388
+
389
+ 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:
390
+
391
+ ```ts
392
+ defineContent('about', {
393
+ edition: 1,
394
+ content: {
395
+ en: {
396
+ fields: {
397
+ body: [
398
+ '![Our team](images/team.png)',
399
+ '![The 2026 chart](<images/my chart (1).png>)',
400
+ `![Logo](${new URL('./images/logo.png', import.meta.url)})`,
401
+ ].join('\n\n'),
402
+ },
403
+ },
404
+ },
405
+ })
406
+ ```
407
+
408
+ 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.
409
+
410
+ 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>`.
411
+
412
+ ### Markdown files
413
+
414
+ 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:
415
+
416
+ ```ts
417
+ import hello from './posts/hello.md'
418
+
419
+ defineEntries('posts', [
420
+ { key: 'hello', edition: 1, content: { en: { slug: 'hello', fields: { title: 'Hello', body: hello } } } },
421
+ ])
422
+ ```
423
+
424
+ 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.
425
+
219
426
  ## Without Node: the Docker image
220
427
 
221
- The Inlay image holds the whole CLI as well as the host, so a computer with Docker needs no Node or npm. Build it from this repository with `pnpm run image` (it's tagged `inlaycms`), and install the `inlaycms` script it carries:
428
+ 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:
222
429
 
223
430
  ```sh
224
- docker run --rm inlaycms cat /opt/inlaycms/wrapper/inlaycms > ~/.local/bin/inlaycms
431
+ docker run --rm ghcr.io/donstephan/inlaycms cat /opt/inlaycms/wrapper/inlaycms > ~/.local/bin/inlaycms
225
432
  chmod +x ~/.local/bin/inlaycms
226
433
  ```
227
434
 
228
- 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 inlay npm install <package>`).
435
+ 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>`).
229
436
 
230
437
  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:
231
438
 
232
- - `INLAY_IMAGE`: the image to run (default `inlaycms`), such as a tag from a registry.
439
+ - `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`).
233
440
  - `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`.
234
441
  - Every other `INLAY_` variable is passed to the command.
235
442
 
236
- The image's default command is `inlaycms serve`, with its data in a volume at `/data` (see [Running a host](#running-a-host)).
443
+ `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)).
237
444
 
238
445
  ### Types in your editor
239
446
 
@@ -242,7 +449,7 @@ Without `node_modules`, an editor on your computer can't find Inlay's types. Ope
242
449
  ```json
243
450
  {
244
451
  "name": "Inlay site",
245
- "image": "inlaycms",
452
+ "image": "ghcr.io/donstephan/inlaycms",
246
453
  "containerEnv": { "INLAY_DATA_DIR": "" },
247
454
  "forwardPorts": [3000]
248
455
  }
@@ -310,6 +517,21 @@ export const site = defineSite({
310
517
  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.
311
518
  - **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.
312
519
 
520
+ ### Menu groups
521
+
522
+ 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.
523
+
524
+ ```ts
525
+ collections: [
526
+ defineCollection({ name: 'plans', label: 'Plans', template: plan, group: 'Pricing' }),
527
+ defineCollection({ name: 'discounts', label: 'Discounts', template: discount, group: 'Pricing' }),
528
+ ],
529
+ ```
530
+
531
+ ### Suggested length
532
+
533
+ `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).
534
+
313
535
  ### Custom field widgets
314
536
 
315
537
  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.
@@ -346,6 +568,75 @@ export const color = (opts: { label: string; help?: string }) =>
346
568
 
347
569
  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.
348
570
 
571
+ ## Search and sharing
572
+
573
+ 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.
574
+
575
+ Site-wide defaults go in `defineSite`:
576
+
577
+ ```ts
578
+ export const site = defineSite({
579
+ ...,
580
+ seo: {
581
+ titleTemplate: '%s | Example Studio', // %s exactly once, where the page's title goes
582
+ description: 'Websites for small studios.',
583
+ image: '/public/share.png', // a file under public/
584
+ },
585
+ })
586
+ ```
587
+
588
+ 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):
589
+
590
+ ```ts
591
+ const Settings = defineTemplate({
592
+ name: 'settings',
593
+ label: 'Site settings',
594
+ fields: z.object({ defaults: f.seoDefaults().optional() }),
595
+ })
596
+ ```
597
+
598
+ 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.
599
+
600
+ - **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.
601
+ - **Description.** The page's `f.seo()` description, then the default.
602
+ - **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.
603
+ - **`ogType`.** `defineTemplate({ ogType: 'article' })` makes the template's pages `og:type` `article`, with `article:modified_time` (the last change). `article:published_time` comes in a later release. The default is `website`.
604
+ - **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.
605
+
606
+ ### Tags from templates
607
+
608
+ 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.
609
+
610
+ ```tsx
611
+ const Faq = defineBlock({
612
+ name: 'faq',
613
+ label: 'FAQ',
614
+ schema: z.object({ question: f.text({ label: 'Question' }), answer: f.text({ label: 'Answer' }) }),
615
+ render: (p, ctx) => {
616
+ ctx.head.jsonLd({
617
+ '@context': 'https://schema.org',
618
+ '@type': 'FAQPage',
619
+ mainEntity: [{ '@type': 'Question', name: p.question, acceptedAnswer: { '@type': 'Answer', text: p.answer } }],
620
+ })
621
+ ctx.head.meta({ name: 'author', content: 'Example Studio' })
622
+ ctx.head.link({ rel: 'alternate', type: 'application/rss+xml', href: '/feed.xml' })
623
+ return <section>…</section>
624
+ },
625
+ })
626
+ ```
627
+
628
+ - **`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.
629
+ - **`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.
630
+ - **`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.
631
+ - **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.
632
+ - **Preview** always stays `noindex`: a `robots` meta from a template is dropped there.
633
+
634
+ 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>`.
635
+
636
+ ### Routes in the sitemap
637
+
638
+ `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`.
639
+
349
640
  ## Backups, export and restore
350
641
 
351
642
  Inlay keeps two kinds of copy, for different jobs.
@@ -422,8 +713,53 @@ Inlay keeps rendered pages in memory and clears them on every publish, so a sing
422
713
  - `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.
423
714
  - Media files are content-addressed and sent with a one-year immutable lifetime.
424
715
 
716
+ 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`.
717
+
425
718
  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.
426
719
 
720
+ ## Redirects
721
+
722
+ Redirects that belong to the site go in its code, so they ship with each release:
723
+
724
+ ```ts
725
+ export const site = defineSite({
726
+ ...,
727
+ redirects: [
728
+ { from: '/about-us', to: '/about' },
729
+ { from: '/blog/:slug', to: '/:slug' },
730
+ { from: '/g2', to: 'https://www.g2.com/products/realciso/reviews' },
731
+ { from: '/old-landing', to: '/', status: 302 },
732
+ ],
733
+ })
734
+ ```
735
+
736
+ `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`.
737
+
738
+ - 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.
739
+ - Rules ship with each release, so they follow activation and rollback: a rule is live only while its release is.
740
+ - `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.
741
+ - 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.
742
+ - 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 `.`.
743
+
744
+ ## Security headers
745
+
746
+ 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.
747
+
748
+ A site changes or adds headers with `headers` in `defineSite`. A value replaces Inlay's default and `false` leaves the default out:
749
+
750
+ ```ts
751
+ export const site = defineSite({
752
+ ...,
753
+ headers: {
754
+ 'Content-Security-Policy': "default-src 'self'; img-src 'self' https://images.example.com; frame-ancestors 'none'",
755
+ 'Permissions-Policy': 'camera=(), microphone=(), geolocation=()',
756
+ 'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload',
757
+ },
758
+ })
759
+ ```
760
+
761
+ 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.
762
+
427
763
  ## Site password
428
764
 
429
765
  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.