inlaycms 0.2.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.
- package/README.md +330 -1
- package/assets/admin/admin.css +1 -1
- package/assets/admin/admin.js +1 -1
- package/assets/admin/editor.js +59 -44
- package/dist/adapters/admin/screens/redirects.js +12 -3
- package/dist/adapters/admin/views/layout.js +27 -7
- package/dist/adapters/cli/remote.js +9 -1
- package/dist/adapters/mcp/tools/redirects.js +16 -2
- package/dist/adapters/site/assets.d.ts +11 -0
- package/dist/adapters/site/assets.js +71 -0
- package/dist/adapters/site/cache.d.ts +2 -1
- package/dist/adapters/site/cache.js +6 -1
- package/dist/adapters/site/context.d.ts +6 -0
- package/dist/adapters/site/context.js +38 -13
- package/dist/adapters/site/head.d.ts +30 -7
- package/dist/adapters/site/head.js +145 -20
- package/dist/adapters/site/headers.d.ts +5 -0
- package/dist/adapters/site/headers.js +31 -0
- package/dist/adapters/site/plugin.d.ts +2 -0
- package/dist/adapters/site/plugin.js +32 -9
- package/dist/adapters/site/public.js +7 -24
- package/dist/adapters/site/render.d.ts +5 -0
- package/dist/adapters/site/render.js +23 -8
- package/dist/adapters/site/routes.d.ts +6 -0
- package/dist/adapters/site/routes.js +8 -3
- package/dist/adapters/site/seo.d.ts +20 -0
- package/dist/adapters/site/seo.js +45 -0
- package/dist/adapters/site/sitemap.d.ts +1 -1
- package/dist/adapters/site/sitemap.js +1 -1
- package/dist/config.js +3 -2
- package/dist/core/agent/format.js +1 -1
- package/dist/core/agent/schema.js +3 -0
- package/dist/core/boot.js +7 -0
- package/dist/core/check.js +6 -1
- package/dist/core/content/dry-run.d.ts +7 -6
- package/dist/core/content/dry-run.js +8 -8
- package/dist/core/content/publish.d.ts +1 -1
- package/dist/core/content/publish.js +5 -3
- package/dist/core/content/read.d.ts +3 -0
- package/dist/core/content/reader.js +3 -2
- package/dist/core/content/refs.js +1 -1
- package/dist/core/content/search.js +2 -2
- package/dist/core/content/shipped-images.d.ts +32 -0
- package/dist/core/content/shipped-images.js +62 -0
- package/dist/core/content/shipped-input.d.ts +9 -3
- package/dist/core/content/shipped-input.js +165 -28
- package/dist/core/content/shipped.js +8 -3
- package/dist/core/content/validate.js +7 -1
- package/dist/core/core.d.ts +5 -1
- package/dist/core/core.js +5 -4
- package/dist/core/db/connection.d.ts +6 -0
- package/dist/core/db/connection.js +13 -1
- package/dist/core/db/migrate.js +2 -0
- package/dist/core/db/migrations/0007_published_at.d.ts +3 -0
- package/dist/core/db/migrations/0007_published_at.js +16 -0
- package/dist/core/db/schema.d.ts +1 -0
- package/dist/core/export/export.js +3 -1
- package/dist/core/export/format.d.ts +8 -1
- package/dist/core/export/format.js +3 -2
- package/dist/core/export/read.js +7 -0
- package/dist/core/export/stage.d.ts +1 -1
- package/dist/core/export/stage.js +24 -1
- package/dist/core/fields/builtins.d.ts +28 -0
- package/dist/core/fields/builtins.js +103 -11
- package/dist/core/fields/define.d.ts +6 -0
- package/dist/core/fields/widgets.d.ts +7 -0
- package/dist/core/fields/widgets.js +76 -28
- package/dist/core/messages/en.d.ts +70 -6
- package/dist/core/messages/en.js +70 -6
- package/dist/core/redirects/collapse.d.ts +17 -1
- package/dist/core/redirects/collapse.js +19 -3
- package/dist/core/redirects/redirects.d.ts +13 -12
- package/dist/core/redirects/redirects.js +141 -53
- package/dist/core/redirects/rule.d.ts +25 -0
- package/dist/core/redirects/rule.js +55 -0
- package/dist/core/registry/define.d.ts +40 -0
- package/dist/core/registry/define.js +3 -0
- package/dist/core/registry/registry.d.ts +21 -0
- package/dist/core/registry/registry.js +114 -6
- package/dist/core/registry/render.d.ts +37 -1
- package/dist/core/registry/route.d.ts +4 -0
- package/dist/core/release/bundle.js +30 -5
- package/dist/core/release/manifest.d.ts +14 -0
- package/dist/core/release/manifest.js +42 -17
- package/dist/core/release/markdown-file.d.ts +21 -0
- package/dist/core/release/markdown-file.js +172 -0
- package/dist/core/release/pack.js +2 -2
- package/dist/core/release/read.js +4 -1
- package/dist/core/release/site-dir.d.ts +4 -0
- package/dist/core/release/site-dir.js +8 -0
- package/dist/core/report.d.ts +8 -2
- package/dist/core/richtext/html.d.ts +3 -1
- package/dist/core/richtext/html.js +16 -4
- package/dist/core/richtext/inline.d.ts +22 -0
- package/dist/core/richtext/inline.js +33 -0
- package/dist/core/richtext/markdown.d.ts +16 -1
- package/dist/core/richtext/markdown.js +137 -14
- package/dist/core/richtext/schema.d.ts +16 -4
- package/dist/core/richtext/schema.js +71 -1
- package/dist/core/site/live.d.ts +1 -0
- package/dist/core/site/live.js +1 -0
- package/dist/core/site/paths.d.ts +6 -0
- package/dist/core/site/paths.js +13 -0
- package/dist/core/site/resolve.d.ts +1 -1
- package/dist/core/site/resolve.js +119 -30
- package/dist/core/site/sitemap.d.ts +1 -1
- package/dist/core/site/sitemap.js +4 -0
- package/dist/core/types.d.ts +28 -3
- package/dist/host/app.d.ts +5 -0
- package/dist/host/app.js +8 -0
- package/dist/host/dev.js +3 -7
- package/dist/host/diff.d.ts +19 -1
- package/dist/host/diff.js +32 -2
- package/dist/index.d.ts +2 -2
- package/dist/markdown-modules.d.ts +8 -0
- package/dist/markdown-modules.js +1 -0
- package/dist/site.d.ts +8 -3
- package/dist/site.js +6 -0
- package/dist/testing.d.ts +22 -0
- package/dist/testing.js +155 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -204,7 +204,7 @@ export INLAY_PUSH_TOKEN=... # or --token <token>
|
|
|
204
204
|
npx inlaycms push https://example.com --key keys/release.key
|
|
205
205
|
```
|
|
206
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 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.
|
|
208
208
|
|
|
209
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
210
|
|
|
@@ -223,6 +223,206 @@ All three take the token from `--token` or `INLAY_PUSH_TOKEN`. They exit 1 when
|
|
|
223
223
|
|
|
224
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
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
|
+
'',
|
|
399
|
+
'.png>)',
|
|
400
|
+
`})`,
|
|
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 `` or ``. 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
|
+
|
|
226
426
|
## Without Node: the Docker image
|
|
227
427
|
|
|
228
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:
|
|
@@ -317,6 +517,21 @@ export const site = defineSite({
|
|
|
317
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.
|
|
318
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.
|
|
319
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
|
+
|
|
320
535
|
### Custom field widgets
|
|
321
536
|
|
|
322
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.
|
|
@@ -353,6 +568,75 @@ export const color = (opts: { label: string; help?: string }) =>
|
|
|
353
568
|
|
|
354
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.
|
|
355
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
|
+
|
|
356
640
|
## Backups, export and restore
|
|
357
641
|
|
|
358
642
|
Inlay keeps two kinds of copy, for different jobs.
|
|
@@ -429,8 +713,53 @@ Inlay keeps rendered pages in memory and clears them on every publish, so a sing
|
|
|
429
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.
|
|
430
714
|
- Media files are content-addressed and sent with a one-year immutable lifetime.
|
|
431
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
|
+
|
|
432
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.
|
|
433
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
|
+
|
|
434
763
|
## Site password
|
|
435
764
|
|
|
436
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.
|