Skip to content

Data in site pages

A site built on @recit/site with recit/config (@recit/site-stories) can use the four data directives of @recit/data — :value, :::kpi, ::chart and ::table — directly inside its pages/*.md and pages/*.mdx files, with the exact same syntax and attributes as a report or a deck.

Setup

Add @recit/data to the site's dependencies (and @recit/geo when pages draw type=choropleth or type=points maps):

JSONpackage.json
{ "dependencies": { "@recit/data": "^0.1.0", "@recit/geo": "^0.1.0", "@recit/site-stories": "^1.0.0", "recit": "^1.0.0" } }

No extra import is needed in recit.config.ts:

  • Every figure, number and table is computed at build time in Node as static HTML and SVG. Raw source paths and inline rows are stripped from the page's client front matter.
  • @recit/data/styles.css (and @recit/geo/styles.css on pages with maps) is imported only by the lazy route chunk of pages that render data directives, never in entry.client.
  • @recit/data/client (keyboard arrow navigation across marks and hover/focus tooltips) loads on demand after hydration only on pages that render a chart figure.
  • A page without data: in its front matter does not change by a single byte.
  • A missing data file or an invalid directive attribute stops the build with the page's file path and 1-based line number (✖ pages/metrics.mdx:5 — source "sales": cannot read ./missing.csv).

Declare data: in front matter

List CSV, JSON or YAML tables, inline rows, or precomputed chart.json files relative to the page (a CSV file may use , or ; as its separator, detected from its header line; a header name that is empty or repeated is an error):

YAMLpages/metrics.mdx
--- title: Metrics data: sales: ./data-in-pages/sales.csv schedule: { chart: ./data-in-pages/schedule.json } spots: { chart: ./data-in-pages/spots.json } ---

An inline rows entry (or a plugin source: entry) can also declare meta provenance (title, url, publisher, license, modified). When ::chart has no source= attribute, it builds its Source: credit line from publisher, title and (license):

YAMLYAML
data: targets: rows: - { month: 2026-01, revenue: 120 } - { month: 2026-02, revenue: 150 } meta: title: Dolor sit amet publisher: Lorem Ipsum Institute license: CC-BY-4.0 modified: 2026-11-01 url: https://example.org/lorem

Inline :value and :::kpi

Across the five months in ./data-in-pages/sales.csv, total revenue reaches 783 units across 228 orders:

Total revenue
783
Five months, Lorem region
Peak month
194
March 2026
Orders
228
Cumulative volume

Bar ::chart with highlight= and marks=

highlight= puts one or more categories or series forward (outlined in the text ink while the other bars fade), and marks= draws dashed reference lines across x or y. Under every chart, the « Data » disclosure (« Données » when the site's metadata.lang or the page's lang is fr) exposes the plotted table:

Lorem revenue by monthUnits sold per month, March highlighted

Revenue

Lorem revenue by monthBar chart of revenue by Month, 5 points. revenue: minimum 118 (2026-01), maximum 194 (2026-03), trend: up. Reference lines: Target 150. Highlighted: 2026-03.0501001502002026-012026-022026-032026-042026-05Target

Month

Source: Lorem dataset, 2026

Data
Monthrevenue
January 2026118
February 2026142
March 2026194
April 2026158
May 2026171

Heatmap with rowGroups and hatched null

Ready chart.json files support grouped rows (rowGroups) and missing cells (null, drawn with a 45° « No data » hatch in the grid and in the scale legend):

Lorem ipsum cadence by slotIndex 100 = average slot
Lorem ipsum cadence by slotHeatmap of Lorem ipsum cadence by slot, 5 rows × 4 columns. minimum 74 index (Monday, Morning), maximum 184 index (Saturday, Afternoon); cells without data: 1.WeekdayWeekendMondayTuesdayWednesdaySaturdaySundayMorningMiddayAfternoonEvening

Index

  • < 80 index
  • 80 – 110 index
  • 110 – 140 index
  • 140 – 170 index
  • ≥ 170 index
  • No data

Source: Lorem dataset, 2026

Data
GroupRowMorningMiddayAfternoonEvening
WeekdayMonday7410812286
WeekdayTuesday82No data11891
WeekdayWednesday7911412988
WeekendSaturday116162184132
WeekendSunday104148168119

Points map (type=points)

When @recit/geo is installed, ::chart also renders type=choropleth and type=points in longitude and latitude, with sized groups, colour roles, connecting lines and highlight:

Lorem relays and reservesArea = daily volume
Lorem relays and reservesMap of points: Lorem relays and reserves, 4 points. Groups: Saturated (2) and Reserve (2). Largest: Lorem (60 Volume). 2 lines: Lorem to Dolor and Ipsum to Amet. Highlighted: Lorem.Lorem – DolorIpsum – AmetIpsum · SaturatedDolor · ReserveAmet · ReserveLorem · SaturatedLorem
  • Saturated
  • Reserve
  • Lines

Source: Lorem dataset, 2026

Data
LabelGroupVolumeLatitudeLongitude
LoremSaturated60452.6
IpsumSaturated4244.94
DolorReserve2445.83.3
AmetReserve1845.74.9

Formatted ::table

::table renders sorted, filtered rows from any declared source:

Top four months by revenue
monthregionrevenueorders
March 2026Lorem19456
May 2026Lorem17150
April 2026Lorem15847
February 2026Lorem14241