site/build.sh

38 lines
1013 B
Bash
Executable File

#!/bin/sh
#umask 0113
#. in reference to src/
for path in . ./wiki;do
tmpindex=$(mktemp --suffix '.md') # for generating list of markdown links for index.html
path="src/$path"
cat "$path/index.md" > $tmpindex
dir="$(echo $path|cut -d / -f 2-)";
find "$path" -maxdepth 1 -name "*.md" -exec sh -c "dir=\"$dir\" tmpindex=\"$tmpindex\""'
filename="$(basename "{}"|rev|cut -d . -f 2-|rev)";
if (echo "$dir" | grep "wiki") >/dev/null && (echo "$filename"|grep -v "^index$") >/dev/null;then
echo "- [$filename]($filename.html)" >> $tmpindex
fi
echo "building dist/$dir/$filename.html";
mkdir -p "dist/$dir/" && touch "dist/$dir/$filename.html";
markdown "src/$dir/$filename.md" |
cat inc/header.html - inc/footer.html >"dist/$dir/$filename.html"
' \;
done
echo "creating index page for wiki..."
markdown "$tmpindex" |
cat inc/header.html - inc/footer.html > dist/wiki/index.html
rm "$tmpindex"
echo "all done!"
# rsync (flags to delete if src is deleted) dist/ /var/www/tilde.cafe/