dvRenderRoutePage function

String dvRenderRoutePage(
  1. String shell,
  2. DVRoutePage page, {
  3. void onUncaptured(
    1. String route
    )?,
})

page rendered into shell: the head, the structured data, the icon, the crawler-visible document, minified. Called by the static build for every route and by the web server for every request, so the two agree byte for byte.

The captured document when there is one. The source-literal lines are the last resort for a route nothing captured, and onUncaptured is told, so a server that falls back says so.

Implementation

String dvRenderRoutePage(
  String shell,
  DVRoutePage page, {
  void Function(String route)? onUncaptured,
}) {
  final String head = dvStaticPage(
    shell: shell,
    route: page.route,
    title: page.title,
    description: page.description,
    siteUrl: page.siteUrl,
    image: page.image,
    siteName: page.siteName,
    alternates: page.alternates,
    defaultAlternate: page.defaultAlternate,
    favicon: page.favicon,
    schemaType: page.schemaType,
    content: page.content,
  );
  final String? captured = page.html;
  final String body;
  if (captured != null && captured.trim().isNotEmpty) {
    body = dvApplyPageHtml(head, captured, path: page.route);
  } else {
    if (page.text.isNotEmpty) onUncaptured?.call(page.route);
    body = dvApplyPageText(head, page.text, path: page.route);
  }
  return dvMinifyHtml(body);
}