Reads EmDash CMS content from D1 and renders Portable Text to HTML. Built for Hono on Cloudflare Workers — ~14 KB bundle, ~2 ms CPU per request.
Cloudflare free plan = 10 ms CPU limit. Astro SSR uses 10-20 ms. Hono uses ~2 ms.
import { getPosts, getPostBySlug, getPages, getPageBySlug, getCollection } from "@awesomeem/emdash-render";
import { portableTextToHtml } from "@awesomeem/emdash-render";
const posts = await getPosts(db); // ec_posts, published, newest first
const post = await getPostBySlug(db, slug); // single post by slug
const pages = await getPages(db); // ec_pages, published, alphabetical
const page = await getPageBySlug(db, slug); // single page by slug
const items = await getCollection(db, name); // any ec_* table
const html = portableTextToHtml(post.content); // Portable Text JSON → HTMLAll queries return only published, non-deleted content.