2 # Provides [[pagecount ]] to count the number of pages.
3 package IkiWiki::Plugin::pagecount;
10 hook(type => "preprocess", id => "pagecount", call => \&preprocess);
13 sub preprocess (@) { #{{{
15 $params{pages}="*" unless defined $params{pages};
17 # Needs to update count whenever a page is added or removed, so
18 # register a dependency.
19 add_depends($params{page}, $params{pages});
21 my @pages=keys %pagesources;
22 return $#pages+1 if $params{pages} eq "*"; # optimisation
24 foreach my $page (@pages) {
25 $count++ if pagespec_match($page, $params{pages}, $params{page});