Add path and path_natural sort orders
[ikiwiki.git] / IkiWiki / Plugin / sortnaturally.pm
index 92453749d9048f3acdea42bfc4058360e67d1e63..108b489f80d6f7e71916c891345ecea8569e9ed3 100644 (file)
@@ -7,13 +7,14 @@ no warnings;
 
 sub import {
        hook(type => "getsetup", id => "sortnaturally", call => \&getsetup);
+       hook(type => "checkconfig", id => "sortnaturally", call => \&checkconfig);
 }
 
 sub getsetup {
        return
                plugin => {
                        safe => 1,
-                       rebuild => 1,
+                       rebuild => undef,
                },
 }
 
@@ -29,4 +30,9 @@ sub cmp_title_natural {
                IkiWiki::pagetitle(IkiWiki::basename($b)))
 }
 
+sub cmp_path_natural {
+       Sort::Naturally::ncmp(IkiWiki::pagetitle($a),
+               IkiWiki::pagetitle($b))
+}
+
 1;