Skip to content
mdxcn is now part of Shadcn Labs. details

graphs from a knap template

Pipe your data through a graph_* filter in a Knap template and the output Markdown contains a framed figure. The Knap CLI doesn't load custom filters, so you register them in your own code.

pnpm dlx shadcn@latest add @mdxcn/graph-knap
[ filter ]

template and the frames it produces

The same incident as on the Comark page, this time written as a Knap template. Switch to Source to see the template that produced these figures.

Latency crossed 800ms at 14:02, and we rolled back at 14:11.

[ NIGHT ]
  1. 14:02p95 crossed 800ms
  2. 14:11rolled back the cache flag
  3. 14:40write the postmortem

Users noticed it on two days that week.

[ api ]

79%

Aug 14Aug 27

█ up▒ slow· down

79 percent uptime over 14 days, Aug 14 to Aug 27

how the pieces fit

Templating is Knap's job, and the graphs are the ones you copied with shadcn if you also render React. The filters are the only new code.

data
Pass plain JSON, or any variables Knap can resolve. The filter reads the value with its types intact, so there's no special schema to learn.
filter
Pipe the data through graph_timeline, graph_meter or any other graph filter. A string argument sets the title, and comark switches the output to a ::graph-* block.
markdown
You get the plain-text figure, identical to the .md tab in the docs, which reads fine in Obsidian, GitHub and READMEs. Graphs without a text version print Comark YAML instead.

where each format belongs

Knap generates text. It writes the plain-text figure for a README, or the ::graph-* block a Comark app renders. Drawing the live React frame is still the component's job.

[ host ]
JSXASCIIComarkKnap
  • MDX / React✓–✓–
  • App .md file––✓✓
  • README / GitHub–✓–✓
  • Data in, Markdown out–––✓
[ filter ]
  • same props as react
  • official fence, not homemade
  • comark param → ::graph-*
  • cli loads graph filterswire createEngine
3 of 4 done