Skip to main content
CMS

Checks

A check is a server-side function that inspects a doc and reports whether it's ready to publish, such as verifying SEO metadata or confirming every string is translated. Editors can run checks on demand in the doc editor, and collections can require them to pass before publishing.

Checks are currently in beta, so the API may change between versions.

Defining a check

Register checks through the checks option in cmsPlugin(). Each check has an id, a label, and a run() function that returns a status (success, warning, or error) along with a Markdown message:

ts
// @/root.config.ts

import {defineConfig} from '@blinkk/root';
import {cmsPlugin, translationsCheck} from '@blinkk/root-cms/plugin';

export default defineConfig({
  plugins: [
    cmsPlugin({
      // ...
      checks: [
        translationsCheck(),
        {
          id: 'seo-meta',
          label: 'SEO metadata',
          description: 'Checks that the doc has a meta title and description.',
          collections: ['Pages', 'BlogPosts'],
          run: async (ctx) => {
            const doc = await ctx.cmsClient.getRawDoc(
              ctx.collectionId,
              ctx.slug,
              {mode: 'draft'}
            );
            const meta = doc?.fields?.meta || {};
            if (!meta.title || !meta.description) {
              return {
                status: 'error',
                message: 'Add a `meta.title` and `meta.description`.',
              };
            }
            return {status: 'success', message: 'All good!'};
          },
        },
      ],
    }),
  ],
});

The ctx object passed to run() includes the doc's docId, collectionId, and slug, along with its collectionSchema, rootConfig, and a cmsClient for reading CMS data. Because checks run on the server, they can also call internal services or authenticated APIs.

Use collections to scope a check to specific collections. If omitted, the check applies to all of them.

Running checks in the editor

When a project has checks configured, a Checks button appears in the doc editor's status bar. Clicking it opens a panel with the checks for that collection so editors can run each one against the current draft and see its output.

Gating publishing

To run checks automatically during publishing, add them to publishing.checks in a collection's schema. Each entry can be a check ID string or an {id, level} object:

ts
// @/collections/Pages.schema.ts

import {schema} from '@blinkk/root-cms';

export default schema.collection({
  name: 'Pages',
  url: '/[...slug]',
  publishing: {
    checks: [
      // A bare id is a required check.
      'seo-meta',
      {id: 'root-cms/translations', level: 'warning'},
    ],
  },
  fields: [
    // ...
  ],
});

A required check (the default) blocks publishing if it returns an error. A warning check never blocks publishing; its message is shown after the doc goes live, and any error it returns is downgraded to a warning. You can make the same check required in one collection and a warning in another.

Checks run when a doc or release is published or scheduled. For a release, a failed required check on any doc blocks the entire release. Scheduled content is checked at scheduling time, not again when it goes live.

Admins can skip checks or publish even after a required check fails. Since publishing writes directly from the browser to Firestore, treat checks as a workflow guardrail rather than a security boundary. Every publish logs the check results (including skips and overrides) in the action's metadata. If a check throws an exception, only that check fails with an error, and unregistered check IDs are skipped.

Missing translations

translationsCheck() is a built-in check with the ID root-cms/translations. It scans a doc's translatable fields (those with translate: true) and flags any strings missing a translation for the doc's enabled locales. Pass {collections: ['Pages']} to limit it to specific collections.

1
2
3
4
5
6
7
8
9
10
11
12
Breakpoint: