build.sh (734B) - raw
1 #!/bin/sh 2 3 # How it works: 4 # Delete everything in site dir 5 # first, build nav html string 6 # lists all files recursively in srcdir 7 # copies them to outdir if not html 8 # otherwise, add header and footer 9 10 outdir=_site 11 srcdir=src 12 13 mkdir -p $outdir 14 rm -rf $outdir/* 15 16 for file in $(find $srcdir); do 17 realpath=`echo $file | sed -e "s/^${srcdir}\///"` 18 fn=$outdir/$realpath 19 mkdir -p `dirname $fn` 20 if [[ $file == *.html ]]; then 21 title=`basename $file` 22 cat templates/header.html | sed -e "s/{title}/${title}/" > $fn 23 cat $file >> $fn 24 updated=`git log -1 --pretty="format:%ci" $file | awk '{print $1}'` 25 cat templates/footer.html | sed -e "s/{updated}/$updated/" >> $fn 26 else 27 cp $file $fn 2> /dev/null 28 fi 29 done