barakoCMS

Presets

Presets

A preset is a named block saved as data, not code: a few props and an arrangement of primitives that reads them through the props scope. A designer saves one in barakoBrew and every site on the published image can use it, with no barakoPress release.

{
  "type": "band",
  "label": "Band",
  "fields": [
    { "name": "heading", "kind": "text", "required": true },
    { "name": "tone", "kind": "select", "options": ["page", "accent"] },
    { "name": "content", "kind": "slots" }
  ],
  "blocks": [
    { "type": "section", "props": { "tone": "{{props.tone}}", "content": [[
      { "type": "text", "props": { "value": "{{props.heading}}", "variant": "title" } },
      { "type": "slot", "props": { "name": "content" } }
    ]] } }
  ]
}

A preset's fields may be lists and groups, in the same shape a block declares them, and {{props.x}} of a list passes the list itself into a primitive's list field:

{
  "type": "taglines",
  "fields": [{ "name": "words", "kind": "list", "max": 8, "item": { "kind": "text" } }],
  "blocks": [{ "type": "rotatingText", "props": { "words": "{{props.words}}" } }]
}

A request-time site reads its tenant's presets from the Presets site setting. A build-time site passes them as presets in the config. /api/blocks lists a tenant's own presets beside the shipped ones when it is mounted with the config. A preset never replaces a block that is code. It does replace a preset, which is how a tenant adjusts one of the shipped blocks below without waiting for a release. A preset body may not use another preset saved in the same pass, so a cycle cannot form; it may use one compiled earlier, which is how a tenant's own block builds on a shipped one. slot marks where the content an editor dropped into the preset goes, and that content binds in the page's scope rather than the preset's.

A preset that is not used says why, once, in the server log, with one line per reason rather than one catchall: an entry that is not a preset, a type that is not a name, a type an earlier preset already uses, a field list that is not a list, fields inside it that are not fields, a name a registered block already has, and the presets past the point where a tenant's bodies hold more than 400 blocks between them. A setting that quietly does nothing reads as done, which is worse than one that is missing. A bad paste is spelled out five times and then counted.