+
+ my @backlinks = IkiWiki::backlink_pages($page);
+
+ if (exists $params{among}) {
+ # only consider backlinks from the amoung pages
+ @backlinks = pagespec_match_list(
+ $params{page}, $params{among},
+ # update whenever links on those pages change
+ deptype => deptype("links"),
+ list => \@backlinks
+ );
+ }
+ else {
+ # update when any page with links changes,
+ # in case the links point to our displayed pages
+ add_depends($params{page}, "*", deptype("links"));
+ }
+
+ $counts{$page} = scalar(@backlinks);