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