summaryrefslogtreecommitdiff
path: root/doc
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
parente74a85c671cf9fe1e445ad183d66e059beaec2f9 (diff)
Allow hooks to add sorting functions to pagespec_match_list
Diffstat (limited to 'doc')
-rw-r--r--doc/ikiwiki/pagespec/sorting.mdwn2
-rw-r--r--doc/plugins/write.mdwn15
2 files changed, 17 insertions, 0 deletions
diff --git a/doc/ikiwiki/pagespec/sorting.mdwn b/doc/ikiwiki/pagespec/sorting.mdwn
index 697818a2a..9007c23bf 100644
--- a/doc/ikiwiki/pagespec/sorting.mdwn
+++ b/doc/ikiwiki/pagespec/sorting.mdwn
@@ -10,4 +10,6 @@ orders can be specified.
installed. Orders by title, but numbers in the title are treated
as such, ("1 2 9 10 20" instead of "1 10 2 20 9")
+Plugins can add additional sort orders.
+
[[!meta robots="noindex, follow"]]
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;`