Content Engine
Publication & Editorial
Add draft/published lifecycles, revision histories, signed preview links, and scheduled publishing to content types.
Content Engine includes complete editorial workflows: draft and published states, historical revisions with one-click restore, signed reviewer preview URLs, and automated scheduled publishing.
Quick start
Enable publication, public API, and editorial workflows in your content type definition:
import { defineContentType, field } from "@vitnode/core/content"
export const blogPostContentType = defineContentType({
id: "blog.post",
tableName: "blog_posts",
publication: { enabled: true },
publicApi: {
path: "/posts",
fields: ["title"],
},
editorial: {
enabled: true,
revisions: { retention: 20 }, // Store up to 20 historical versions
preview: { enabled: true, expiresInMinutes: 60 },
scheduling: { enabled: true },
},
fields: {
title: field.text({ required: true }),
},
})Editorial Features
1. Publication Lifecycle
When publication: { enabled: true } is configured:
- Records carry a
statuscolumn ("draft"or"published") and apublishedAttimestamp. - Unauthenticated public queries automatically filter out drafts, returning only records where
status = "published". - Publishing is idempotent: the first publish stamps
publishedAt, while subsequent edits preserve the original publication date. - The service exposes typed
publish(id)andunpublish(id)methods.
2. Revision History
When editorial: { enabled: true } is configured:
- Adds a
versioncolumn to the database table (defaults to 1 and increments on each restore). - Each save stores an immutable snapshot in the centralized
core_content_revisionstable. revisions.retentionsets the maximum number of revisions kept per record (1–500, default: 50).- Editors can inspect diffs between any historical snapshot and the current record state.
- One-click restore reinstates previous content while incrementing the version and emitting a
content.${id}.restoredevent.
3. Signed Preview Links
Share unpublished drafts with stakeholders who lack AdminCP accounts:
- Prerequisite:
publicApimust be configured on the content type, because preview projections rely onpublicApi.fields. - Generates HMAC-signed URLs valid for a customizable duration (
expiresInMinutes: 1–1440, default: 15). - Optional
pathTemplateallows custom preview URL routing (e.g."/preview/posts/{id}"). - Public frontend routes verify the preview token and stream the draft.
4. Scheduled Publishing
Pick a future release date and time for automatic publishing or unpublishing:
- Prerequisite:
publication: { enabled: true }must be enabled. - The background cron worker checks scheduled items periodically.
- Transitions records between
draftandpublishedat the specified timestamp and emitscontent.${id}.scheduledorcontent.${id}.schedule_cancelledevents.
Configuration Reference
| Option | Type | Default | Description |
|---|---|---|---|
publication.enabled | boolean | false | Enables status and publishedAt lifecycle columns. |
editorial.enabled | boolean | false | Enables version tracking and revisions. |
editorial.revisions.retention | number | 50 | Maximum historical revisions preserved per item (1–500). |
editorial.preview.enabled | boolean | false | Enables signed preview links. Requires publicApi. |
editorial.preview.expiresInMinutes | number | 15 | Expiration time for signed preview links in minutes (1–1440). |
editorial.preview.pathTemplate | string | — | Custom URL template for preview links. |
editorial.scheduling.enabled | boolean | false | Enables scheduled publication/unpublication. Requires publication.enabled: true. |