Marketing›Pricing

marketing

Pricing

Pricing tables with tier comparison

Install

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

About the plugin and its runes

Source

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

const NAME_PRICE_PATTERN = /^(.+?)\s*[-–—]\s*(.+)$/;

const CURRENCY_SYMBOLS: Record<string, string> = {
	$: 'USD',
	'€': 'EUR',
	'£': 'GBP',
	'¥': 'JPY',
	'₹': 'INR',
	kr: 'SEK',
	CHF: 'CHF',
	A$: 'AUD',
	C$: 'CAD',
};

function inferCurrency(priceText: string): string {
	for (const [symbol, code] of Object.entries(CURRENCY_SYMBOLS)) {
		if (priceText.startsWith(symbol)) return code;
	}
	return 'USD';
}

function convertHeadings(nodes: Node[]): Node[] {
	const level = nodes.find((n) => {
		if (n.type !== 'heading') return false;
		const text = Array.from(n.walk())
			.filter((c) => c.type === 'text')
			.map((t) => t.attributes.content)
			.join(' ');
		return NAME_PRICE_PATTERN.test(text);
	})?.attributes.level;
	if (!level) return nodes;

	const converted = headingsToList({ level })(nodes);
	const n = converted.length - 1;
	if (!converted[n] || converted[n].type !== 'list') return nodes;

	const result: Node[] = converted.slice(0, n);
	for (const item of converted[n].children) {
		const heading = item.children[0];
		const headingText = Array.from(heading.walk())
			.filter((n) => n.type === 'text')
			.map((t) => t.attributes.content)
			.join(' ');

		const match = headingText.match(NAME_PRICE_PATTERN);
		if (match) {
			result.push(
				new Ast.Node(
					'tag',
					{ name: match[1].trim(), price: match[2].trim() },
					item.children.slice(1),
					'tier',
				),
			);
		} else {
			result.push(heading, ...item.children.slice(1));
		}
	}
	return result;
}

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

export const pricingSchema = {
	type: 'Product',
	properties: { headline: 'name', blurb: 'description' },
	lists: ['offers'],
	children: {
		tier: { type: 'Offer', property: 'offers' },
		'featured-tier': { type: 'Offer', property: 'offers' },
	},
} as const;

export const pricing = createContentModelSchema({
	schema: pricingSchema,
	sections: pricingSections,
	attributes: {},
	contentModel: {
		type: 'sequence',
		fields: [{ name: 'content', match: 'any', optional: true, greedy: true }],
	},
	transform(resolved, attrs, config) {
		const processed = convertHeadings(asNodes(resolved.content));

		const allNodes = new RenderableNodeCursor(
			Markdoc.transform(processed, config) as RenderableTreeNode[],
		);

		const header = allNodes.tags('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p');
		const tiers = allNodes.tag('li');

		const sectionProps = pageSectionProperties(header);
		const tiersList = tiers.wrap('ul', {
			'data-layout': 'grid',
			'data-columns': tiers.nodes.length,
		});

		return createComponentRenderable({
			rune: 'pricing',
			tag: 'section',
			properties: {
				tier: tiers,
			},
			refs: {
				...sectionProps,
				tiers: tiersList.tag('ul'),
			},
			children: [header.wrap('header').next(), tiersList.next()],
		});
	},
});

export const tierSchema = {
	type: 'Offer',
	properties: { name: 'name', parsedPrice: 'price', resolvedCurrency: 'priceCurrency' },
} as const;

export const tier = createContentModelSchema({
	schema: tierSchema,
	attributes: {
		name: { type: String, required: true },
		price: { type: String, required: false },
		featured: { type: Boolean, required: false },
		currency: { type: String, required: false },
		priceMonthly: { type: String, required: false },
	},
	contentModel: bodyOnly(),
	transform(resolved, attrs, config) {
		const runeName = attrs.featured ? 'featured-tier' : 'tier';

		const priceValue = attrs.price || attrs.priceMonthly || '';
		const nameTag = new Tag('h1', {}, [attrs.name ?? '']);
		const priceTag = new Tag('p', {}, [priceValue]);
		const children = renderNodes(resolved.body, config);
		const body = children.wrap('div');

		const currencyMeta = attrs.currency ? new Tag('meta', { content: attrs.currency }) : undefined;

		const numericMatch = priceValue.match(/[\d.]+/);
		const parsedPriceMeta = new Tag('meta', {
			content: numericMatch ? numericMatch[0] : priceValue,
		});
		const resolvedCurrencyMeta = new Tag('meta', {
			content: attrs.currency || inferCurrency(priceValue),
		});

		return createComponentRenderable({
			rune: runeName,
			tag: 'li',
			properties: {
				description: description(children),
				currency: currencyMeta,
				url: children.flatten().tag('a'),
				// Not `price` / `currency`: those are the rendered price and the authored attribute.
				parsedPrice: parsedPriceMeta,
				resolvedCurrency: resolvedCurrencyMeta,
			},
			refs: {
				body: body.tag('div'),
				name: nameTag,
				price: priceTag,
			},
			children: [nameTag, priceTag, body.next()],
		});
	},
});

View plugins/marketing/src/tags/pricing.ts on GitHub

Pricing plans side by side, each with its price, what it includes and a link to sign up, published as structured offers.

Heading-based

Write a heading for each plan, with its name and price.

{% pricing %}
# Plans

Pick the plan that fits your needs.

## Free — $0
- 1 project
- Community support
- Basic analytics

[Get started](/docs/getting-started)

## Pro — $19/mo
- Unlimited projects
- Priority support
- Advanced analytics

[Start trial](/docs/getting-started)
{% /pricing %}
<section data-rune="pricing" typeof="Product" data-schema-lists="[&quot;offers&quot;]">
  <header>
    <h1 id="plans" data-name="headline" property="name">Plans</h1>
    <p data-name="blurb" property="description">Pick the plan that fits your needs.</p>
  </header>
  <ul data-layout="grid" data-columns="2" data-name="tiers">
    <li data-rune="tier" data-rune-fields="{&quot;parsedPrice&quot;:&quot;0&quot;,&quot;resolvedCurrency&quot;:&quot;USD&quot;}" typeof="Offer" data-field="tier" property="offers">
      <h1 data-name="name" property="name">Free</h1>
      <p data-name="price">$0</p>
      <div data-name="body">
        <ul>
          <li>1 project</li>
          <li>Community support</li>
          <li>Basic analytics</li>
        </ul>
        <p data-field="description">
          <a href="/docs/getting-started" data-field="url">Get started</a>
        </p>
      </div>
      <meta property="price" content="0">
      <meta property="priceCurrency" content="USD">
    </li>
    <li data-rune="tier" data-rune-fields="{&quot;parsedPrice&quot;:&quot;19&quot;,&quot;resolvedCurrency&quot;:&quot;USD&quot;}" typeof="Offer" data-field="tier" property="offers">
      <h1 data-name="name" property="name">Pro</h1>
      <p data-name="price">$19/mo</p>
      <div data-name="body">
        <ul>
          <li>Unlimited projects</li>
          <li>Priority support</li>
          <li>Advanced analytics</li>
        </ul>
        <p data-field="description">
          <a href="/docs/getting-started" data-field="url">Start trial</a>
        </p>
      </div>
      <meta property="price" content="19">
      <meta property="priceCurrency" content="USD">
    </li>
  </ul>
</section>

Plans

Pick the plan that fits your needs.

  • Free

    $0

    • 1 project
    • Community support
    • Basic analytics

    Get started

  • Pro

    $19/mo

    • Unlimited projects
    • Priority support
    • Advanced analytics

    Start trial

<section class="rf-pricing rf-pricing--full" typeof="Product" data-schema-lists="[&quot;offers&quot;]" data-width="full" data-rune="pricing" data-density="full">
  <header data-name="preamble" class="rf-pricing__preamble" data-section="preamble">
    <h1 id="plans" data-name="headline" property="name" class="rf-pricing__headline" data-section="title">Plans</h1>
    <p data-name="blurb" property="description" class="rf-pricing__blurb" data-section="description">Pick the plan that fits your needs.</p>
  </header>
  <ul data-layout="grid" data-columns="2" data-name="tiers" class="rf-pricing__tiers">
    <li class="rf-tier" typeof="Offer" data-field="tier" property="offers" data-rune="tier" data-density="full">
      <h1 data-name="name" property="name" class="rf-tier__name">Free</h1>
      <p data-name="price" class="rf-tier__price">$0</p>
      <div data-name="body" class="rf-tier__body">
        <ul>
          <li>1 project</li>
          <li>Community support</li>
          <li>Basic analytics</li>
        </ul>
        <p data-field="description">
          <a href="/docs/getting-started" data-field="url">Get started</a>
        </p>
      </div>
      <meta property="price" content="0" />
      <meta property="priceCurrency" content="USD" />
    </li>
    <li class="rf-tier" typeof="Offer" data-field="tier" property="offers" data-rune="tier" data-density="full">
      <h1 data-name="name" property="name" class="rf-tier__name">Pro</h1>
      <p data-name="price" class="rf-tier__price">$19/mo</p>
      <div data-name="body" class="rf-tier__body">
        <ul>
          <li>Unlimited projects</li>
          <li>Priority support</li>
          <li>Advanced analytics</li>
        </ul>
        <p data-field="description">
          <a href="/docs/getting-started" data-field="url">Start trial</a>
        </p>
      </div>
      <meta property="price" content="19" />
      <meta property="priceCurrency" content="USD" />
    </li>
  </ul>
</section>

How Markdown is read

You writeIt becomes
A heading Name — Price (any dash)A tier: the plan's name, then its price
The content under it, up to the next tier headingThe tier's body, such as its feature list and a sign-up link
A short paragraph, then a heading and a paragraph, before the first tierThe eyebrow, headline and blurb (Page sections)

Explicit tiers

Use {% tier %} tags when you need full control over attributes like featured or currency.

{% pricing %}
	# Choose your plan

	{% tier name="Free" price="$0" %}
	- 1 project
	- Community support
	{% /tier %}

	{% tier name="Pro" price="$19" featured=true %}
	- Unlimited projects
	- Priority support
	- Advanced analytics

	[Start trial](/docs/getting-started)
	{% /tier %}

	{% tier name="Enterprise" price="Custom" %}
	- Custom integrations
	- Dedicated support
	- SLA guarantee

	[Contact us](/docs/getting-started)
	{% /tier %}
{% /pricing %}
<section data-rune="pricing" typeof="Product" data-schema-lists="[&quot;offers&quot;]">
  <header>
    <h1 id="choose-your-plan" data-name="headline" property="name">Choose your plan</h1>
  </header>
  <ul data-layout="grid" data-columns="3" data-name="tiers">
    <li data-rune="tier" data-rune-fields="{&quot;parsedPrice&quot;:&quot;0&quot;,&quot;resolvedCurrency&quot;:&quot;USD&quot;}" typeof="Offer" data-field="tier" property="offers">
      <h1 data-name="name" property="name">Free</h1>
      <p data-name="price">$0</p>
      <div data-name="body">
        <ul>
          <li>1 project</li>
          <li>Community support</li>
        </ul>
      </div>
      <meta property="price" content="0">
      <meta property="priceCurrency" content="USD">
    </li>
    <li data-rune="featured-tier" data-rune-fields="{&quot;parsedPrice&quot;:&quot;19&quot;,&quot;resolvedCurrency&quot;:&quot;USD&quot;}" typeof="Offer" data-field="tier" property="offers">
      <h1 data-name="name" property="name">Pro</h1>
      <p data-name="price">$19</p>
      <div data-name="body">
        <ul>
          <li>Unlimited projects</li>
          <li>Priority support</li>
          <li>Advanced analytics</li>
        </ul>
        <p data-field="description">
          <a href="/docs/getting-started" data-field="url">Start trial</a>
        </p>
      </div>
      <meta property="price" content="19">
      <meta property="priceCurrency" content="USD">
    </li>
    <li data-rune="tier" data-rune-fields="{&quot;parsedPrice&quot;:&quot;Custom&quot;,&quot;resolvedCurrency&quot;:&quot;USD&quot;}" typeof="Offer" data-field="tier" property="offers">
      <h1 data-name="name" property="name">Enterprise</h1>
      <p data-name="price">Custom</p>
      <div data-name="body">
        <ul>
          <li>Custom integrations</li>
          <li>Dedicated support</li>
          <li>SLA guarantee</li>
        </ul>
        <p data-field="description">
          <a href="/docs/getting-started" data-field="url">Contact us</a>
        </p>
      </div>
      <meta property="price" content="Custom">
      <meta property="priceCurrency" content="USD">
    </li>
  </ul>
</section>

Choose your plan

  • Free

    $0

    • 1 project
    • Community support
  • Enterprise

    Custom

    • Custom integrations
    • Dedicated support
    • SLA guarantee

    Contact us

<section class="rf-pricing rf-pricing--full" typeof="Product" data-schema-lists="[&quot;offers&quot;]" data-width="full" data-rune="pricing" data-density="full">
  <header data-name="preamble" class="rf-pricing__preamble" data-section="preamble">
    <h1 id="choose-your-plan" data-name="headline" property="name" class="rf-pricing__headline" data-section="title">Choose your plan</h1>
  </header>
  <ul data-layout="grid" data-columns="3" data-name="tiers" class="rf-pricing__tiers">
    <li class="rf-tier" typeof="Offer" data-field="tier" property="offers" data-rune="tier" data-density="full">
      <h1 data-name="name" property="name" class="rf-tier__name">Free</h1>
      <p data-name="price" class="rf-tier__price">$0</p>
      <div data-name="body" class="rf-tier__body">
        <ul>
          <li>1 project</li>
          <li>Community support</li>
        </ul>
      </div>
      <meta property="price" content="0" />
      <meta property="priceCurrency" content="USD" />
    </li>
    <li class="rf-tier rf-tier--featured" typeof="Offer" data-field="tier" property="offers" data-rune="featured-tier" data-density="full">
      <h1 data-name="name" property="name" class="rf-tier__name">Pro</h1>
      <p data-name="price" class="rf-tier__price">$19</p>
      <div data-name="body" class="rf-tier__body">
        <ul>
          <li>Unlimited projects</li>
          <li>Priority support</li>
          <li>Advanced analytics</li>
        </ul>
        <p data-field="description">
          <a href="/docs/getting-started" data-field="url">Start trial</a>
        </p>
      </div>
      <meta property="price" content="19" />
      <meta property="priceCurrency" content="USD" />
    </li>
    <li class="rf-tier" typeof="Offer" data-field="tier" property="offers" data-rune="tier" data-density="full">
      <h1 data-name="name" property="name" class="rf-tier__name">Enterprise</h1>
      <p data-name="price" class="rf-tier__price">Custom</p>
      <div data-name="body" class="rf-tier__body">
        <ul>
          <li>Custom integrations</li>
          <li>Dedicated support</li>
          <li>SLA guarantee</li>
        </ul>
        <p data-field="description">
          <a href="/docs/getting-started" data-field="url">Contact us</a>
        </p>
      </div>
      <meta property="price" content="Custom" />
      <meta property="priceCurrency" content="USD" />
    </li>
  </ul>
</section>

Attributes

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

tier

AttributeTypeRequiredDescription
namestring✓
pricestring—
featuredboolean—
currencystring—
priceMonthlystring—

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