PressPage constructor

PressPage({
  1. required Iterable<String> slug,
  2. required Uri location,
  3. required String title,
  4. required MdcDocument content,
  5. required String sourcePath,
  6. String? description,
  7. int order = 0,
  8. bool draft = false,
  9. String? language,
})

Creates a parsed content page.

Implementation

PressPage({
  required Iterable<String> slug,
  required this.location,
  required this.title,
  required this.content,
  required this.sourcePath,
  this.description,
  this.order = 0,
  this.draft = false,
  this.language,
}) : slug = List<String>.unmodifiable(slug) {
  if (title.trim().isEmpty) {
    throw ArgumentError.value(title, 'title', 'Must not be empty.');
  }
  if (!location.hasAbsolutePath ||
      location.hasScheme ||
      location.hasAuthority ||
      location.hasQuery ||
      location.hasFragment) {
    throw ArgumentError.value(
      location,
      'location',
      'Must be an absolute local path without query or fragment.',
    );
  }
  for (final segment in this.slug) {
    if (segment.isEmpty ||
        segment == '.' ||
        segment == '..' ||
        segment.contains('/') ||
        segment.contains(r'\')) {
      throw ArgumentError.value(slug, 'slug', 'Contains an invalid segment.');
    }
  }
}