Build your own section in BearMinion
One folder, three files, one command. A Timeline section with a list of milestones that the editor lets you add, remove and drag, with no editor code from you.
Sections are the blocks every page is made of: a hero, a FAQ, a call to action. Yours sit next to them in the Add section picker, and the editor builds their controls from your schema.
This post builds a Timeline: a heading and a list of milestones, each with a year, a title and a sentence.
1. Make the folder
Run:
mkdir src/components/sections/timelineThe folder name is the section's name, in kebab-case. In your content files the type is the same name in camelCase, and the component is named after it: Timeline.astro.
2. Write the three files
definition.ts says what the section holds, as a Zod schema. It checks every save and builds the fields in the editor. wireframe.ts draws the thumbnail in the picker. Timeline.astro renders it.
The files
Three files, nothing else.
Every value you want editable on the page gets a data-field with its path in the page file. The rest is ordinary Astro.
import { z } from 'zod'import { defineSection, richTextSchema, textSchema, withEmphasis } from 'bearminion'import { accent, eyebrow, heading } from '../shared'import { timelineWireframe } from './wireframe' export const milestoneSchema = z .object({ year: textSchema, title: textSchema, text: richTextSchema.optional() }) .strict() export const timeline = defineSection({ type: 'timeline', label: 'Timeline', description: 'Milestones in order: a year, a title and a sentence each.', schema: withEmphasis({ eyebrow, heading, milestones: z.array(milestoneSchema).min(2).max(8) }), defaults: { eyebrow: 'Our story', heading: 'How we got here.', marks: accent('How we got here.', 'got here.'), milestones: [ { year: '2019', title: 'The idea', text: 'Say what started it.' }, { year: '2021', title: 'The first customer', text: 'Name the moment it became real.' }, { year: '2024', title: 'Today', text: 'Say where you are now.' }, ], }, variants: ['list', 'columns'] as const, defaultVariant: 'list', optional: { props: ['eyebrow', 'heading'], items: { milestones: ['text'] } }, counts: { milestones: { recommended: '3 to 5', min: 2, max: 8 } }, wireframe: timelineWireframe,})import { defineWireframe } from 'bearminion' /** [left %, top %, width %, height %, kind] in a 100 × 100 frame. */export const timelineWireframe = defineWireframe([ [8, 12, 44, 8, 'title'], [8, 32, 10, 5, 'highlight'], [24, 32, 40, 5, 'text'], [8, 50, 10, 5, 'highlight'], [24, 50, 40, 5, 'text'],])---import type { Section } from '../definitions'import Typography from '../../atoms/Typography.astro'import SectionHeader from '../../molecules/SectionHeader.astro'import SectionShell from '../../molecules/SectionShell.astro' interface Props { section: Extract<Section, { type: 'timeline' }> index: number motion?: boolean} const { section, index, motion = true } = Astro.propsconst props = section.propsconst field = (path: string) => `sections.${index}.props.${path}`--- <SectionShell id={section.id} anchor={section.anchor} type={section.type} variant={section.variant} tone={section.tone} motion={section.motion ?? motion}> <div class="section-container flex flex-col gap-10"> <SectionHeader eyebrow={props.eyebrow} heading={props.heading} marks={props.marks} size="h2-md" field={field} /> <ol class="grid gap-6"> {props.milestones.map((milestone, item) => ( <li class="flex gap-6 border-t border-line pt-6"> <span class="w-20 shrink-0 font-mono text-muted" data-field={field(`milestones.${item}.year`)}>{milestone.year}</span> <div class="flex flex-col gap-2"> <Typography as="h3" size="h3" data-field={field(`milestones.${item}.title`)}>{milestone.title}</Typography> {milestone.text && <Typography as="p" size="body" color="muted" data-field={field(`milestones.${item}.text`)} markdown={milestone.text} />} </div> </li> ))} </ol> </div></SectionShell>3. Register it
Run:
npx bearminion syncIt finds every section folder with a definition.ts and writes them into definitions.gen.ts and components.gen.ts. Commit those two files, but don't edit them.
4. Try it
Restart npm run dev. Hover any section, choose Add, and Timeline is in the picker with its thumbnail. Add it, open Settings, and the milestones are a list: add a row, drag one to reorder, remove one. The buttons stop at 2 and 8, because the schema says so.
Click a year or a title on the page and type. Save, and the section is in the page's JSON exactly as your schema describes it.

When something's off
Invalid defaults for sectionwhenastro devstarts: a default value fails your schema.- The section isn't in the picker: you didn't run
npx bearminion sync, or didn't restart the dev server after it. - Clicking a value does nothing: its element has no
data-field, or the path doesn't match the schema. - A field can't be cleared:
optionaland the schema's.optional()disagree about it.
The full walkthrough, with a second layout, is in Build your own section.
Wake the minion.
Run one command, answer three boring questions and watch it do the rest. Template copied, dependencies installed, first commit done.
Now it gets out of your way so you can actually work.
- npm create bearminion@latest
- Created My Site in my-site
- Installed dependencies
- →Next: cd my-site, npm run dev
