How Bevel works
How files under Data/ become typed C# data, how pages read it, and how an export writes static HTML.
On this page
Files go in. Typed C# comes out. Your pages render it live, or Bevel writes it to disk as HTML.
The four ideas
- A dataset is one named collection of content, such as
PostsorAuthors. You declare it with a C# record and a[DataSource]attribute. - The data step runs during
dotnet build. It reads every dataset, checks it, and generatesISiteData. That interface has one typed property per dataset. The MSBuild target behind it is calledBevelPrebuild, so you also see "prebuild" in file and property names. - Your pages read
ISiteData. You route them withMapStatic. - An export renders every mapped page and writes the result to disk as static files.
What happens inside the data step
The data step does more than read files. It follows this order:
Read the full list in Processors. The short version: Bevel binds each file to your record, runs your processors, then sorts, checks uniqueness, resolves references and builds groups. A mistake fails the build with an error that names the file.
The data graph
Bevel builds a graph of every dataset, with edges from [DependsOn] and [Reference]. It validates the graph, then runs datasets in layers. The LoadOrder setting (the [LoadOrder] attribute on a custom loader, or the LoadOrder property of [DataSource]) only breaks ties inside a layer. The build prints the result:
data graph: [Authors, Site] -> [Posts] -> [Posts.Tags] -> [Metrics]
Each dataset is stored as a UTF-8 JSON file embedded in the assembly as a resource (Bevel.Data.<Namespace>.<Dataset>.<hash>.json, written to obj/.../Bevel/data/). Bevel reads it once, on first use, through a source-generated System.Text.Json context. The generated C# stays small however much content you have. Bevel serializes every dataset and reads it back during the build to make sure nothing is lost.
Live, exported or served
While you develop, the app renders pages live. When you are ready, dotnet run -- --bevel-build writes plain HTML. If your ASP.NET Core app serves the site, Bevel can answer from the exported files in production.