Docs · Platforms

EmDash

emdash-vibe-editor is a native EmDash plugin (EmDash 1.3 or later). It runs on Node and on Cloudflare Workers, follows EmDash's roles, and saves through EmDash's own drafts and publishing.

Install

npm install emdash-vibe-editor

Add it to EmDash's plugins in astro.config.mjs. Vibe Editor has its own switch, so turn EmDash's toolbar off:

// astro.config.mjs
import emdash from 'emdash/astro'
import vibeEditor from 'emdash-vibe-editor'

export default defineConfig({
  integrations: [
    emdash({
      // ...database, storage
      plugins: [vibeEditor()],
      toolbar: false,
    }),
  ],
})

The editor reaches your pages through EmDash's page hooks, so your layout must render EmDash's head and body components with the page context, as EmDash's templates do:

---
import { EmDashHead, EmDashBodyEnd } from 'emdash/ui'
import { createPublicPageContext } from 'emdash/page'
const pageCtx = createPublicPageContext({ Astro, kind: 'content', content: { collection: 'posts', id: post.id, slug: post.slug }, title, description })
---
<head><EmDashHead page={pageCtx} /></head>
<body>
  <slot />
  <EmDashBodyEnd page={pageCtx} />
</body>

Connect to Vibe Editor

  1. Deploy, then open /_emdash/admin → Vibe Editor as an admin.
  2. Click Koble til Vibe Editor (Connect), sign in to Vibe Editor (or create an account) and approve the site.
  3. You are sent back to EmDash. Visit the site signed in: the switch sits at the bottom right.

The connection is kept in the plugin's storage in your EmDash database and never reaches the browser. Koble fra (Disconnect) deletes it and revokes it at Vibe Editor. On a Node host you can instead set VIBE_API_KEY to a developer key from your account page; a connection made in the admin wins over it.

Mark editable content

The plugin uses the same marks as EmDash's own visual editing. Spread an entry's edit proxy onto the element that shows a field:

---
const { entry: post } = await getEmDashEntry('posts', slug)
---
<h1 {...post.edit.title}>{post.data.title}</h1>
<p {...post.edit.excerpt}>{post.data.excerpt}</p>

<div {...post.edit.featured_image}>
  <Image image={post.data.featured_image} />
</div>

<div class="prose" {...post.edit.content}>
  <PortableText value={post.data.content} />
</div>

EmDash writes these marks only in edit mode, so turning on Vibe Editor's edit mode turns on EmDash's (one reload the first time). In edit mode the site shows drafts, as EmDash's editor does.

Field typeWhat the editor does
string, textRewrite with AI or type, then save.
portableTextThe same, one paragraph, heading, list item or quote at a time. The rest of the field is untouched, links included.
imageA new AI picture (built on the one there), a picture from the media library, an uploaded picture, a pasted https:// address, and alt text.
blocksThe text, rich-text and image fields inside page-builder sections, when the template marks them (below).

Page-builder sections

Fields inside a blocks field are marked with a dotted path: the blocks field, the block's _key and the field. A repeater row's field adds the repeater and the row's index:

{page.data.sections.map((b) => (
  <section>
    <h2 {...page.edit[`sections.${b._key}.title`]}>{b.title}</h2>
    <div class="prose" {...page.edit[`sections.${b._key}.intro`]}>
      <PortableText value={b.intro} />
    </div>
    {b.steps.map((step, i) => (
      <p {...page.edit[`sections.${b._key}.steps.${i}.text`]}>{step.text}</p>
    ))}
  </section>
))}

Only string, text, portableText and image fields (and text and image fields of repeater rows) can be edited, and EmDash's own validation runs before anything is written. The plugin reads your block types through EmDash's runtime: that works on Cloudflare Workers, and on Node with vite: { ssr: { noExternal: ['emdash-vibe-editor'] } } in astro.config. Otherwise, declare the editable fields per block type in the blocks option.

Who can edit

Editing

Upload a picture

In the picture panel, Last opp bilde (upload picture) sits beside Flere valg. Pick a picture on your device (on a phone: camera or photo library), drop one on the panel, or paste one while the panel is open. It goes to EmDash's media library with a progress bar and a cancel button, then straight into the field you clicked.

Saving and publishing

A change to a published entry is published again at once, so visitors see it. If the entry already has unpublished changes of its own, the change goes into that draft instead, and the editor is offered Publiser alt nå (publish everything now) or Ikke nå (not now) — the publish button only for someone who may publish the entry. A draft scheduled for later is never published from the page. With publish: false every change stays a draft.

Options

vibeEditor({
  // Only these fields; `seo` is the title and description. Default: all.
  allow: [
    { collection: 'pages', field: 'sections' }, // a blocks field: everything inside it
    { collection: 'posts', field: 'title' },
    { collection: 'posts', field: 'content' },
    { collection: 'posts', field: 'featured_image' },
    { collection: 'posts', field: 'seo' },
  ],
  // Fields inside sections, per block type. Only needed where EmDash's
  // block types can't be read (Node without noExternal, see above).
  blocks: {
    hero: { title: { type: 'text', maxLength: 80, required: true }, intro: 'portableText', image: 'image' },
  },
  publish: true, // false: changes always stay drafts
  upload: { maxBytes: 50 * 1024 * 1024, maxEdge: 2560, quality: 0.85, process: true },
})

Credits

AI calls are paid from the connected Vibe Editor account (your usage shows these calls as EmDash). Every new account starts with 20 free credits; plans and top-ups are on the pricing section.

ActionCredits
AI text suggestion1
AI picture5
AI suggestion for a page title or meta description1 each
Saving text you typed, a picture from the library or by URL, alt text, a title or descriptionFree

When the credits run out, the editor says so and links to where you can buy more. If the AI fails, the credits are given back.

When the AI is refused

StatusWhy
402Out of credits. The editor links to where you buy more.
429Too many calls in a minute.
503AI paused, the site isn't connected, or the connection was revoked (connect again).
502The AI failed. The credits were given back.

The editor's buttons are in Norwegian today. The ones you'll meet most: Endre tekst (edit text), Skriv selv (type it yourself), Endre bilde (change picture), Flere valg (more options), Alt-tekst (alt text), Side i søkemotorer (page in search engines), Foreslå med AI (suggest with AI), Lagre (save) and Koble til Vibe Editor (connect).

Read more on the blog