<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
package IkiWiki::Plugin::pagecount;

use warnings;
use strict;
use IkiWiki 3.00;

sub import {
	hook(type =&gt; "getsetup", id =&gt; "pagecount", call =&gt; \&amp;getsetup);
	hook(type =&gt; "preprocess", id =&gt; "pagecount", call =&gt; \&amp;preprocess);
}

sub getsetup () {
	return 
		plugin =&gt; {
			safe =&gt; 1,
			rebuild =&gt; undef,
		},
}

sub preprocess (@) {
	my %params=@_;
	$params{pages}="*" unless defined $params{pages};
	
	# Needs to update count whenever a page is added or removed, so
	# register a dependency.
	add_depends($params{page}, $params{pages});
	
	my @pages;
	if ($params{pages} eq "*") {
		@pages=keys %pagesources;
	}
	else {
		@pages=pagespec_match_list([keys %pagesources], $params{pages}, location =&gt; $params{page});
	}
	return $#pages+1;
}

1
</pre></body></html>