aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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};
}