Commit | Line | Data |
ebd4c292 |
1 | package SCSite::SubListFilter; |
2 | |
3 | use Moo; |
4 | |
5 | with 'SCSite::Filter'; |
6 | |
7 | sub _filter_stream { |
8 | my ($self, $stream, $config, $page) = @_; |
9 | my $max = $config->{max_entries}||undef; # explicit undef (not 0) |
2a19b2a6 |
10 | my %child = |
11 | map +(exists $config->{$_} ? ($_ => $config->{$_}) : ()), |
12 | qw(min_depth max_depth at_depth); |
ebd4c292 |
13 | $stream->select('.SubList') |
2a19b2a6 |
14 | ->repeat_content($page->children(%child)->latest($max)->map(sub { |
ebd4c292 |
15 | my $o = shift; |
16 | sub { |
17 | $_->select('.entry.title')->replace_content($o->title) |
2a19b2a6 |
18 | ->select('.entry.subtitle')->replace_content($o->subtitle) |
ebd4c292 |
19 | ->select('.entry.description')->replace_content($o->description) |
2a19b2a6 |
20 | ->select('.entry.published_at')->replace_content($o->published_at) |
34597fb2 |
21 | ->select('.entry.link')->set_attribute(href => $o->path); |
ebd4c292 |
22 | } |
23 | })); |
24 | } |
25 | |
26 | 1; |