Specification · Draft
Content profile
Draft 0.1 · not implemented · extends the intent spec
A content profile says which UI intent a piece of content renders as, which content a listing shows, and how each field reaches a prop. It does not define any components or any vocabulary. A site supplies those through four inputs (§1), and the profile validates its mappings against them.
The words MUST, SHOULD and MAY are used as in RFC 2119. Open questions are marked Open.
At a glance
content model ───┐
field list ───┼─► content profile ─► UI intents ─► components
naming rule ───┤ (mappings)
inventory ───┘Terms
- Content type: a kind of content in the site's model, such as an article or a topic.
- Item: one piece of content of a content type.
- Reader: the adapter that fetches items and reports which fields it fetched.
- Field path: a dotted path into an item, such as
image.url. Written in the model's own names. - Binding: what a content type or listing resolves to: a UI intent, props, and optionally a source and choices.
- Source: a query over items, rendered as a list of items.
- Choice: a rule that picks one of several candidate intents for an item or a listing.
- Derived value: a value computed from fields, such as a URL built from a slug.
1. Inputs
A site MUST supply all four inputs before the profile can validate. The profile MUST NOT assume any of them.
1.1 Content model
A description of the content types and their fields: name, kind (text, number, boolean, reference, asset, rich text, list), and for references the target type. It SHOULD be exported from the source system, not written by hand.
type ModelField = { name: string; kind: 'text' | 'number' | 'boolean' | 'reference' | 'asset' | 'richText' | 'list'; of?: string };
type ContentModel = Record<string, { fields: Record<string, ModelField> }>;1.2 Reader
The adapter that fetches items. It MUST report, for each content type and query, the field paths it fetches and the references it includes. Validation (§5, rule 2) uses this report, so a field the reader does not fetch is an error.
type Reader = {
query(contentType: string, options: { fields: string[]; include: string[]; limit: number | 'all'; sort?: string }): Promise<unknown[]>;
fieldsFor(contentType: string, query: string): { fields: string[]; include: string[] }; // the query contract
};1.3 Naming rule
How a model field name becomes the name the reader returns. A site MUST declare it, even if the rule is the identity.
type NamingRule = (modelName: string) => string; // e.g. strip a prefix, camel-caseField paths in bindings MUST use the model's names. The profile applies the naming rule when it checks a path against the item shape the component receives. Open: whether the item shape should instead be generated from the model, so the naming rule is applied once, by the reader.
1.4 Inventory
The components a site can render, with the props each one takes and whether each prop is required.
type Inventory = Record<string, { props: Record<string, { type: string; required: boolean }> }>;A prop typed record takes the whole item. A prop typed with a field type takes that field.
2. Bindings
A content type or a listing has one binding. The binding names the UI intent it resolves to and how its data reaches the component.
type FieldRef = string | { from: string; fallback?: unknown }; // a model field path, with an optional fallback
type Derived = { template: string; from: string[] }; // e.g. "/{slug}", placeholders are model fields
type Binding =
| { kind: 'fields'; component: string; props: Record<string, FieldRef | Derived> }
| { kind: 'record'; component: string; prop: string };- A
fieldsbinding maps each prop to a field path or a derived value. Every required prop MUST be covered. - A
recordbinding passes the whole item as one prop. It is the form for components that take the item.
Props not in the inventory MUST be an error. A component not in the inventory MUST be an error.
3. Sources and choices
3.1 Source
A listing's source is a query over items. It MUST state every part below. None of them may default silently.
type Source = {
model: string; // which content model the query runs against
contentType: string;
where?: Array<{ field: string; equals?: string | boolean; exists?: boolean }>;
terms?: { field: string; values: string[] | string; match: 'any' | 'all' };
limit: number | 'all'; // explicit; a number is a cap that is reported when reached
sort?: string; // a field, with a direction
onEmpty?: string; // the UI intent rendered when nothing matches
};- Multiple
whereconditions and multipletermsMUST combine with AND. - Within one
termsfield,match: 'any'is OR andmatch: 'all'is AND. limit: 'all'MUST fetch every item. A numericlimitMUST be reported as reached, not silently truncated.
Open: whether a taxonomy vocabulary is a terms field or a separate source type. A vocabulary's values are data a site supplies, so the profile MUST NOT ship them.
3.2 Choice
When more than one UI intent could render an item, a choice picks one. Its use MUST be one of the candidates the binding lists in refs.
type Choice = {
at: 'item' | 'listing'; // what the rule reads
when: { field: string; equals?: string | boolean; exists?: boolean };
use: string;
};at: 'item'reads a field of the item.at: 'listing'reads a field of the listing that contains it.- Choices MUST be checked in order. The first match wins. A choice set MUST name a default for when none match, and a choice set with no default MUST be an error.
Open: whether a choice should be a list of rules, as above, or a function. A list is checkable; a function is more flexible but cannot be checked without running it. This draft uses a list.
4. Resolution
Resolving a content item:
- Find its content type's binding.
- If the binding has choices, evaluate them (§3.2) against the item or the listing, and take the chosen intent.
- Map each prop from the item by its field path or derived value (§2), applying the naming rule.
- Pass the result to the chosen intent's component.
A content type with no binding MUST be reported as unmapped. It MUST NOT render nothing without a report.
Open: cross-profile merge. A content binding can sit on top of a UI intent's binding, but the spec defines merge per profile (§2 of the intent spec). The rule for layering a content profile's props on a UI profile's binding is not yet defined. Until it is, a content binding MUST name a single UI intent and map props only, and MUST NOT add to the UI binding.
5. Validation
A registry MUST run every rule below. Each failure is an error unless marked as a warning.
- Paths resolve. Every field path in a binding, source and choice resolves in the content model, through the naming rule.
- Paths are fetched. Every field path used by a binding or source is in the reader's field list for that query. A path the query does not fetch is an error. Included references are checked the same way.
- Components exist. Every
componentis in the inventory, and every required prop is covered by the binding. - Choices resolve. Every choice's
useis in the binding'srefs, and each choice set has a default. - Limits are explicit. Every source states
limit, and a numeric limit MUST be reported when reached (§3.1). - Unmapped types are reported. Every content type in the model with no binding is listed. This is a warning, not silence, so the list can be reviewed before a migration or a render.
- Derived placeholders resolve. Every placeholder in a derived template is a field in the model.
Rules 1 and 2 are separate on purpose. A path can exist in the model and still be missing from a query, which is how a card loses its date on one page and keeps it on another.
6. Example
A neutral model with an article type and a topic listing. The names are invented for this example.
// Model: article { title, summary, publishedOn, image: asset, slug, topics: reference[] }
const articleCard: Binding = {
kind: 'fields',
component: 'Card',
props: {
heading: 'title',
body: 'summary',
image: { from: 'image.url', fallback: '/placeholder.jpg' },
to: { template: '/articles/{slug}', from: ['slug'] },
},
};
const topicListing = {
source: {
model: 'site',
contentType: 'article',
terms: { field: 'topics', values: ['{topic}'], match: 'any' },
where: [{ field: 'publishedOn', exists: true }],
limit: 12,
sort: 'publishedOn desc',
onEmpty: 'message.noResults',
},
item: 'content.article',
};The Card component, its props and the fields above are assumed for the example. A real site supplies its own.
7. Conformance
None yet. Conformance tests will be added once the profile is implemented and has run on at least two sites with different content systems.