CMS / foldkit-cms
Kinds, and how they are drawn
An entry's address and its publish time use
foldkit-form-recipes' slug and dateTime
controls; the CMS adds two display kinds (Cms.Display.State and
Cms.Display.Moment) made with Display.kind. Render them alongside your form
renderers—a kind and its renderer are all a view needs.
import { Form } from 'foldkit-form'
import { FieldRecipes } from 'foldkit-form-recipes'
import { renderers } from 'foldkit-form-recipes/html'
import { FormView } from 'foldkit-mixins-form'
const PostForm = Form.make('PostForm', Entity.input(Post, PostInput), {
inputs: {
// follows the title until the author writes it
slug: FieldRecipes.slug('title', { prefix: '/blog/' }).control,
// a datetime-local input, read in London, submitted as an ISO instant
goesLiveAt: FieldRecipes.dateTime({ stored: 'instant', zone: 'Europe/London' }).control,
},
})
FormView.define(PostForm, { renderers: renderers() })Beside a Crud.list over Cms.Entries, pass Cms.displayRenderers() to
EntryTable({ page, renderers: Cms.displayRenderers() }, h).
A slug follows its title until the author writes it, and a form filled with a published slug stays fixed so an existing URL never moves when a title changes.
| Kind | What it renders |
|---|---|
Cms.Display.State | span with data-cms-state and data-cms-schedule for the entry state |
Cms.Display.Moment | time element, relative to now or formatted as a date and time |
Pass custom labels to Cms.Display.State.of({ words }) for each state,
scheduled, overdue, and withSchedule ('{state}, {schedule}'). Pass
Cms.Display.Moment.of({ now }) to format relative times like 3 days ago
against your chosen clock.
Cms.Entities already declare these kinds on their state and timestamp
fields, so a Crud.list over Cms.Entries needs only Cms.displayRenderers().
Entry-level views live beside the kinds: Cms.stateBadge for the state
(written in Cms.stateAttribute, data-cms-state, matching list cells),
Cms.revisionsOf for the open entry's published revisions, Cms.historyCard
for the timeline, and Cms.moreCard for the remaining actions. They draw on your
own slot builders so you keep your slots and styles; you supply authorName,
the archive icon, and an explicit locale and timeZone so server and browser
renders match:
Cms.historyCard(slots, h, Cms.revisionsOf(model, history), {
state,
restore: revision => Message.RestoreAsked({ revision }),
authorName: name => directoryName(name),
locale: 'en',
timeZone: 'UTC',
})