summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/pagestats.pm3
-rw-r--r--IkiWiki/Render.pm17
2 files changed, 12 insertions, 8 deletions
diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm
index fdda5767a..cdde43628 100644
--- a/IkiWiki/Plugin/pagestats.pm
+++ b/IkiWiki/Plugin/pagestats.pm
@@ -35,8 +35,7 @@ sub preprocess (@) { #{{{
foreach my $page (keys %links) {
if (pagespec_match($page, $params{pages}, location => $params{page})) {
use IkiWiki::Render;
- my @bl = IkiWiki::backlinks($page);
- $counts{$page} = scalar(@{$bl[0]})+scalar(@{$bl[1]});
+ $counts{$page} = scalar(IkiWiki::backlinks($page));
$max = $counts{$page} if $counts{$page} > $max;
}
}
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 37383384d..92993fd95 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -44,11 +44,7 @@ sub backlinks ($) { #{{{
push @links, { url => $href, page => pagetitle($p_trimmed) };
}
- @links = sort { $a->{page} cmp $b->{page} } @links;
-
- return \@links, [] if @links <= $config{numbacklinks} || ! $config{numbacklinks};
- return [@links[0..$config{numbacklinks}-1]],
- [@links[$config{numbacklinks}..$#links]];
+ return @links;
} #}}}
sub parentlinks ($) { #{{{
@@ -105,7 +101,16 @@ sub genpage ($$$) { #{{{
$template->param(have_actions => 1);
}
- my ($backlinks, $more_backlinks)=backlinks($page);
+ my @backlinks=sort { $a->{page} cmp $b->{page} } backlinks($page);
+ my ($backlinks, $more_backlinks);
+ if (@backlinks <= $config{numbacklinks} || ! $config{numbacklinks}) {
+ $backlinks=\@backlinks;
+ $more_backlinks=[];
+ }
+ else {
+ $backlinks=[@backlinks[0..$config{numbacklinks}-1]];
+ $more_backlinks=[@backlinks[$config{numbacklinks}..$#backlinks]];
+ }
$template->param(
title => $page eq 'index'