#!/bin/bash # compiles new post into target directory rootDir='./tmp/' post() { # First get the body of the document tmp=".swap" base=$(basename $1) cat 'templates/post-header.html' > $tmp pandoc $1 >> $tmp cat 'templates/post-footer.html' >> $tmp sed -i "3i ${base%.*}" $tmp # finally move this post to its proper location in the _rootDir mv $tmp "$rootDir/post/${base%.*}.html" rm -f $tmp } target="" for file in $@;do post $file done