#!/bin/bash SITE_TITLE="Volpeon's Den" target () { if [ "${1#*.}" = "md" ]; then echo "dist/$(echo "${1%.md}.html" | cut -sd / -f 2-)" else echo "dist/$(echo "$1" | cut -sd / -f 2-)" fi } compile () { TARGET=$(target "$1") mkdir -p $(dirname "$TARGET") pandoc "$1" \ -t html5 \ --template templates/base.html \ -o "$TARGET" \ --metadata sitetitle="$SITE_TITLE" } if [ -z "$1" ]; then find content/ \ -iname "*.md" \ -type f \ | while read FILE do compile "$FILE" done else if [ "$2" = "delete" ]; then rm -rf $(target $1) else compile "$1" fi fi