#!/usr/bin/env bash PUB_DIR=${1:-/home/html/planet/static} FILES=md/*.md test -d tmp || mkdir tmp for f in $FILES do filename=$(basename -- $f .md) echo "publishing md/$filename.md to $PUB_DIR/$filename.html" lowdown -o tmp/$filename.html $f sed -i 's/^/ /' tmp/$filename.html cp head.html tmp/ # set the title title="$(echo $filename | awk '{for(i=1;i<=NF;i++){ $i=toupper(substr($i,1,1)) substr($i,2) }}1')" echo " $title • Anarchy Planet" >> tmp/head.html echo " " >> tmp/head.html echo " " >> tmp/head.html # compile the elements in order cat tmp/head.html nav.html tmp/$filename.html foot.html tail.html \ > $PUB_DIR/$filename.html done