# Article bodies and blocks

An article's `body` (and a page's `body`, and an entity's `bio`) is [Portable Text](https://portabletext.org): a list of typed nodes. Render it with a Portable Text library for your framework, such as `@portabletext/react`, giving each node type below a component.

If you would rather not, every body also comes as `html`, ready to place, and an article as `markdown` with `?format=markdown`. You lose the typed blocks and image control that way.

## Text

A `block` node is a paragraph, heading, quote or list item:

- `style`: `normal`, `h2` to `h6`, or `blockquote`. Article titles are the page's `h1`, so bodies start at `h2`.
- `listItem` (`bullet` or `number`) and `level` (nesting, from 1) on list items.
- `children`: spans of `text`, each with `marks`.
- A mark is a decorator (`strong`, `em`, `underline`, `strike-through`, `code`) or the `_key` of an entry in the block's `markDefs`. A `link` mark def has an `href`.

Links inside the site are paths (`/racing/other-story`); link them as such. Anything else is a full URL.

## Other nodes

| `_type` | Fields | Render as |
| --- | --- | --- |
| `image` | `url`, `alt`, `caption`, `credit`, `width`, `height`, `focalPoint`, `placeholder`, `link` | A figure. Reserve its space from `width` and `height`. See [Images](#images). |
| `table` | `title`, `subtitle`, `columns`, `rows[].cells` | A table. `cells` line up with `columns`. |
| `code` | `code`, `language` | Preformatted code. |
| `break` | none | A section break. |

## Preset blocks

Every site has six blocks the writer can place. Each arrives with its own `_type`:

| `_type` | Fields | Render as |
| --- | --- | --- |
| `embed` | `provider`, `url`, `caption` | A post or video from another service. `provider` is `twitter`, `instagram`, `youtube`, `tiktok`, `bluesky`, `threads`, `facebook`, `linkedin`, `vimeo`, `strava` or `other`. At least, a link to `url`. |
| `gallery` | `title`, `images` | A set of images, each shaped like an `image` node. |
| `table` | as above | A data, results or stage table. |
| `quote` | `text`, `credit` | A pull quote. |
| `callout` | `title`, `text` | A boxed note. |
| `graphic` | `id`, `title`, `alt`, `caption`, `image`, `markup`, `script` | An interactive graphic Velora made. Run `markup` and `script` in a sandboxed `iframe` (`srcdoc`, `sandbox="allow-scripts"`) so its script cannot touch your page, sized from `image.width` and `image.height`. Where scripts cannot run (feeds, email), show `image`. |

## Your own blocks

A site can define its own blocks: a race times table, a product card, a verdict. You define each in your front end, next to the component that draws it, and publish the list. Velora's writer places the blocks an editor switches on.

### Publish the list

Serve your list as JSON at `/velora/blocks.json` on the same origin as your **Revalidate URL** (or Preview URL, if that is the only one set):

```json
{
  "blocks": [
    {
      "name": "RACE_TIMES",
      "title": "Race times",
      "guidance": "Start and finish times for a race day.",
      "fields": {
        "race": {"type": "entity", "entity_type": "races"},
        "timezone": {"type": "string", "required": true},
        "events": {
          "type": "array",
          "of": {"type": "object", "fields": {
            "time": {"type": "string"},
            "label": {"type": "string", "required": true}
          }}
        }
      }
    }
  ]
}
```

- `name`: capitals, digits and underscores, starting with a capital, up to 50 characters. It is the marker the writer uses and the `_type` your body receives. It cannot be a preset's name (`EMBED`, `GALLERY`, `TABLE`, `QUOTE`, `CALLOUT`, `VELORA_GRAPHIC`).
- `title` (up to 100 characters) and `guidance` (when the writer should use it, up to 2,000; editors can rewrite it in Velora).
- `fields`: up to 50, named with a letter then letters, digits or `_`, nested up to 6 deep. Each is `{type, title?, description?, required?, max?}`.
- Up to 100 blocks, and 512 KB.

Field types:

| `type` | Value in the body |
| --- | --- |
| `string`, `text` (paragraphs), `url`, `email`, `date` (`2026-05-02`), `datetime` | string |
| `number` | number |
| `boolean` | boolean |
| `array` (with `of`) | list; objects in it get a `_key` |
| `object` (with `fields`) | object |
| `product` | Velora fills it: `name`, `brand`, `image`, and `links`, each `{kind: "buy" or "search", retailer, url, rel}`. Use `rel` on the link. |
| `entity` (with `entity_type`, one of your type slugs) | Velora fills it: `{_type: "entity", id, name, type, path}`. `path` is `null` when the entity has no page. |
| `article` | Velora fills it: `{_type: "article", id, title, path}` |
| `image` | a `RenderedImage` (see [Images](#images)): no `_type`, `_key` or `link` |
| `graphic` | one of the article's graphics, shaped like a `graphic` block |

`max` is the most items for a list, characters for text, or the highest value for a number. `required` and `max` are checked on every publish.

### Tell Velora it changed

Velora reads the list when an editor presses Refresh in **Skills**, **Components**, every day, and when your deploy tells it to. After a production deploy, send:

```bash
curl -X POST "https://api.velora.build/v1/public/$SITE_ID/blocks/changed" \
  -H "Authorization: Bearer $VELORA_READ_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"hash\": \"$(curl -s https://your-site.com/velora/blocks.json | sha256sum | cut -d' ' -f1)\"}"
```

`hash` (optional) is the SHA-256 hex of the exact bytes your list serves. Velora answers `202` and reads the list every minute, up to ten times, until it sees that hash, so a ping sent before the deploy is live still lands. Do not fail your build on this call: the daily read catches a missed one.

If Velora cannot read the list, or it is not valid, Velora keeps the last good one.

### What reaches your body

A site block arrives as `{"_type": "RACE_TIMES", "_key": "...", ...fields}`. A field with no value is left out. Velora refuses to publish an article with a block your list does not define, or one whose fields do not fit, and tells the editor why.

Still render a block you have no component for: show its title and fields rather than dropping it. An article published before you removed a block from your list still holds it.

## Images

Every image is a `RenderedImage`: `url`, `alt`, `caption`, `credit`, `width`, `height` (when known), `focalPoint` and `placeholder`.

- `focalPoint` is `{x, y}`, each 0 to 1 from the left and top: the part of the image to keep in frame when it is cropped. `null` means the centre. When the browser crops (`object-fit: cover`), set `object-position: {x*100}% {y*100}%`.
- `placeholder` is a tiny WebP data URL, for a blurred preview while the image loads.

Images Velora stores come from `https://delivery.velora.build/media/...`, which resizes them at the edge. Add parameters to the `url` as given:

| Parameter | Does |
| --- | --- |
| `w` | Width. Snapped up to 320, 640, 960, 1280, 1920 or 2560. |
| `dpr` | Pixel density, 1 to 3. Multiplies `w` before snapping. |
| `ar=W:H` or `h` | Crop to a shape (`ar=16:9`). |
| `fp=x,y` | The focal point to keep in frame when cropping. Pass `focalPoint`. |
| `fit` | `cover` (the default with a shape), `contain` or `scale-down` (the default without). |
| `q` | Quality, 30 to 95 in steps of 5. |
| `format=auto` | AVIF or WebP, as the browser accepts, else JPEG. |

```
https://delivery.velora.build/media/abc123/photo.jpg?w=960&ar=16:9&fp=0.42,0.3&format=auto
```

Media responses are immutable and cached for a year. Images whose `url` is on any other host (a product's picture from a shop, for example) are not resized by Velora: use them as they are, or through your own image service.
