Reference Field Reference
fields.references()
Multi-template document references, sized and scoped by allowed template names. Not localizable.
Multi-template document references. Maps to editor { name: 'str-references', type: 'references' }: a sized, ordered list scoped by allowed template names.
fields.references() is for content the document owns, and a publish follows it through every level. To link to documents that stand on their own, such as related articles, use fields.related().
Stored as an array of document ids (string[]), in the list's order. That is the write shape Infer<> gives you:
{
"relatedContent": ["6f1c2e9a-4b7d-4f3e-9a21-8c5d7b3e0f12", "0b9e4d7c-2a1f-4c8e-b5d3-7e6f1a2c9d48"]
}At read time the content index replaces each id with the target document, so strife typegen emits Target[].
Example
fields.references({
label: 'Related content',
allow: ['article', 'video-post'],
size: 5,
})Options
| Option | Type | Required | Description |
|---|---|---|---|
label | string | Yes | Label shown to editors in Strife Studio. |
allow | string | readonly string[] | Yes | The defineType name(s) this field may reference. Emitted as wire options.availableTypes (normalized template names) and drives the generated read type. Pass several to allow a union. |
description | string | No | Shown as a note under the field while it is empty. |
propertyName | string | No | Override the stored property name. |
size | number | null | No | Maximum number of references. |
No localizable option.
Output type
Write shape: string[], the document ids in order. Generated read shape (via strife typegen): Target[].
See also
- References — the same editor, documented from the Strife Studio UI side.
fields.related()— one-way links on thestr-relatededitor, scoped by collection (to).