set -ex if [ $# -gt 2 ]; then echo "./publish-blog.sh [isodate] mds/blog/blog-file.md" exit 1 fi if [ $# -lt 1 ]; then echo "./publish-blog.sh [isodate] mds/blog/blog-file.md" exit 1 fi # Setup Dates isodate=$(date -I) date=$(date +"%B %d, %Y") if [ $# -eq 2 ]; then isodate=$1 date=$(date --date="${isodate}" +"%B %d, %Y") in=$2 else in=$1 fi # Get Page Title title=$(head -n1 $in | sed -E 's/^##[[:space:]]*(.+)[[:space:]]*$/\1/g') # File info path=www/blog/${isodate} out=${path}/index.html # Make path mkdir -p ${path} # Compile md ./compile-md.sh blog "${title}" $in $out # Update date sed -E -i "s/BLOG_DATE/${date}/" $out