From 4d716024dc58dc4c93c85c4c15ff3041b0dd3cd0 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Sun, 21 Feb 2016 23:28:26 -0300 Subject: remove all the 'index' links --- ssg | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'ssg') diff --git a/ssg b/ssg index a81678c..4aafc85 100755 --- a/ssg +++ b/ssg @@ -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}; } -- cgit v1.2.3-70-g09d2