Meta

Shipping posts from the command line

A short note on the ded-blog CLI publish flow — how I write in a markdown file and one command sends it to Sanity + triggers a Pages redeploy.

Derek Ethan Davis
Lead Engineer · Builder
TL;DR — Writing directly to Sanity via `bun run publish post.md` — no Studio, no git commit, no manual redeploy. Webhook handles the rebuild.

The Sanity Studio is nice, but sometimes I want to write in vim and ship a post without opening a browser tab. So I built a CLI.

How it works

The CLI reads a markdown file with frontmatter, converts the body to portable text, and creates a document in Sanity via the Content Lake API.

bun run publish drafts/my-post.md

Behind the scenes:

Why not just commit MDX?

I could — Astro content collections handle MDX fine. But Sanity is the source of truth now, and going through the Studio (or its API) means every post shows up in the Studio's edit view. If I need to fix a typo three weeks later, I don't have to remember whether it lives in git or in Sanity. It's all in Sanity.

The tradeoff: markdown gets a lossy conversion to portable text on the way in. Simple inline formatting (bold, italic, code, links) survives. Anything exotic doesn't. For engineering posts this has been fine.

Category
Meta