aboutsummaryrefslogtreecommitdiff
path: root/ssg
diff options
context:
space:
mode:
Diffstat (limited to 'ssg')
-rwxr-xr-xssg53
1 files changed, 34 insertions, 19 deletions
diff --git a/ssg b/ssg
index f502040..d2faa90 100755
--- a/ssg
+++ b/ssg
@@ -1,6 +1,9 @@
#!/usr/bin/perl
use strict;
use warnings;
+use v5.22;
+# Disable experimental warnings.
+no warnings 'experimental';
use File::Path qw(make_path remove_tree);
use Path::Class;
@@ -11,6 +14,10 @@ my $indir;
my $outdir;
my $VERSION = "v0.1";
+my @exlude_files = (
+ qr/TIL\/\w+\/*/
+);
+
sub help {
print<<EOF
$0 [switches] input-directory
@@ -90,29 +97,37 @@ sub generate_link {
my ($file, $options) = @_;
$options->{hl} = 0 if !exists($options->{hl});
- my $path = $file->stringify;
- my $str = $file->basename;
+ # Exclude links
+ given($file) {
+ when(@exlude_files) {
+ return "";
+ }
+ default {
+ my $path = $file->stringify;
+ my $str = $file->basename;
- if($path =~ /index\.md$/) {
- return "";
- }
+ if($path =~ /index\.md$/) {
+ return "";
+ }
- # remove the input directory.
- $path =~ s/^$indir//g;
- if($file->is_dir()) {
- $str = "$str/" if $file->is_dir();
- } else {
- $path =~ s/\.md$/.html/g;
- $str =~ s/\.md$//g;
- }
+ # remove the input directory.
+ $path =~ s/^$indir//g;
+ if($file->is_dir()) {
+ $str = "$str/" if $file->is_dir();
+ } else {
+ $path =~ s/\.md$/.html/g;
+ $str =~ s/\.md$//g;
+ }
- # Higlight?
- my $hl = "";
- if($options->{hl} eq 1) {
- $hl = "class='hl'";
- }
+ # Higlight?
+ my $hl = "";
+ if($options->{hl} eq 1) {
+ $hl = "class='hl'";
+ }
- return "<li><a $hl href='$path'>$str</a></li>";
+ return "<li><a $hl href='$path'>$str</a></li>";
+ }
+ }
}
sub transverse {