storytelling
Bond
Relationship connections between characters or entities
Install
- Add the package:
npm install @refrakt-md/storytelling - Add it to the
pluginsarray inrefrakt.config.json:"plugins": ["@refrakt-md/storytelling"]
Source
import Markdoc from '@markdoc/markdoc';
const { Tag } = Markdoc;
import {
createContentModelSchema,
bodyOnly,
createComponentRenderable,
renderNodes,
} from '@refrakt-md/runes';
export const bondSections = { body: 'body' } as const;
export const bond = createContentModelSchema({
registers: {
edge: {
from: 'from',
to: 'to',
kind: { field: 'bondType' },
bidirectional: { field: 'bidirectional' },
data: ['bondType', 'status', 'bidirectional'],
},
},
sections: bondSections,
provides: ['prose'],
attributes: {
from: {
type: String,
required: true,
description: 'Name of the first character or entity in this bond.',
},
to: {
type: String,
required: true,
description: 'Name of the second character or entity in this bond.',
},
type: {
type: String,
required: false,
description: 'Kind of relationship (e.g. ally, rival, mentor, sibling).',
},
status: {
type: String,
required: false,
description: 'Current state of the bond (e.g. active, broken, strained).',
},
bidirectional: {
type: Boolean,
required: false,
description: 'Enable/disable mutual connection between both entities.',
},
},
contentModel: bodyOnly(),
transform(resolved, attrs, config) {
const fromTag = new Tag('span', {}, [attrs.from ?? '']);
const toTag = new Tag('span', {}, [attrs.to ?? '']);
const connector = new Tag('div', { 'data-name': 'connector' }, [
new Tag('span', { 'data-name': 'arrow' }),
]);
const bondTypeMeta = new Tag('meta', { content: attrs.type ?? '' });
const statusMeta = new Tag('meta', { content: attrs.status ?? 'active' });
const bidirectionalMeta = new Tag('meta', { content: String(attrs.bidirectional ?? true) });
const body = renderNodes(resolved.body, config).wrap('div');
return createComponentRenderable({
rune: 'bond',
tag: 'div',
properties: {
bondType: bondTypeMeta,
status: statusMeta,
bidirectional: bidirectionalMeta,
},
refs: {
from: fromTag,
to: toTag,
connector,
body: body.tag('div'),
},
children: [fromTag, connector, toTag, body.next()],
});
},
});
Content within the rune describes the nature and history of the relationship.
Basic usage
Define a relationship between two entities with a type and status.
{% bond from="Elena" to="Veshra" type="rival" status="strained" %}
They studied side by side at the Ashen Spire until Veshra turned to necromancy. Elena still keeps the letters they wrote each other, and still hopes to bring her back.
{% /bond %}<div data-rune="bond" data-rune-fields="{"bondType":"rival","status":"strained","bidirectional":"true"}">
<span data-name="from">Elena</span>
<div data-name="connector">
<span data-name="arrow"></span>
</div>
<span data-name="to">Veshra</span>
<div data-name="body">
<p>They studied side by side at the Ashen Spire until Veshra turned to necromancy. Elena still keeps the letters they wrote each other, and still hopes to bring her back.</p>
</div>
</div>They studied side by side at the Ashen Spire until Veshra turned to necromancy. Elena still keeps the letters they wrote each other, and still hopes to bring her back.
<div class="rf-bond rf-bond--rival rf-bond--strained rf-bond--true" data-bond-type="rival" data-status="strained" data-bidirectional="true" data-elevation="flat" data-rune="bond" data-density="full">
<span data-name="from" class="rf-bond__from">Elena</span>
<div data-name="connector" class="rf-bond__connector">
<span data-name="arrow" class="rf-bond__arrow"></span>
</div>
<span data-name="to" class="rf-bond__to">Veshra</span>
<div data-name="body" class="rf-bond__body" data-section="body">
<p>They studied side by side at the Ashen Spire until Veshra turned to necromancy. Elena still keeps the letters they wrote each other, and still hopes to bring her back.</p>
</div>
</div>One-directional bonds
Set bidirectional to false for one-way relationships like mentorship or unrequited feelings.
{% bond from="Veshra" to="Elena" type="obsession" status="active" bidirectional=false %}
Veshra has followed Elena's every move since the Spire fell, through informants in the Whispering Hand. Elena has no idea.
{% /bond %}<div data-rune="bond" data-rune-fields="{"bondType":"obsession","status":"active","bidirectional":"false"}">
<span data-name="from">Veshra</span>
<div data-name="connector">
<span data-name="arrow"></span>
</div>
<span data-name="to">Elena</span>
<div data-name="body">
<p>Veshra has followed Elena's every move since the Spire fell, through informants in the Whispering Hand. Elena has no idea.</p>
</div>
</div>Veshra has followed Elena's every move since the Spire fell, through informants in the Whispering Hand. Elena has no idea.
<div class="rf-bond rf-bond--obsession rf-bond--active rf-bond--false" data-bond-type="obsession" data-status="active" data-bidirectional="false" data-elevation="flat" data-rune="bond" data-density="full">
<span data-name="from" class="rf-bond__from">Veshra</span>
<div data-name="connector" class="rf-bond__connector">
<span data-name="arrow" class="rf-bond__arrow"></span>
</div>
<span data-name="to" class="rf-bond__to">Elena</span>
<div data-name="body" class="rf-bond__body" data-section="body">
<p>Veshra has followed Elena's every move since the Spire fell, through informants in the Whispering Hand. Elena has no idea.</p>
</div>
</div>In the relationship graph
Every bond is also an edge in the site's relationship graph, with its type as the edge kind (bond when it has none). relationships lists it on both characters' pages, or only on the from side when bidirectional is false. from and to may name a character by any of its aliases. A bond whose from or to names no character, realm, faction, lore or plot is reported as a build warning and left out of the graph.
Attributes
| Attribute | Type | Required | Description |
|---|---|---|---|
from | string | ✓ | Name of the first character or entity in this bond. |
to | string | ✓ | Name of the second character or entity in this bond. |
type | string | — | Kind of relationship (e.g. ally, rival, mentor, sibling). |
status | string | — | Current state of the bond (e.g. active, broken, strained). |
bidirectional | boolean | — | Enable/disable mutual connection between both entities. |
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) |
dropcap
Per-instance drop-cap opt-in.
| Attribute | Type | Required | Description |
|---|---|---|---|
dropcap | boolean | — | Style the opening letter of a prose body as a drop cap. Honoured only when the body reads as prose; ignored otherwise. |
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) |
reading
Editorial register for body text. You pick the register; the theme decides how it looks.
| Attribute | Type | Required | Description |
|---|---|---|---|
reading | "fine" | "ui" | "prose" | — | Reading register for this block’s body: fine | ui | prose. The theme sets how each one looks. |
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 |
|---|---|
| frame | this rune declares neither a `frameTarget` nor a media section |
| prominence | this rune has no page-section header or featured quotation |