diff options
author | Matias Linares <matiaslina@openmailbox.org> | 2016-02-21 23:28:26 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@openmailbox.org> | 2016-02-21 23:28:26 -0300 |
commit | 4d716024dc58dc4c93c85c4c15ff3041b0dd3cd0 (patch) | |
tree | c1bc68319728f5c289f299bb51d9273bb0192c2f | |
parent | 5a7569fe91f6b442ef5f50dc3f82764eca2aa39c (diff) | |
download | ssg-4d716024dc58dc4c93c85c4c15ff3041b0dd3cd0.tar.gz |
remove all the 'index' links
-rwxr-xr-x | ssg | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -88,16 +88,21 @@ sub generate_link { my ($file, $options) = @_; $options->{hl} = 0 if !exists($options->{hl}); - # Get the path. my $path = $file->stringify; - $path =~ s/^$dir//g; - $path =~ s/\.md$/.html/g; - - # String to show my $str = $file->basename; - $str =~ s/\.md$//g; - $str = "$str/" if $file->is_dir(); + if($path =~ /index\.md$/) { + return ""; + } + + # remove the input directory. + $path =~ s/^$dir//g; + if($file->is_dir()) { + $str = "$str/" if $file->is_dir(); + } else { + $path =~ s/\.md$/.html/g; + $str =~ s/\.md$//g; + } # Higlight? my $hl = ""; @@ -120,7 +125,7 @@ sub transverse { next if $filename =~ /(\.|\.\.)$/; next if $filename eq $directory; - if($file_needed eq $file) { + if($file_needed eq $file or $file_needed->dir eq $filename) { $retval = "$retval" . generate_link($file, { hl => 1 }); } else { $retval = "$retval" . generate_link($file); @@ -179,18 +184,13 @@ sub main { ); getopts('vhd:', \%opts); - if($opts{h}) - { + if($opts{h}) { help; exit 0; - } - elsif($opts{v}) - { + } elsif($opts{v}) { version; exit 0; - } - elsif($opts{d}) - { + } elsif($opts{d}) { $dir = dir $opts{d}; } |