core
Relationships
Render an entity's relationship edges, grouped by kind — the plural-graph counterpart to ref and expand, generic over any domain's relationship vocabulary
Source
import Markdoc from '@markdoc/markdoc';
const { Tag } = Markdoc;
import { createContentModelSchema, createComponentRenderable } from '../lib/index.js';
import { readDeferredBody } from '../deferred-body.js';
export const RELATIONSHIPS_SENTINEL = '__relationships-sentinel';
export const relationships = createContentModelSchema({
attributes: {
of: {
type: String,
required: false,
default: '',
description: 'Entity to describe — an id (e.g. `of=$item.id`) or a bound entity.',
},
kind: {
type: String,
required: false,
default: '',
description: 'Edge kinds to include, comma-separated (e.g. "blocks,blocked-by").',
},
type: {
type: String,
required: false,
default: '',
description: 'Restrict related entity types, comma-separated.',
},
group: {
type: String,
required: false,
default: 'kind',
description: 'Group-by: kind (default) | type | none.',
},
'group-display': {
type: String,
required: false,
default: 'headings',
matches: ['headings', 'accordion'],
description:
'How groups are presented: headings (default) or accordion (collapsible native <details> panels, styled like the accordion rune, with a per-group count).',
},
sort: {
type: String,
required: false,
default: '',
description: 'Sort related entities by a field (prefix - for descending).',
},
limit: { type: String, required: false, default: '', description: 'Max edges.' },
fields: {
type: String,
required: false,
default: '',
description: 'Comma-separated data fields to project in the no-body built-in.',
},
layout: {
type: String,
required: false,
default: 'list',
description:
'Arrangement: list (stacked) | grid (multi-column). Item chrome comes from the item — the no-body built-in, or a rune like {% card %} in the body template.',
},
empty: {
type: String,
required: false,
default: '',
description:
'Fallback text shown when there are no edges (no-body form; body form uses a fallback zone). Absent → render nothing.',
},
},
deferBody: true,
contentModel: { type: 'sequence', fields: [] },
transform(_resolved, attrs) {
const meta = (field: string, content: string) =>
new Tag('meta', { 'data-field': field, content });
const bodySource = readDeferredBody(attrs) ?? '';
const ofRaw = attrs.of as unknown;
const of =
ofRaw && typeof ofRaw === 'object'
? String((ofRaw as { id?: unknown }).id ?? '')
: String(ofRaw ?? '');
const metas = [
meta('relationships-of', of),
meta('relationships-kind', String(attrs.kind ?? '')),
meta('relationships-type', String(attrs.type ?? '')),
meta('relationships-group', String(attrs.group ?? 'kind')),
meta('relationships-group-display', String(attrs['group-display'] ?? 'headings')),
meta('relationships-sort', String(attrs.sort ?? '')),
meta('relationships-limit', String(attrs.limit ?? '')),
meta('relationships-fields', String(attrs.fields ?? '')),
meta('relationships-layout', String(attrs.layout ?? 'list')),
meta('relationships-empty', String(attrs.empty ?? '')),
meta(RELATIONSHIPS_SENTINEL, 'true'),
];
if (bodySource) metas.push(meta('relationships-body', bodySource));
const placeholder = new Tag('div', { 'data-name': 'items' }, []);
return createComponentRenderable({
rune: 'relationships',
tag: 'section',
properties: {},
refs: { items: placeholder },
children: [...metas, placeholder],
});
},
});
{% relationships %} renders the relationship edges of one entity — what it implements, what blocks it, who it allies with — grouped by kind. It's the graph counterpart to collection: where collection selects a set of entities by a field:value query, relationships projects the edges touching a single entity, read from the registry's relationship graph.
It's generic over the edge kind, which is an arbitrary string. Plugins contribute edges with their own vocabulary — plan emits implements / blocked-by / depends-on, storytelling's bond emits its type (ally, rival, mentor, …) — and relationships groups and labels whatever it finds. There is one generic rune, not a per-domain *-relationships.
Selecting edges — of + kind
of is the entity to describe, passed explicitly as an id (or a bound entity). With no body, edges are grouped by kind, each rendered as a title link to the related entity — the zero-config built-in:
{% relationships of="WORK-259" /%}<section data-rune="relationships">
<meta data-field="relationships-of" content="WORK-259">
<meta data-field="relationships-kind" content="">
<meta data-field="relationships-type" content="">
<meta data-field="relationships-group" content="kind">
<meta data-field="relationships-group-display" content="headings">
<meta data-field="relationships-sort" content="">
<meta data-field="relationships-limit" content="">
<meta data-field="relationships-fields" content="">
<meta data-field="relationships-layout" content="list">
<meta data-field="relationships-empty" content="">
<meta data-field="__relationships-sentinel" content="true">
<div data-name="items"></div>
</section>Implements
Dependency Of
Related
<section class="rf-relationships" data-of="WORK-259" data-layout="list" data-rune="relationships" data-density="full">
<div data-name="items" class="rf-relationships__items">
<div class="rf-relationships__group" data-group="implements">
<h3 class="rf-relationships__group-title">Implements</h3>
<div class="rf-relationships__item" data-entity-id="SPEC-066" data-kind="implements">
<span class="rf-relationships__title">Expand rune</span>
</div>
</div>
<div class="rf-relationships__group" data-group="dependency-of">
<h3 class="rf-relationships__group-title">Dependency Of</h3>
<div class="rf-relationships__item" data-entity-id="WORK-260" data-kind="dependency-of">
<span class="rf-relationships__title">Expand rune (resolver, extraction, level= demotion, canonical-link affordance)</span>
</div>
</div>
<div class="rf-relationships__group" data-group="related">
<h3 class="rf-relationships__group-title">Related</h3>
<div class="rf-relationships__item" data-entity-id="v0.15.0" data-kind="related">
<span class="rf-relationships__title">v0.15.0 — Composable embedding</span>
</div>
<div class="rf-relationships__item" data-entity-id="SPEC-060" data-kind="related">
<span class="rf-relationships__title">Drawer rune</span>
</div>
</div>
</div>
</section>Group headings are the kinds, humanized via the shared humanize function (blocked-by → "Blocked By") — no per-domain label table.
kind narrows to specific edge kinds (comma-separated), and type restricts the related entity types: kind="blocks,blocked-by" type="work,bug" keeps only dependency edges to work items and bugs. On a generated entity page, pass the page entity as of=$item.id — the same binding you'd hand to expand.
How Markdown is read
The body, when you give one, is a template rather than content to show as written:
| You write | It becomes |
|---|---|
A body with no --- | The template, rendered once per edge |
A body split by one --- | A preamble (above the edges, shown only when there are any), then the template |
A second --- | The part after it is the fallback, shown when there are no edges |
A --- inside a nested tag such as {% card %} | Part of that tag; it does not split the body |
Per-item templates
Give relationships a body and it becomes the per-edge template, transformed once per edge with $item bound to the related entity (the same contract as collection — id/type/url/data) and $kind bound to the edge kind:
{% relationships of="SPEC-066" type="work,bug" layout="grid" group="none" %}
{% card href=$item.url %}
{% humanize($kind) %} · {% $item.id %}
### {% $item.data.title %}
Status: {% $item.data.status %}
{% /card %}
{% /relationships %}<section data-rune="relationships">
<meta data-field="relationships-of" content="SPEC-066">
<meta data-field="relationships-kind" content="">
<meta data-field="relationships-type" content="work,bug">
<meta data-field="relationships-group" content="none">
<meta data-field="relationships-group-display" content="headings">
<meta data-field="relationships-sort" content="">
<meta data-field="relationships-limit" content="">
<meta data-field="relationships-fields" content="">
<meta data-field="relationships-layout" content="grid">
<meta data-field="relationships-empty" content="">
<meta data-field="__relationships-sentinel" content="true">
<meta data-field="relationships-body" content="{% card href=$item.url %}
{% humanize($kind) %} · {% $item.id %}
### {% $item.data.title %}
Status: {% $item.data.status %}
{% /card %}
">
<div data-name="items"></div>
</section>Implemented By · BUG-045
Embedded content's structured data is published again on every page that embeds it
Status: reported
Implemented By · WORK-259
Generic data-outline-scope walkers (TOC isolation + heading-ID namespacing)
Status: done
Implemented By · WORK-260
Expand rune (resolver, extraction, level= demotion, canonical-link affordance)
Status: done
Related · WORK-251
Plan plugin: unconditional scan, entity registration, fileRoots opt-in
Status: done
Related · WORK-257
Drawer rune (schema, transform, CSS)
Status: done
Related · WORK-302
xref preview="drawer" — mention an entity in prose, expand on demand
Status: done
<section class="rf-relationships" data-of="SPEC-066" data-layout="grid" data-rune="relationships" data-density="full">
<div data-name="items" class="rf-relationships__items">
<div class="rf-relationships__item" data-entity-id="BUG-045" data-kind="implemented-by" data-block="">
<div class="rf-card" data-media-position="top" data-rune="card" data-density="full">
<div data-name="content" class="rf-card__content">
<p data-name="eyebrow" class="rf-card__eyebrow" data-section="eyebrow">
Implemented By
·
BUG-045
</p>
<div data-name="body" class="rf-card__body" data-section="body">
<h3 id="embedded-contents-structured-data-is-published-again-on-every-page-that-embeds-it" data-name="title" class="rf-card__title">Embedded content's structured data is published again on every page that embeds it</h3>
<p>
Status:
reported
</p>
</div>
</div>
</div>
</div>
<div class="rf-relationships__item" data-entity-id="WORK-259" data-kind="implemented-by" data-block="">
<div class="rf-card" data-media-position="top" data-rune="card" data-density="full">
<div data-name="content" class="rf-card__content">
<p data-name="eyebrow" class="rf-card__eyebrow" data-section="eyebrow">
Implemented By
·
WORK-259
</p>
<div data-name="body" class="rf-card__body" data-section="body">
<h3 id="generic-data-outline-scope-walkers-toc-isolation-heading-id-namespacing" data-name="title" class="rf-card__title">Generic data-outline-scope walkers (TOC isolation + heading-ID namespacing)</h3>
<p>
Status:
done
</p>
</div>
</div>
</div>
</div>
<div class="rf-relationships__item" data-entity-id="WORK-260" data-kind="implemented-by" data-block="">
<div class="rf-card" data-media-position="top" data-rune="card" data-density="full">
<div data-name="content" class="rf-card__content">
<p data-name="eyebrow" class="rf-card__eyebrow" data-section="eyebrow">
Implemented By
·
WORK-260
</p>
<div data-name="body" class="rf-card__body" data-section="body">
<h3 id="expand-rune-resolver-extraction-level-demotion-canonical-link-affordance" data-name="title" class="rf-card__title">Expand rune (resolver, extraction, level= demotion, canonical-link affordance)</h3>
<p>
Status:
done
</p>
</div>
</div>
</div>
</div>
<div class="rf-relationships__item" data-entity-id="WORK-251" data-kind="related" data-block="">
<div class="rf-card" data-media-position="top" data-rune="card" data-density="full">
<div data-name="content" class="rf-card__content">
<p data-name="eyebrow" class="rf-card__eyebrow" data-section="eyebrow">
Related
·
WORK-251
</p>
<div data-name="body" class="rf-card__body" data-section="body">
<h3 id="plan-plugin-unconditional-scan-entity-registration-fileroots-opt-in" data-name="title" class="rf-card__title">Plan plugin: unconditional scan, entity registration, fileRoots opt-in</h3>
<p>
Status:
done
</p>
</div>
</div>
</div>
</div>
<div class="rf-relationships__item" data-entity-id="WORK-257" data-kind="related" data-block="">
<div class="rf-card" data-media-position="top" data-rune="card" data-density="full">
<div data-name="content" class="rf-card__content">
<p data-name="eyebrow" class="rf-card__eyebrow" data-section="eyebrow">
Related
·
WORK-257
</p>
<div data-name="body" class="rf-card__body" data-section="body">
<h3 id="drawer-rune-schema-transform-css" data-name="title" class="rf-card__title">Drawer rune (schema, transform, CSS)</h3>
<p>
Status:
done
</p>
</div>
</div>
</div>
</div>
<div class="rf-relationships__item" data-entity-id="WORK-302" data-kind="related" data-block="">
<div class="rf-card" data-media-position="top" data-rune="card" data-density="full">
<div data-name="content" class="rf-card__content">
<p data-name="eyebrow" class="rf-card__eyebrow" data-section="eyebrow">
Related
·
WORK-302
</p>
<div data-name="body" class="rf-card__body" data-section="body">
<h3 id="xref-previewdrawer-mention-an-entity-in-prose-expand-on-demand" data-name="title" class="rf-card__title">xref preview="drawer" — mention an entity in prose, expand on demand</h3>
<p>
Status:
done
</p>
</div>
</div>
</div>
</div>
</div>
</section>Because $item means the same thing here as in a collection body, the same card partials are reusable across both runes — a work-card.md partial works whether it's fed by a collection query or a relationship edge.
Grouping and ordering
group— defaults tokind(a heading per edge kind). Usegroup="type"to group by the related entity's type, orgroup="none"for a flat list.group-display—headings(default) oraccordion, exactly as incollection:accordionrenders each group as a collapsible native<details>panel styled like theaccordionrune, collapsed, with the group's edge count beside its label.sort— a field on the related entity (-field/field-descfor descending). Enum fields honor the same domain-aware ordering ascollection.limit— a positive integer cap.layout—list(default, stacked) orgrid(responsive multi-column), mirroringcollection. Withgroup, the grid arranges each group's edges into columns (the group title spans the row); item chrome comes from the item — the no-body built-in becomes a card, or use a{% card %}in the body template.
Empty state and body zones
Like collection, relationships supports an empty state and ----delimited body zones. The self-closing form takes an empty fallback, shown when the entity has no matching edges:
{% relationships of="SPEC-066" kind="blocked-by" empty="Nothing blocks this spec." /%}<section data-rune="relationships">
<meta data-field="relationships-of" content="SPEC-066">
<meta data-field="relationships-kind" content="blocked-by">
<meta data-field="relationships-type" content="">
<meta data-field="relationships-group" content="kind">
<meta data-field="relationships-group-display" content="headings">
<meta data-field="relationships-sort" content="">
<meta data-field="relationships-limit" content="">
<meta data-field="relationships-fields" content="">
<meta data-field="relationships-layout" content="list">
<meta data-field="relationships-empty" content="Nothing blocks this spec.">
<meta data-field="__relationships-sentinel" content="true">
<div data-name="items"></div>
</section><section class="rf-relationships" data-of="SPEC-066" data-layout="list" data-rune="relationships" data-density="full">
<div data-name="empty" class="rf-relationships__empty">Nothing blocks this spec.</div>
</section>With a body, split on a top-level --- into preamble (rendered above the edges only when there are any), template (the per-edge template), and fallback (shown when there are none) — so a "Relationships" heading can live inside the rune and disappear when the entity has no edges. The preamble and fallback can read $count (edges matched, pre-limit) and $shown (edges rendered, post-limit), just as in collection.
Where edges come from
relationships only renders the graph — it doesn't build it. Plugins contribute edges during the registry's aggregate phase, so the kinds you see depend on which plugins are installed. See plugin authoring → pipeline for the relate() / getRelated() contract.
Attributes
| Attribute | Type | Required | Description |
|---|---|---|---|
of | string | — | Entity to describe — an id (e.g. `of=$item.id`) or a bound entity. |
kind | string | — | Edge kinds to include, comma-separated (e.g. "blocks,blocked-by"). |
type | string | — | Restrict related entity types, comma-separated. |
group | string | — | Group-by: kind (default) | type | none. |
group-display | "headings" | "accordion" | — | How groups are presented: headings (default) or accordion (collapsible native <details> panels, styled like the accordion rune, with a per-group count). |
sort | string | — | Sort related entities by a field (prefix - for descending). |
limit | string | — | Max edges. |
fields | string | — | Comma-separated data fields to project in the no-body built-in. |
layout | string | — | Arrangement: list (stacked) | grid (multi-column). Item chrome comes from the item — the no-body built-in, or a rune like {% card %} in the body template. |
empty | string | — | Fallback text shown when there are no edges (no-body form; body form uses a fallback zone). Absent → render nothing. |
Universal attributes
bg
The background layer: image, video, gradient, flat overlay wash and legibility scrim, in a single injected layer behind the rune's content.
| Attribute | Type | Required | Description |
|---|---|---|---|
bg | string | — | Background preset applied to this block |
bg-from | string | — | Gradient start colour — a semantic token name (→ var(--rf-color-*)) |
bg-gradient | "to-t" | "to-b" | "to-l" | "to-r" | "to-tr" | "to-br" | "to-bl" | "to-tl" | — | Gradient direction (bounded named set) |
bg-gradient-type | "linear" | "radial" | "conic" | — | Gradient type |
bg-to | string | — | Gradient end colour — a semantic token name |
bg-via | string | — | Optional middle gradient stop — a semantic token name |
scrim | "top" | "bottom" | "left" | "right" | "none" | — | Scrim direction (heaviest edge); presence turns the scrim on, "none" opts out of the default cover scrim |
scrim-blur | "none" | "sm" | "md" | "lg" | — | Frost scrim blur amount |
scrim-strength | "sm" | "md" | "lg" | — | Gradient scrim strength |
scrim-tone | "dark" | "light" | — | Whether the scrim darkens (for light text) or lightens (for dark text) |
scrim-type | "gradient" | "frost" | — | Scrim treatment: gradient (default) or frost (backdrop blur) |
elevation
How far the rune sits off the page, from sunken to overlay. The theme decides what each step looks like.
| Attribute | Type | Required | Description |
|---|---|---|---|
elevation | "sunken" | "flush" | "flat" | "raised" | "floating" | "overlay" | "none" | "sm" | "md" | "lg" | — | Surface depth, from sunken to overlay. Deprecated: none, sm, md and lg (read as flat, raised, raised and floating) |
inset
Internal padding override.
| Attribute | Type | Required | Description |
|---|---|---|---|
inset | "flush" | "tight" | "default" | "loose" | "breathe" | — | Inner padding of this block |
motion
Scroll-reveal entrance. You choose its character; the theme decides how it moves.
| Attribute | Type | Required | Description |
|---|---|---|---|
reveal | "none" | "fade" | "slide" | "scale" | "blur" | — | Scroll-reveal entrance character (none|fade|slide|scale|blur); the theme owns the choreography |
stagger | boolean | — | Cascade this block's items in as it reveals (no-op on single-child runes) |
spacing
Block-level rhythm override.
| Attribute | Type | Required | Description |
|---|---|---|---|
spacing | "flush" | "tight" | "default" | "loose" | "breathe" | — | Vertical spacing above and below this block |
substrate
Generated pattern fills behind the content, drawn by the theme.
| Attribute | Type | Required | Description |
|---|---|---|---|
substrate | "dots" | "grid" | "lines" | "cross" | "checker" | "none" | — | Generated surface pattern |
substrate-fill | "inherit" | "inset" | — | Surface fill the pattern sits on (full colour stays with tint) |
substrate-opacity | "sm" | "md" | "lg" | — | Pattern ink strength |
substrate-size | "sm" | "md" | "lg" | — | Pattern cell size |
substrate-target | "self" | "media" | — | Which surface the pattern fills (overrides the rune/theme default) |
tint
Per-rune colour override: a named tint from the theme registry, with inline per-token overrides layered on top.
| Attribute | Type | Required | Description |
|---|---|---|---|
tint | string | — | Color tint preset applied to this block |
tint-mode | "auto" | "dark" | "light" | — | Whether the tint adapts to auto, dark, or light mode |
width
The track a block rune occupies.
| Attribute | Type | Required | Description |
|---|---|---|---|
width | "compact" | "narrow" | "content" | "wide" | "full" | — | Maximum width constraint for this block |
| Not available | Why |
|---|---|
| dropcap, reading | this rune declares no prose body |
| frame | this rune declares neither a `frameTarget` nor a media section |
| prominence | this rune has no page-section header or featured quotation |
See also
- collection — the field-query counterpart; shares
$item, layout, grouping, and ordering. - ref / expand — the singular counterparts (one entity → a link / inlined content).
- card — the generic content card you feed with
$itemin a body template.