Add a slot
Adding anything to a section — the five-step loop you will run for every piece of content you ever add.
This is the loop. Declare a slot, say where its value comes from, state it in the
fixture, render it, run concrete check. Everything else in the framework is a
variation on these five steps, so it is worth doing once slowly.
Goal
A new line of content in the hero — declared, filled, previewable and checked.
Steps
Declare the slot. A slot is a builder call under slots, keyed by the name
your markup will use. A short line under the headline wants
text.short — the entry on its own first, and the
whole file it belongs in at step 4:
import { text } from "@homepages/concrete";
const tagline = text.short({ label: "Tagline", cap: 40 });label is what the editor's card is called. cap is the character budget, and
it is written here and nowhere else — the fill below inherits it.
Say where its value comes from. Every slot answers this exactly once, in its
source:, and there are two answers you will use first.
A fill hands the platform's model a brief, and its verb says what the model
does: fill.write writes the value. brief is the whole instruction — what to
write, its shape, its tone — and reads is exactly what the model sees beside it,
nothing more:
import { fact, fill, text } from "@homepages/concrete";
const tagline = text.short({
label: "Tagline",
cap: 40,
source: fill.write({
reads: [fact.property.address, fact.property.description],
brief: "Name the neighbourhood and one thing it is known for, in a few plain, specific words.",
}),
});Keep the brief inside the cap, as that one does by asking for a few words. The
model is told the budget, but a brief asking for something longer than it fits
produces text that has to be cut. A fill that reads nothing writes from nothing,
so a written slot names the facts its brief is about. The starter's hero image
takes the other verb, fill.pick: the model writes nothing there, it chooses one
of the property's own photos.
A fact ref binds the slot to the property instead, and then no model is involved at all. The bedroom count is a fact the property already carries:
import { fact, number, row } from "@homepages/concrete";
const unit = row({ label: "Unit", from: fact.property.units, locked: true });
const beds = number({ label: "Bedrooms", source: unit.beds });A table's members are read through a row(). This one holds the property's first
unit, and locked: true keeps the section on it. An edit to the slot is offered
back to the unit (where an edit goes). A
number the platform holds, like this one, is a fact
and is always bound; a fill.write on a number is only for an estimate the user
confirms, such as a suggested price.
State it in the fixture. A filled slot has no value on your machine until you write one: there is no model running locally, and the fixture is where you say what one would have produced.
{
"$schema": "../.concrete/schema/content-fixture.schema.json",
"property": "properties/starter/property.json",
"content": {
"hero-1": {
"slots": {
"headline": "A brick colonial on a quiet, tree-lined street",
"tagline": "Maplewood: leafy, walkable, ten to town",
"hero_image": { "media": "exterior-front" }
}
}
}
}The new line is tagline; the scaffold's notes member is dropped for length.
hero-1 is the hero's instance — its key, and which placement it is — and a
photograph is named by its upload id in the property document.
Only the filled slots go here. beds needs no line — its value comes from the
property, and the fixture already has one.
Leaving the line out is not an error, and that is worth knowing rather than
discovering: concrete check stays green and the slot renders its empty
branch — the marked element, with nothing in it. An unfilled slot is a state
the editor has to survive, so the framework treats it as one.
Render it. Through the primitive for its kind, never off the binding. Here is the starter's hero with both new slots in place — its declaration and its markup, with the scaffolder's own explanatory comments dropped for length:
import { fact, fill, image, number, row, Section, section, Slot, text } from "@homepages/concrete";
const unit = row({ label: "Unit", from: fact.property.units, locked: true });
export const Hero = section(
{
key: "hero",
label: "Hero",
slots: {
headline: text.medium({
label: "Headline",
cap: 80,
source: fill.write({
reads: [fact.property.address, fact.property.description],
brief: "Name what makes the property worth seeing, in one short, confident sentence.",
}),
}),
tagline: text.short({
label: "Tagline",
cap: 40,
source: fill.write({
reads: [fact.property.address, fact.property.description],
brief: "Name the neighbourhood and one thing it is known for, in a few plain, specific words.",
}),
}),
unit,
beds: number({ label: "Bedrooms", source: unit.beds }),
hero_image: image({
label: "Hero image",
from: fact.property.property_media,
source: fill.pick({ brief: "The photo that best shows the front of the property." }),
}),
street: text.short({ label: "Street", source: fact.property.address.street }),
city: text.short({ label: "City", source: fact.property.address.city }),
},
},
({ slot }) => (
<Section className="bg-white text-neutral-900">
<div className="mx-auto max-w-3xl px-6 py-24">
<Slot.Image slot={slot.hero_image} className="aspect-[3/2] w-full rounded-lg" />
<Slot.Text slot={slot.headline} as="h1" className="mt-10 text-4xl font-semibold tracking-tight" />
<Slot.Text slot={slot.tagline} as="p" className="mt-3 text-lg text-neutral-500" />
<p className="mt-4 text-lg text-neutral-600">
<Slot.Text slot={slot.street} as="span" />, <Slot.Text slot={slot.city} as="span" />
{" · "}
<Slot.Number slot={slot.beds} as="span" />
</p>
</div>
</Section>
),
);as names the one element the primitive renders and marks. That element is how
the editor finds the value in the DOM — it never sees your component — so a value
read straight off the binding is a check failure
(slots/no-raw-values), and so is a
data-slot-* attribute written by hand
(slots/no-marker-literal).
Check it.
npm run check✓ workspace
✓ typecheck
✓ lint
✓ composition
✓ relations
✓ stylesheet
✓ logic
✓ fixtures
✓ sections
✓ contracts
✓ render
✓ bundles
hero renderer 8.0 KB gzip
✓ dependencies
concrete check passed: 13 stages.Thirteen stages, every one of them a requirement the platform accepts a template on. The bundles stage prints what each placed section's renderer weighs — 7.8 KB before this slot, 8.0 KB after.
What a failure looks like
Most of what you get wrong here is caught before it ships, and the report names
the rule that caught it. The compiler refuses an option a fill does not take — a
count, a cap on the fill rather than on its slot — so the red report worth
reading once is a contract one. Delete the tagline's reads line, so its fill
writes from the brief alone, and the contract stage refuses it. The finding from
one run, with the green stages left out here:
✗ contracts (1 violation)
sections/hero/section.tsx concrete/contract/writer-reads-fact
Section "hero": fill "tagline" writes "tagline" but reads no fact — its model call is shown exactly its `reads`, so it would write from the brief alone. Declare the facts it writes from (`reads: [fact.property.description]`), on the fill or on the item field that writes.
concrete check failed: 1 violation in 1 stage.Every violation carries a rule id, and every id resolves at /rules/<id> —
contract/writer-reads-fact here. concrete check
does not stop at the first red stage, so one run tells you everything that is
wrong. Working through a red report is
its own guide.
What you learned
- What a slot is. A type and exactly one source of value, declared by a builder — slots.
- The two first answers. A fill's brief a model reads
(AI fill) or a fact ref bound to the property
(facts and provenance), each a
source:— one per slot. - Why a filled slot needs a fixture line. No model runs on your machine; the fixture is the stated content, and an unstated slot renders empty — fixtures.
- Why the value goes through a primitive. The editor reads the DOM, so the marker has to be in the output — the marker contract.
- What
concrete checkis. The platform's acceptance criteria, run locally, every finding carrying the id of the rule that explains it — the pipeline.
Next
Add a section and a page — the same loop, one level up.
