Business›Timeline

business

Timeline

Chronological events displayed as a timeline

Install

  1. Add the package: npm install @refrakt-md/business
  2. Add it to the plugins array in refrakt.config.json: "plugins": ["@refrakt-md/business"]

About the plugin and its runes

Source

import Markdoc from '@markdoc/markdoc';
import type { RenderableTreeNode } from '@markdoc/markdoc';
const { Tag } = Markdoc;
import {
	createComponentRenderable,
	createContentModelSchema,
	bodyOnly,
	asNodes,
	renderNodes,
	RenderableNodeCursor,
	pageSectionProperties,
} from '@refrakt-md/runes';

export const timelineEntrySchema = {
	type: 'ListItem',
	properties: { label: 'name', date: 'description' },
} as const;

export const timelineEntry = createContentModelSchema({
	schema: timelineEntrySchema,
	attributes: {
		date: {
			type: String,
			required: false,
			description: 'Date or time shown on this entry (e.g. "2024-03", "Q1 2025").',
		},
		label: {
			type: String,
			required: false,
			description: 'Short title or milestone name for the entry.',
		},
	},
	contentModel: bodyOnly(),
	transform(resolved, attrs, config) {
		const dateTag = new Tag('time', {}, [attrs.date ?? '']);
		const labelTag = new Tag('span', {}, [attrs.label ?? '']);
		const body = renderNodes(resolved.body, config).wrap('div');

		return createComponentRenderable({
			rune: 'timeline-entry',
			tag: 'li',
			refs: {
				date: dateTag,
				label: labelTag,
				body: body.tag('div'),
			},
			children: [dateTag, labelTag, body.next()],
		});
	},
});

export const timelineSections = {
	preamble: 'preamble',
	headline: 'title',
	blurb: 'description',
} as const;

export const timelineSchema = {
	type: 'ItemList',
	lists: ['itemListElement'],
	children: {
		'timeline-entry': {
			type: 'ListItem',
			property: 'itemListElement',
			generated: { position: 'index' },
		},
	},
} as const;

export const timeline = createContentModelSchema({
	schema: timelineSchema,
	sections: timelineSections,
	attributes: {
		direction: {
			type: String,
			required: false,
			description: 'Axis along which entries are laid out (vertical or horizontal).',
		},
	},
	contentModel: () => ({
		type: 'sections' as const,
		sectionHeading: 'heading',
		emitTag: 'timeline-entry',
		emitAttributes: { date: '$date', label: '$label' },
		headingExtract: {
			fields: [
				{ name: 'date', match: 'text' as const, pattern: /^(.+?)\s*[-–—:]\s*/, optional: true },
				{ name: 'label', match: 'text' as const, pattern: 'remainder' as const },
			],
		},
		fields: [
			{ name: 'header', match: 'heading|paragraph', optional: true, greedy: true },
			{ name: 'items', match: 'tag', optional: true, greedy: true },
		],
		sectionModel: {
			type: 'sequence' as const,
			fields: [{ name: 'body', match: 'any', optional: true, greedy: true }],
		},
	}),
	transform(resolved, attrs, config) {
		const headerNodes = renderNodes(resolved.header, config);
		const allItems = [...asNodes(resolved.items), ...asNodes(resolved.sections)];
		const sectionNodes = new RenderableNodeCursor(
			Markdoc.transform(allItems, config) as RenderableTreeNode[],
		);
		const directionMeta = new Tag('meta', { content: attrs.direction ?? 'vertical' });

		const items = sectionNodes.tag('li').typeof('TimelineEntry');

		const entriesList = new Tag('ol', {}, items.toArray());

		const children: any[] = [];
		if (headerNodes.count() > 0) {
			children.push(headerNodes.wrap('header').next());
		}
		children.push(entriesList);

		return createComponentRenderable({
			rune: 'timeline',
			tag: 'section',
			properties: {
				direction: directionMeta,
				entry: items,
			},
			refs: { ...pageSectionProperties(headerNodes), entries: entriesList },
			children,
		});
	},
});

View plugins/business/src/tags/timeline.ts on GitHub

Chronological events: a company's history, a project's milestones, a roadmap. For a product's release notes, use changelog; for instructions a reader follows in order, steps; for a story's arc, plot.

Heading-based timeline

{% timeline %}
## 2015 - Founded

Acme Coffee opened its first café on Main Street, Portland, roasting in the back room.

## 2019 - Roastery

Moved roasting to a dedicated roastery and began supplying twelve local restaurants.

## 2024 - Subscription

Launched a coffee subscription, now shipping fresh roasts to 10,000 homes.
{% /timeline %}
<section data-rune="timeline" data-rune-fields="{&quot;direction&quot;:&quot;vertical&quot;}" typeof="ItemList" data-schema-lists="[&quot;itemListElement&quot;]">
  <ol data-name="entries">
    <li data-rune="timeline-entry" typeof="ListItem" data-field="entry" property="itemListElement">
      <time data-name="date" property="description">2015</time>
      <span data-name="label" property="name">Founded</span>
      <div data-name="body">
        <p>Acme Coffee opened its first café on Main Street, Portland, roasting in the back room.</p>
      </div>
      <meta property="position" content="1">
    </li>
    <li data-rune="timeline-entry" typeof="ListItem" data-field="entry" property="itemListElement">
      <time data-name="date" property="description">2019</time>
      <span data-name="label" property="name">Roastery</span>
      <div data-name="body">
        <p>Moved roasting to a dedicated roastery and began supplying twelve local restaurants.</p>
      </div>
      <meta property="position" content="2">
    </li>
    <li data-rune="timeline-entry" typeof="ListItem" data-field="entry" property="itemListElement">
      <time data-name="date" property="description">2024</time>
      <span data-name="label" property="name">Subscription</span>
      <div data-name="body">
        <p>Launched a coffee subscription, now shipping fresh roasts to 10,000 homes.</p>
      </div>
      <meta property="position" content="3">
    </li>
  </ol>
</section>
  1. Acme Coffee opened its first café on Main Street, Portland, roasting in the back room.

  2. Moved roasting to a dedicated roastery and began supplying twelve local restaurants.

  3. Launched a coffee subscription, now shipping fresh roasts to 10,000 homes.

<section class="rf-timeline rf-timeline--vertical" typeof="ItemList" data-schema-lists="[&quot;itemListElement&quot;]" data-direction="vertical" data-elevation="flat" data-rune="timeline" data-density="full">
  <ol data-name="entries" data-sequence="connected" data-sequence-direction="vertical" class="rf-timeline__entries">
    <li class="rf-timeline-entry" typeof="ListItem" data-field="entry" property="itemListElement" data-rune="timeline-entry" data-density="full">
      <time data-name="date" property="description" class="rf-timeline-entry__date">2015</time>
      <span data-name="label" property="name" class="rf-timeline-entry__label">Founded</span>
      <div data-name="body" class="rf-timeline-entry__body">
        <p>Acme Coffee opened its first café on Main Street, Portland, roasting in the back room.</p>
      </div>
      <meta property="position" content="1" />
    </li>
    <li class="rf-timeline-entry" typeof="ListItem" data-field="entry" property="itemListElement" data-rune="timeline-entry" data-density="full">
      <time data-name="date" property="description" class="rf-timeline-entry__date">2019</time>
      <span data-name="label" property="name" class="rf-timeline-entry__label">Roastery</span>
      <div data-name="body" class="rf-timeline-entry__body">
        <p>Moved roasting to a dedicated roastery and began supplying twelve local restaurants.</p>
      </div>
      <meta property="position" content="2" />
    </li>
    <li class="rf-timeline-entry" typeof="ListItem" data-field="entry" property="itemListElement" data-rune="timeline-entry" data-density="full">
      <time data-name="date" property="description" class="rf-timeline-entry__date">2024</time>
      <span data-name="label" property="name" class="rf-timeline-entry__label">Subscription</span>
      <div data-name="body" class="rf-timeline-entry__body">
        <p>Launched a coffee subscription, now shipping fresh roasts to 10,000 homes.</p>
      </div>
      <meta property="position" content="3" />
    </li>
  </ol>
</section>

How Markdown is read

You writeIt becomes
A heading such as 2023 - FoundedAn entry; the text before the first dash or colon is its date, the rest its label
The content under the heading, up to the next oneThe entry's description
A short paragraph, then a heading one level above the entries and a paragraph, before the first entryThe eyebrow, headline and blurb (Page sections)

Explicit entries

Use {% timeline-entry %} tags for more control over date and label values.

{% timeline %}
	{% timeline-entry date="Q1 2024" label="Subscription pilot" %}
	Two hundred regulars tried a fortnightly delivery from the Main Street café.
	{% /timeline-entry %}

	{% timeline-entry date="Q3 2024" label="Nationwide launch" %}
	The subscription opened to every US address, with roast-to-door in three days.
	{% /timeline-entry %}
{% /timeline %}
<section data-rune="timeline" data-rune-fields="{&quot;direction&quot;:&quot;vertical&quot;}" typeof="ItemList" data-schema-lists="[&quot;itemListElement&quot;]">
  <ol data-name="entries">
    <li data-rune="timeline-entry" typeof="ListItem" data-field="entry" property="itemListElement">
      <time data-name="date" property="description">Q1 2024</time>
      <span data-name="label" property="name">Subscription pilot</span>
      <div data-name="body">
        <p>Two hundred regulars tried a fortnightly delivery from the Main Street café.</p>
      </div>
      <meta property="position" content="1">
    </li>
    <li data-rune="timeline-entry" typeof="ListItem" data-field="entry" property="itemListElement">
      <time data-name="date" property="description">Q3 2024</time>
      <span data-name="label" property="name">Nationwide launch</span>
      <div data-name="body">
        <p>The subscription opened to every US address, with roast-to-door in three days.</p>
      </div>
      <meta property="position" content="2">
    </li>
  </ol>
</section>
  1. Two hundred regulars tried a fortnightly delivery from the Main Street café.

  2. The subscription opened to every US address, with roast-to-door in three days.

<section class="rf-timeline rf-timeline--vertical" typeof="ItemList" data-schema-lists="[&quot;itemListElement&quot;]" data-direction="vertical" data-elevation="flat" data-rune="timeline" data-density="full">
  <ol data-name="entries" data-sequence="connected" data-sequence-direction="vertical" class="rf-timeline__entries">
    <li class="rf-timeline-entry" typeof="ListItem" data-field="entry" property="itemListElement" data-rune="timeline-entry" data-density="full">
      <time data-name="date" property="description" class="rf-timeline-entry__date">Q1 2024</time>
      <span data-name="label" property="name" class="rf-timeline-entry__label">Subscription pilot</span>
      <div data-name="body" class="rf-timeline-entry__body">
        <p>Two hundred regulars tried a fortnightly delivery from the Main Street café.</p>
      </div>
      <meta property="position" content="1" />
    </li>
    <li class="rf-timeline-entry" typeof="ListItem" data-field="entry" property="itemListElement" data-rune="timeline-entry" data-density="full">
      <time data-name="date" property="description" class="rf-timeline-entry__date">Q3 2024</time>
      <span data-name="label" property="name" class="rf-timeline-entry__label">Nationwide launch</span>
      <div data-name="body" class="rf-timeline-entry__body">
        <p>The subscription opened to every US address, with roast-to-door in three days.</p>
      </div>
      <meta property="position" content="2" />
    </li>
  </ol>
</section>

Attributes

AttributeTypeRequiredDescription
directionstring—Axis along which entries are laid out (vertical or horizontal).

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.

AttributeTypeRequiredDescription
bgstring—Background preset applied to this block
bg-fromstring—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-tostring—Gradient end colour — a semantic token name
bg-viastring—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.

AttributeTypeRequiredDescription
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.

AttributeTypeRequiredDescription
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.

AttributeTypeRequiredDescription
reveal"none" | "fade" | "slide" | "scale" | "blur"—Scroll-reveal entrance character (none|fade|slide|scale|blur); the theme owns the choreography
staggerboolean—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.

AttributeTypeRequiredDescription
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.

AttributeTypeRequiredDescription
spacing"flush" | "tight" | "default" | "loose" | "breathe"—Vertical spacing above and below this block
substrate

Generated pattern fills behind the content, drawn by the theme.

AttributeTypeRequiredDescription
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.

AttributeTypeRequiredDescription
tintstring—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.

AttributeTypeRequiredDescription
width"compact" | "narrow" | "content" | "wide" | "full"—Maximum width constraint for this block
Not availableWhy
dropcap, readingthis rune declares no prose body
framethis rune declares neither a `frameTarget` nor a media section

timeline-entry

AttributeTypeRequiredDescription
datestring—Date or time shown on this entry (e.g. "2024-03", "Q1 2025").
labelstring—Short title or milestone name for the entry.

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.

AttributeTypeRequiredDescription
bgstring—Background preset applied to this block
bg-fromstring—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-tostring—Gradient end colour — a semantic token name
bg-viastring—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.

AttributeTypeRequiredDescription
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.

AttributeTypeRequiredDescription
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.

AttributeTypeRequiredDescription
reveal"none" | "fade" | "slide" | "scale" | "blur"—Scroll-reveal entrance character (none|fade|slide|scale|blur); the theme owns the choreography
staggerboolean—Cascade this block's items in as it reveals (no-op on single-child runes)
spacing

Block-level rhythm override.

AttributeTypeRequiredDescription
spacing"flush" | "tight" | "default" | "loose" | "breathe"—Vertical spacing above and below this block
substrate

Generated pattern fills behind the content, drawn by the theme.

AttributeTypeRequiredDescription
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.

AttributeTypeRequiredDescription
tintstring—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.

AttributeTypeRequiredDescription
width"compact" | "narrow" | "content" | "wide" | "full"—Maximum width constraint for this block
Not availableWhy
dropcap, readingthis rune declares no prose body
framethis rune declares neither a `frameTarget` nor a media section
prominencethis rune has no page-section header or featured quotation