aboutsummaryrefslogtreecommitdiff
path: root/doc/plugins
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2010-03-24 00:29:10 +0000
committerSimon McVittie <smcv@debian.org>2010-03-24 00:29:10 +0000
commite67a9382f67e745af3be7d367fe7a0d36c1777e6 (patch)
treea8c244b493dbc96b13488df948f5ac90718df45a /doc/plugins
parente74a85c671cf9fe1e445ad183d66e059beaec2f9 (diff)
downloadikiwiki-e67a9382f67e745af3be7d367fe7a0d36c1777e6.tar
ikiwiki-e67a9382f67e745af3be7d367fe7a0d36c1777e6.tar.gz
Allow hooks to add sorting functions to pagespec_match_list
Diffstat (limited to 'doc/plugins')
-rw-r--r--doc/plugins/write.mdwn15
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn
index 96a2aa16d..bfa6617bd 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -588,6 +588,21 @@ describes the plugin as a whole. For example:
This hook is used to inject C code (which it returns) into the `main`
function of the ikiwiki wrapper when it is being generated.
+### sort
+
+ hook(type => "sort", id => "foo", call => \&sort_by_foo);
+
+This hook adds an additional [[ikiwiki/pagespec/sorting]] order or overrides
+an existing one. The callback is given two page names as arguments, and
+returns negative, zero or positive if the first page should come before,
+close to (i.e. undefined order), or after the second page.
+
+For instance, the built-in `title` sort order could be reimplemented as
+
+ sub sort_by_title {
+ pagetitle(basename($_[0])) cmp pagetitle(basename($_[1]));
+ }
+
## Exported variables
Several variables are exported to your plugin when you `use IkiWiki;`