Relatude Help

11 Any IResult: Blazor, JSON and the rest

A ResultTarget returns any IResult, so it needs neither MVC nor Razor Pages. Use it for JSON to a headless client, a file, a template engine of your own, or a Blazor component rendered on the server.

builder.AddRelatudeCMS()
    .AddRendering(o => o
        // JSON for a headless client: a projection, never the node itself
        .RenderResult<IApiPage>((http, page) => Results.Json(new { page.Id, page.Name }))
        // RSS, through a class of the site's own
        .RenderResult<IFeedPage>((http, feed) => Results.Text(FeedWriter.Rss(feed), "application/rss+xml")));

Serialize a projection, never the node itself. A node's relations are enumerable, so a serializer handed the node would walk into every related node, and on through theirs.

  • Blazor — A Blazor component renders a page through RazorComponentResult. The component is a plain one, with no @page, and gets the page through a parameter named Content: