dvRenderRoutePage function
String
dvRenderRoutePage(
- String shell,
- DVRoutePage page, {
- void onUncaptured(
- String route
- bool minify = true,
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,
bool minify = true,
}) {
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,
robots: page.robots,
content: page.content,
structuredData: page.structuredData,
);
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);
}
// Unminified only for the streaming server, which cuts the head by the
// shell's own line breaks and minifies nothing it streams.
return minify ? dvMinifyHtml(body) : body;
}