Read route metadata
List every route Bevel maps with BevelEndpointRegistry, for example to build a custom sitemap or check links.
On this page
var routes = await registry.GetRoutesAsync(serviceProvider);
var pages = routes.Where(r => r is { IsPage: true, IsExported: true });
Call GetRoutesAsync on BevelEndpointRegistry to see every route. Use it for a sitemap, a search index or a link check.
Build a custom sitemap
This sitemap keeps exported pages and skips the 404 page:
app.MapStatic("/sitemap.xml", async (ISiteData data, BevelEndpointRegistry registry, IServiceProvider sp) =>
{
var routes = await registry.GetRoutesAsync(sp);
var pages = routes
.Where(r => r is { IsPage: true, IsExported: true } && r.Path != "/404.html")
.Select(r => data.Site.BaseUrl.TrimEnd('/') + r.Path);
return BevelResults.Xml(BuildSitemap(pages));
});
What a route holds
public sealed record BevelRouteInfo(
string Path, bool IsPage, string? ContentType, bool IsExported,
Type? PageType, Type? ItemType, object? Item);
Task<IReadOnlyList<BevelRouteInfo>> BevelEndpointRegistry.GetRoutesAsync(
IServiceProvider, CancellationToken = default)
- There is one entry per route.
.htmland/index.htmlaliases are not listed. A paged root route appears once. Pathis route-relative and never includesPathBase.IsPageis true forMapStatic<TPage>andMapStaticPaged./404.htmlis a page, so skip it yourself.ContentTypeistext/htmlfor pages. For handler routes it is inferred from the file extension (/rss.xml) and may benull.IsExportedis false for routes withExcludeFromStaticExport(). Those routes are still listed.GetAllRoutesAsyncreturns the paths of exported routes only.