dvRobotsTxt function

String dvRobotsTxt({
  1. required String siteUrl,
  2. bool sitemap = true,
})

A robots.txt allowing everything and naming siteUrl's sitemap when sitemap. What the build writes, and what the server answers per host.

Implementation

String dvRobotsTxt({required String siteUrl, bool sitemap = true}) {
  final String base = siteUrl.replaceAll(RegExp(r'/+$'), '');
  const String head =
      'User-agent: *\n'
      'Allow: /\n';
  if (!sitemap) return head;
  return '$head'
      '\n'
      'Sitemap: $base/sitemap.xml\n';
}