Frontmatter and Data Binding in Vue Markdown

Interpolate frontmatter and reactive data into Markdown with the Comark binding plugin in Vue and Vite.
App.vue
<script setup lang="ts">
import { reactive } from 'vue'
import { Comark } from '@comark/vue'
import binding, { Binding } from '@comark/vue/plugins/binding'

// Runtime data exposed to bindings via the `data.` namespace.
const data = reactive({
  user: {
    name: 'Ada',
    role: 'admin',
  },
  stats: {
    users: 1200,
    uptime: '99.9%',
  },
})

const markdown = `---
release:
  version: 2.5.1
  codename: Firefly
---

# {{ frontmatter.release.codename || Unnamed }} — v{{ frontmatter.release.version }}

Hello **{{ data.user.name || friend }}** (role: {{ data.user.role }}), welcome back!

## Platform stats

| Metric | Value                            |
| ------ | -------------------------------- |
| Users  | {{ data.stats.users }}           |
| Uptime | {{ data.stats.uptime }}          |
| Plan   | {{ data.plan \\|\\| community }}     |

## Components see their own props

::card{title="Component props"}
Inside the card the binding below pulls the card's title via \`props\`:

{{ props.title }}
::
`
</script>

<template>
  <Suspense>
    <Comark
      :markdown="markdown"
      :plugins="[binding()]"
      :components="{ Binding }"
      :data="data"
    />
  </Suspense>
</template>
https://comark-binding.vercel.app

This example interpolates YAML frontmatter, reactive application state, and component props into Markdown in a Vue and Vite app with @comark/vue/plugins/binding.

Features

  • {{ path }} interpolation: reads values from frontmatter, the renderer's data prop, or an enclosing component's props.
  • || default fallback: renders an inline fallback when the dot path is undefined.
  • Conditional blocks: selects branches with ::if and #else using truthiness or comparison operators.
  • Typed prop bindings: passes strings, numbers, booleans, and objects without stringifying them first.

Usage

  1. Import the plugin and its Vue components:

    import binding, { Binding, If } from '@comark/vue/plugins/binding'
  2. Pass them to <Markdown> along with reactive data:

    <Markdown
      :value="markdown"
      :plugins="[binding()]"
      :components="{ Binding, If }"
      :data="data"
    />
  3. Reference values with {{ path || default }} in Markdown:

    ---
    release:
      version: 2.5.1
    ---
    
    Hello, {{ data.user.name || friend }}. You are on v{{ frontmatter.release.version }}.

Namespaces

Bindings resolve against four namespaces:

NamespaceSource
frontmatterYAML frontmatter on the parsed document
metaPlugin metadata attached to document.meta
dataThe data prop passed to <Markdown>
propsResolved props of the enclosing component

Learn more

© 2026 Vercel, Inc.