#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
function clean {
rm -fr output_*
}
# Create a new note.
function new {
if [[ "$1" == "" ]]; then
echo "Usage: ./run new
"
exit 1
fi
title="$1"
zet_path="source/_zets"
zet_count=$(find "$zet_path" -type f | wc -l)
next_zet=$((zet_count + 1))
next_zet_path="$zet_path/$next_zet.md"
date=$(date +"%Y-%m-%d %T")
{
echo "---"
echo "title: ${title}"
echo "date: ${date}"
echo "tags: []"
echo "---"
echo ""
} > "$next_zet_path"
git add "$next_zet_path"
git commit -m "$title"
}
# Generate and publish a new version of the website.
function publish {
git push
clean
APP_ENV=production generate
rsync -avz output_prod/ ssh.oliverdavies.uk:/var/www/vhosts/zet.oliverdavies.uk
}