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
- Deploy, then open /_emdash/admin → Vibe Editor as an admin.
- Click Koble til Vibe Editor (Connect), sign in to Vibe Editor (or create an account) and approve the site.
- 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 type | What the editor does |
|---|---|
string, text | Rewrite with AI or type, then save. |
portableText | The same, one paragraph, heading, list item or quote at a time. The rest of the field is untouched, links included. |
image | A new AI picture (built on the one there), a picture from the media library, an uploaded picture, a pasted https:// address, and alt text. |
blocks | The 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
- Editors only. Every page gets a tiny script that stops at once unless EmDash's admin has marked the browser as an editor's. Only for an author or above is the editor loaded. Visitors never load it.
- EmDash's roles decide. An author may change their own entries, an editor or admin any entry, as in EmDash's admin. The check runs before any AI call, so a change that would be refused costs no credits.
- Content only. Text, rich text, images, alt text and the SEO title and description — never templates, settings or other fields. The
allowoption narrows it further.
Editing
- Text and rich text. Click a marked field, write an instruction or type the text yourself, and save.
- Pictures. Describe a new one and the AI makes it, building on the one there when it fits; AI pictures are added to the media library as
vibe-<time>.png. Or pick one from the library, upload one, or paste an address. - Alt text for the picture, in the same panel.
- Page title and meta description. On pages that show one entry of a collection with SEO on, the magnifier above the gear opens Side i søkemotorer, with character counts and Foreslå med AI. EmDash stores SEO fields at once, so the change is live straight away.
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.
- The upload goes from the browser to EmDash's own media endpoint with the editor's session, so EmDash's rules hold: who may upload (Contributor and up), its file types (no SVG), its size limit (50 MB by default) and de-duplication.
- Big photos are made smaller in the browser first: longer than 2560 px or over 1.5 MB becomes at most 2560 px on the long side. A 12-megapixel phone photo comes out at a few hundred KB, without the location and camera data. GIFs are never changed.
- If you set a lower
emdash({ maxUploadSize }), pass the same number asvibeEditor({ upload: { maxBytes } })so editors are told before uploading. - An image field with its own allowed types only takes pictures of those types.
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.
| Action | Credits |
|---|---|
| AI text suggestion | 1 |
| AI picture | 5 |
| AI suggestion for a page title or meta description | 1 each |
| Saving text you typed, a picture from the library or by URL, alt text, a title or description | Free |
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
| Status | Why |
|---|---|
402 | Out of credits. The editor links to where you buy more. |
429 | Too many calls in a minute. |
503 | AI paused, the site isn't connected, or the connection was revoked (connect again). |
502 | The 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).
Try now