X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/0f6fce7dcc8932ef9b9988d9ee310cdcadca549b..ce7966a82cf8d0043a771a1a5b26e3a953e909b2:/IkiWiki/Plugin/parentlinks.pm diff --git a/IkiWiki/Plugin/parentlinks.pm b/IkiWiki/Plugin/parentlinks.pm index 6acfcd063..bdf678069 100644 --- a/IkiWiki/Plugin/parentlinks.pm +++ b/IkiWiki/Plugin/parentlinks.pm @@ -16,6 +16,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 1, + section => "core", }, } @@ -32,10 +33,9 @@ sub parentlinks ($) { my @pagepath=(split("/", $page)); my $pagedepth=@pagepath; - if ($pagepath[$#pagepath] eq 'index') { - pop @pagepath; # Remove 'index' - pop @pagepath; # Remove directory above 'index' - } + # The last element in @pagepath is the page itself, so punt that + # (These are /parent/ links, after all.) + pop @pagepath; foreach my $dir (@pagepath) { next if $dir eq 'index'; @@ -44,7 +44,7 @@ sub parentlinks ($) { $path.="/".$dir; $title=pagetitle($dir); push @ret, { - url => urlto($path, $page), + url => urlto(bestlink($page, $path), $page), page => $title, depth => $depth, height => $height, @@ -61,8 +61,11 @@ sub pagetemplate (@) { my $page=$params{page}; my $template=$params{template}; - if ($template->query(name => "parentlinks")) { - $template->param(parentlinks => [parentlinks($page)]); + if ($template->query(name => "parentlinks") || + $template->query(name => "has_parentlinks")) { + my @links=parentlinks($page); + $template->param(parentlinks => \@links); + $template->param(has_parentlinks => (@links > 0)); } }