aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@openmailbox.org>2016-02-21 23:28:26 -0300
committerMatias Linares <matiaslina@openmailbox.org>2016-02-21 23:28:26 -0300
commit4d716024dc58dc4c93c85c4c15ff3041b0dd3cd0 (patch)
treec1bc68319728f5c289f299bb51d9273bb0192c2f
parent5a7569fe91f6b442ef5f50dc3f82764eca2aa39c (diff)
downloadssg-4d716024dc58dc4c93c85c4c15ff3041b0dd3cd0.tar.gz
remove all the 'index' links
-rwxr-xr-xssg32
1 files changed, 16 insertions, 16 deletions
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};
}