Only store titlesort in meta pagestate if it differs from title
authorSimon McVittie <smcv@debian.org>
Mon, 5 Apr 2010 23:58:55 +0000 (00:58 +0100)
committerSimon McVittie <smcv@debian.org>
Mon, 5 Apr 2010 23:58:55 +0000 (00:58 +0100)
IkiWiki/Plugin/meta.pm

index 553f9345587889cc779c27679cc5e14ddccf65e2..7f19b46a3cf89f4f9d3317d9fbc5d06879803e70 100644 (file)
@@ -88,13 +88,18 @@ sub preprocess (@) {
 
        # Metadata collection that needs to happen during the scan pass.
        if ($key eq 'title') {
-               $pagestate{$page}{meta}{title}=HTML::Entities::encode_numeric($value);
+               my $encoded = HTML::Entities::encode_numeric($value);
+               $pagestate{$page}{meta}{title} = $encoded;
+
                if (exists $params{sortas}) {
                        $pagestate{$page}{meta}{titlesort}=$params{sortas};
                }
-               else {
+               elsif ($encoded ne $value) {
                        $pagestate{$page}{meta}{titlesort}=$value;
                }
+               else {
+                       delete $pagestate{$page}{meta}{titlesort};
+               }
                return "";
        }
        elsif ($key eq 'description') {