pagesForGenerator function

List<SeoResolvedPage> pagesForGenerator({
  1. required String canonicalBase,
  2. List<SeoRoute>? routes,
  3. List<SeoResolvedPage>? pages,
  4. List<String> additionalPaths = const [],
  5. SeoDetail detail = SeoDetail.head,
})

The shared front door of the synchronous generators (seoSitemapXml, seoLlmsTxt): resolve routes, or validate and return a pre-resolved pages snapshot.

Exactly one of routes and pages must be given; additionalPaths may not accompany pages, since they were already folded into the pass that produced them.

Implementation

List<SeoResolvedPage> pagesForGenerator({
  required String canonicalBase,
  List<SeoRoute>? routes,
  List<SeoResolvedPage>? pages,
  List<String> additionalPaths = const [],
  SeoDetail detail = SeoDetail.head,
}) {
  if ((routes == null) == (pages == null)) {
    throw ArgumentError('Pass exactly one of `routes:` or `pages:`.');
  }
  if (pages != null) {
    if (additionalPaths.isNotEmpty) {
      throw ArgumentError(
        '`additionalPaths` cannot be combined with `pages:` — fold them into '
        'resolveSeoPages(additionalPaths: …) instead.',
      );
    }
    return pages;
  }
  return resolveSeoPagesSync(
    routes: routes!,
    canonicalBase: canonicalBase,
    additionalPaths: additionalPaths,
    detail: detail,
  );
}