generates simple blog index
authorDaniel <thefekete@gmail.com>
Tue, 23 Jun 2020 22:18:20 +0000 (00:18 +0200)
committerDaniel <thefekete@gmail.com>
Tue, 23 Jun 2020 22:18:20 +0000 (00:18 +0200)
Makefile
bin/blog_index [new file with mode: 0755]

index 94a9ea2..f4e6b9e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ posts=$(patsubst %.md,build/%.html,$(wildcard blog/*.md))
 # static sources
 S=img/
 
-all: build/index.html blog $S
+all: $S build/index.html build/blog/index.html $(posts)
        cp -av $S build/
 
 build/:
@@ -15,19 +15,21 @@ build/index.html: index.md build/ inc/head.template inc/foot.template
        echo "<p><small>Last updated `date -u`</small></p>" >>$@
        cat inc/foot.template >>$@
 
-blog: build/blog/ $(posts)
+
+build/blog/index.html: $(wildcard blog/*.md) build/blog/ bin/blog_index
+       bin/blog_index | bin/blog.awk >$@
 
 build/blog/: build/
        mkdir -p $@
 
-build/blog/%.html: blog/%.md build/ inc/head.template inc/foot.template
+build/blog/%.html: blog/%.md build/ inc/head.template inc/foot.template build/blog/
        @# `pacman -S discount` for `markdown`
        bin/blog.awk $< >$@
 
 publish: _not_dirty all _rsync
 
 clean:
-       rm -rfv build/
+       rm -rfv build/ blog/index.md
 
 _rsync: all
        rsync -vha --delete build/ root@thefekete.net:/var/www/thefekete.net/
diff --git a/bin/blog_index b/bin/blog_index
new file mode 100755 (executable)
index 0000000..3038f39
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+echo -e "% Blog Index\n"
+for p in $(ls -r blog); do
+       title=$(head -n1 "blog/$p" | sed 's/^% //')
+       echo -e "  * [${title}](${p%.*}.html)\n"
+done