storytelling
Plot
Story arcs and quest trackers with progress markers
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 {
createComponentRenderable,
createContentModelSchema,
bodyOnly,
renderNodes,
} from '@refrakt-md/runes';
import { RenderableNodeCursor } from '@refrakt-md/runes';
import { taxonomyAttributes } from './common.js';
const MARKER_TO_STATUS: Record<string, string> = {
x: 'complete',
'>': 'active',
' ': 'planned',
'-': 'abandoned',
};
export const beat = createContentModelSchema({
attributes: {
label: { type: String, required: true },
status: { type: String, required: false },
description: { type: String, required: false },
id: { type: String, required: false },
track: { type: String, required: false },
follows: { type: String, required: false },
},
contentModel: bodyOnly(),
transform(resolved, attrs, config) {
const labelTag = new Tag('span', {}, [attrs.label ?? '']);
const resolvedStatus = MARKER_TO_STATUS[attrs.status] ?? (attrs.status || 'planned');
const statusMeta = new Tag('meta', { content: resolvedStatus });
const idMeta = new Tag('meta', { content: attrs.id ?? '' });
const trackMeta = new Tag('meta', { content: attrs.track ?? '' });
const followsMeta = new Tag('meta', { content: attrs.follows ?? '' });
const childContent = renderNodes(resolved.body, config);
const descText = (attrs.description ?? '').replace(/^[\s—–-]+/, '').trim();
const bodyChildren: any[] = [];
if (descText) {
bodyChildren.push(new Tag('p', {}, [descText]));
}
if (childContent.count() > 0) {
bodyChildren.push(...childContent.toArray());
}
const body = new RenderableNodeCursor(bodyChildren).wrap('div');
return createComponentRenderable({
rune: 'beat',
tag: 'li',
properties: {
status: statusMeta,
id: idMeta,
track: trackMeta,
follows: followsMeta,
},
refs: { label: labelTag, body: body.tag('div') },
children: [labelTag, body.next()],
});
},
});
const plotType = ['arc', 'quest', 'subplot', 'campaign', 'episode', 'act', 'chapter'] as const;
const structureType = ['linear', 'parallel', 'branching', 'web'] as const;
export const plotSections = { title: 'title' } as const;
export const plotSchema = {
type: 'CreativeWork',
properties: { title: 'name', plotType: 'genre' },
} as const;
export const plot = createContentModelSchema({
registers: {
entity: { idFrom: 'title', data: ['plotType', 'structure', 'tags', { name: 'title' }] },
},
schema: plotSchema,
sections: plotSections,
base: taxonomyAttributes,
attributes: {
title: { type: String, required: true, description: 'Heading displayed for this plot line.' },
type: {
type: String,
required: false,
matches: plotType.slice(),
description: 'Narrative scope: arc, quest, subplot, campaign, episode, act, or chapter.',
},
structure: {
type: String,
required: false,
matches: structureType.slice(),
description: 'How beats connect: linear (sequential), parallel, branching, or web.',
},
},
contentModel: {
type: 'sequence' as const,
fields: [
{ name: 'description', match: 'paragraph', optional: true, greedy: true },
{
name: 'beats',
match: 'list',
optional: true,
greedy: true,
itemModel: {
fields: [
{
name: 'marker',
match: 'text' as const,
pattern: /^\[(x|>|\s|-)\]\s*/,
optional: true,
},
{ name: 'label', match: 'strong' as const, optional: true },
{
name: 'description',
match: 'text' as const,
pattern: 'remainder' as const,
optional: true,
},
],
},
emitTag: 'beat',
emitAttributes: { label: '$label', status: '$marker', description: '$description' },
} as any,
],
},
transform(resolved, attrs, config) {
const descRendered = renderNodes(resolved.description, config);
const itemStream = renderNodes(resolved.beats, config);
const titleTag = new Tag('span', {}, [attrs.title ?? '']);
const plotTypeMeta = new Tag('meta', { content: attrs.type ?? 'arc' });
const structureMeta = new Tag('meta', { content: attrs.structure ?? 'linear' });
const tagsMeta = new Tag('meta', { content: attrs.tags ?? '' });
const beats = itemStream.tag('li').typeof('Beat');
const beatsList = new Tag('ol', {}, beats.toArray());
const children: any[] = [titleTag];
if (descRendered.count() > 0) {
children.push(...descRendered.toArray());
}
children.push(beatsList);
return createComponentRenderable({
rune: 'plot',
tag: 'section',
properties: {
plotType: plotTypeMeta,
structure: structureMeta,
tags: tagsMeta,
beat: beats,
},
refs: { title: titleTag, beats: beatsList },
children,
});
},
});
Story arcs, quests, and narrative structures, with progress tracked beat by beat. For real-world events in date order, use timeline.
Basic usage
{% plot title="The Warden's Seal" type="quest" structure="linear" %}
Elena must recover Lord Ashford's seal before Veshra uses it to open the gates of Thornwall.
- [x] **Discovery** — Find Ashford's last letter in the libraries of Hollowmere
- [x] **Departure** — Leave the valley by the cliff road at night
- [>] **Descent** — Bargain with the Whispering Hand for passage through the Undercroft
- [ ] **Confrontation** — Face Veshra beneath the city walls
- [-] **Alliance** — Win the Silver Order's support (refused by the Grand Master)
{% /plot %}<section data-rune="plot" data-rune-fields="{"plotType":"quest","structure":"linear","tags":""}" typeof="CreativeWork">
<span data-name="title" property="name">The Warden's Seal</span>
<p>Elena must recover Lord Ashford's seal before Veshra uses it to open the gates of Thornwall.</p>
<ol data-name="beats">
<li data-rune="beat" data-rune-fields="{"status":"complete","id":"","track":"","follows":""}" data-field="beat">
<span data-name="label">Discovery</span>
<div data-name="body">
<p>Find Ashford's last letter in the libraries of Hollowmere</p>
</div>
</li>
<li data-rune="beat" data-rune-fields="{"status":"complete","id":"","track":"","follows":""}" data-field="beat">
<span data-name="label">Departure</span>
<div data-name="body">
<p>Leave the valley by the cliff road at night</p>
</div>
</li>
<li data-rune="beat" data-rune-fields="{"status":"active","id":"","track":"","follows":""}" data-field="beat">
<span data-name="label">Descent</span>
<div data-name="body">
<p>Bargain with the Whispering Hand for passage through the Undercroft</p>
</div>
</li>
<li data-rune="beat" data-rune-fields="{"status":"planned","id":"","track":"","follows":""}" data-field="beat">
<span data-name="label">Confrontation</span>
<div data-name="body">
<p>Face Veshra beneath the city walls</p>
</div>
</li>
<li data-rune="beat" data-rune-fields="{"status":"abandoned","id":"","track":"","follows":""}" data-field="beat">
<span data-name="label">Alliance</span>
<div data-name="body">
<p>Win the Silver Order's support (refused by the Grand Master)</p>
</div>
</li>
</ol>
<meta property="genre" content="quest">
</section>Elena must recover Lord Ashford's seal before Veshra uses it to open the gates of Thornwall.
- Discovery
Find Ashford's last letter in the libraries of Hollowmere
- Departure
Leave the valley by the cliff road at night
- Descent
Bargain with the Whispering Hand for passage through the Undercroft
- Confrontation
Face Veshra beneath the city walls
- Alliance
Win the Silver Order's support (refused by the Grand Master)
<section class="rf-plot rf-plot--quest rf-plot--linear" typeof="CreativeWork" data-plot-type="quest" data-structure="linear" data-tags="" data-elevation="flat" data-rune="plot" data-density="full">
<div data-name="eyebrow" data-zone="eyebrow" data-zone-layout="bar" class="rf-plot__eyebrow">
<span data-meta-type="category" data-field="plotType">quest</span>
<span data-meta-type="category" data-align="end" data-field="structure">linear</span>
</div>
<span data-name="title" property="name" class="rf-plot__title" data-section="title">The Warden's Seal</span>
<p>Elena must recover Lord Ashford's seal before Veshra uses it to open the gates of Thornwall.</p>
<ol data-name="beats" data-sequence="connected" class="rf-plot__beats">
<li class="rf-beat rf-beat--complete" data-field="beat" data-status="complete" data-id="" data-track="" data-follows="" data-checked="checked" data-rune="beat" data-density="full">
<span data-name="label" class="rf-beat__label">Discovery</span>
<div data-name="body" class="rf-beat__body">
<p>Find Ashford's last letter in the libraries of Hollowmere</p>
</div>
</li>
<li class="rf-beat rf-beat--complete" data-field="beat" data-status="complete" data-id="" data-track="" data-follows="" data-checked="checked" data-rune="beat" data-density="full">
<span data-name="label" class="rf-beat__label">Departure</span>
<div data-name="body" class="rf-beat__body">
<p>Leave the valley by the cliff road at night</p>
</div>
</li>
<li class="rf-beat rf-beat--active" data-field="beat" data-status="active" data-id="" data-track="" data-follows="" data-checked="active" data-rune="beat" data-density="full">
<span data-name="label" class="rf-beat__label">Descent</span>
<div data-name="body" class="rf-beat__body">
<p>Bargain with the Whispering Hand for passage through the Undercroft</p>
</div>
</li>
<li class="rf-beat rf-beat--planned" data-field="beat" data-status="planned" data-id="" data-track="" data-follows="" data-checked="unchecked" data-rune="beat" data-density="full">
<span data-name="label" class="rf-beat__label">Confrontation</span>
<div data-name="body" class="rf-beat__body">
<p>Face Veshra beneath the city walls</p>
</div>
</li>
<li class="rf-beat rf-beat--abandoned" data-field="beat" data-status="abandoned" data-id="" data-track="" data-follows="" data-checked="skipped" data-rune="beat" data-density="full">
<span data-name="label" class="rf-beat__label">Alliance</span>
<div data-name="body" class="rf-beat__body">
<p>Win the Silver Order's support (refused by the Grand Master)</p>
</div>
</li>
</ol>
<meta property="genre" content="quest" />
</section>How Markdown is read
| You write | It becomes |
|---|---|
| Paragraphs before the list | The plot's description |
| A list item | A beat |
[x], [>], [ ] or [-] at the start of an item | The beat's status: complete, active, planned or abandoned |
| Bold text in the item | The beat's label; the text after it is the beat's description |
Plot types
type sets the plot's narrative scope — arc, quest, subplot, campaign, episode, act or chapter — and structure says how its beats connect: linear, parallel, branching or web. Both are shown in the plot's header, so a long-running campaign with branching beats reads differently from a single linear quest.
Attributes
| Attribute | Type | Required | Description |
|---|---|---|---|
title | string | ✓ | Heading displayed for this plot line. |
type | "arc" | "quest" | "subplot" | "campaign" | "episode" | "act" | "chapter" | — | Narrative scope: arc, quest, subplot, campaign, episode, act, or chapter. |
structure | "linear" | "parallel" | "branching" | "web" | — | How beats connect: linear (sequential), parallel, branching, or web. |
Inherited from the storytelling taxonomy preset
| Attribute | Type | Required | Description |
|---|---|---|---|
tags | string | — | Comma-separated keywords for filtering and cross-referencing. |
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) |
prominence
Header emphasis. Scales a rune's header, or its featured quotation; the theme decides the type size for each step.
| Attribute | Type | Required | Description |
|---|---|---|---|
prominence | "quiet" | "normal" | "prominent" | "display" | "marquee" | — | Emphasis of a page-section header or a featured quotation (only on runes that have one) |
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 |
beat
| Attribute | Type | Required | Description |
|---|---|---|---|
label | string | ✓ | |
status | string | — | |
description | string | — | |
id | string | — | |
track | string | — | |
follows | string | — |
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 |