package SCSite::SubListFilter;

use Moo;

with 'SCSite::Filter';

sub _filter_stream {
  my ($self, $stream, $config, $page) = @_;
  my $max = $config->{max_entries}||undef; # explicit undef (not 0)
  $stream->select('.SubList')
         ->repeat_content($page->children->latest($max)->map(sub {
             my $o = shift;
             sub {
               $_->select('.entry.title')->replace_content($o->title)
                 ->select('.entry.description')->replace_content($o->description)
                 ->select('.entry.created')->replace_content($o->created)
                 ->select('.entry.link')->set_attribute(href => $o->path);
             }
          }));
}

1;
