Brease Docs

content.schema.json

Describe each page template's fields so Brease can check content before it's saved.

content.schema.json is optional. It sits at the site's root folder (the root directory set in the site's setup, in a monorepo) and is a JSON Schema with one $defs entry per page template (definitions works too).

content.schema.json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [{ "$ref": "#/$defs/home" }, { "$ref": "#/$defs/page" }, { "$ref": "#/$defs/global" }],
  "$defs": {
    "link": {
      "type": "object",
      "required": ["label", "href"],
      "properties": { "label": { "type": "string" }, "href": { "type": "string" } }
    },
    "html": {
      "type": "string",
      "description": "HTML: <p>, <h2>, <h3>, <ul>/<ol>, <blockquote>; <strong>, <em> and <a href> inline"
    },
    "page": {
      "type": "object",
      "required": ["template", "title", "intro", "body"],
      "properties": {
        "template": { "const": "page" },
        "title": { "type": "string" },
        "intro": { "type": "string" },
        "body": { "$ref": "#/$defs/html" }
      }
    }
  }
}

How it's used

  • A page's content.template picks the $defs entry it's checked against. Content without a matching template is checked against the root schema.
  • Every content change from the editor or the AI is checked, and again before publishing. Only errors a change introduces block it, so a site whose existing content doesn't match yet can still be edited.
  • Page sections are also checked against their own section types (see Sections), on top of this schema.
  • The AI reads one template at a time (get_content_schema), including the $defs it references. Write descriptions for fields whose format isn't obvious.

Rich text tags

A rich text field can name the HTML tags it allows with x-brease-html:

"body": { "type": "string", "x-brease-html": ["p", "h2", "h3", "ul", "ol", "li", "strong", "em", "a"] }

The editor's toolbar then offers only those tags, and a change that uses any other tag is rejected with the tags it used. <br> and <span> are always allowed. Without the keyword, any tag is accepted.

Tips

  • Keep a TypeScript mirror of the schema (the starter has src/lib/content.ts) and change both together.
  • Brease compiles the schema in non-strict mode, so unknown keywords are ignored rather than rejected.
  • When you add a template, add it to the schema, the types and the templates file in the same change. BREASE.md is a good place to say so.

On this page