@wptom/cms-emdash
v0.2.0
Published
EmDash CMS for WPTom templates: collections, fields, block types and the demo seed generated from the template's content model, and the mapping that turns EmDash entries back into the model's shape.
Maintainers
Readme
@wptom/cms-emdash
EmDash for WPTom templates. In a template's EmDash
variant (wptom new my-site -t <template> --cms emdash), EmDash runs inside the site: the admin
lives at /_emdash/admin, pages are rendered on request on Cloudflare Workers (D1 + R2), and
what you publish is live at once. This package connects EmDash to the template's content
model (src/content/model.ts), so pages don't change. Part of the
WPTom integrations. Tested with EmDash 1.3.
- Some fields live where EmDash keeps them: the site's
nameandtaglinein Settings (single-language sites),nav,legal,socialand footer link groups in Menus (primary,legal,social,footer), a post'stagsandauthorin Tags and Bylines, adraftswitch in EmDash's drafts, and pages'seoTitleandseoDescriptionin the SEO panel. Only fields of exactly that shape move; sites set up before keep their own values until the menu or setting exists. - A spec's
route(/about,/blog/{slug}) becomes the collection's URL pattern: Live View, previews and menu links follow it. emdashSchema(specs, { bodies, multilingual }): collections, fields and block types from the model. Single pages are collections with one entry; nested objects are flattened into fields (pricing.eyebrow→pricing__eyebrow); lists of plain values or flat objects are repeaters; page sections are blocks (section_<type>); deeper structures are JSON fields. Pages with more than 60 fields keep each top-level group in a one-item block, since D1 allows 100 columns per table. Bodies are Portable Text (EmDash's rich editor) or Markdown text.emdashSeed(parts, { title, tagline, media }): the template's demo content as an EmDash seed file (.emdash/seed.json), with photos as$mediadownloads. EmDash applies it in its setup wizard.fromEmDashEntry(spec, fields, data, options, { settings, menus }, { multilingual }): turns an entry from EmDash's live collections back into the model's shape (images as{ src, width, height }or URLs), with the fields EmDash keeps elsewhere and fallbacks for empty SEO texts.fromEmDashdoes the fields alone.@wptom/cms-emdash/astro:routeCache({ provider })turns on Astro's route cache for every page insrc/pages(an hour fresh, a day stale-while-revalidate), tagged with every collection, the settings, menus and tags, so EmDash's purges on publish refresh the whole site within seconds.setupEmDash(options, schema): brings a running EmDash in line after the model changed (the template'snpm run emdash:schema): adds collections, fields and block types, updates changed ones and gives block types a new version when EmDash needs one. Content stays. Needs an API token withschema:write(Settings → API Tokens).markdownToPortableText(),portableTextToPlain(): body conversion (the plain text feeds search and the site chat). Headings, paragraphs, lists, quotes, code, images and inline marks (**bold**,*italic*or_italic_, code, links, strike-through);---becomes EmDash'sbreakblock; footnotes ([^1]and[^1]: text) becomefootnoteRefinline objects and onefootnotesblock at the end, numbered by first reference. Render the last two with your own components (PortableTextcomponents.type).
EmDash's rich editor has no tables yet. No dependencies besides @wptom/content-model.
MIT License; portable-text.ts is adapted from EmDash (MIT, notice in LICENSE).
