71 lines
2.0 KiB
Makefile
71 lines
2.0 KiB
Makefile
# Build everything then deploy
|
|
default: site (docs "pdf") (docs "epub") (docs "txt") images deploy
|
|
|
|
# Deploy website
|
|
deploy:
|
|
# Deploying website ...
|
|
rsync -qavmzz public/ hel1:/var/www/secluded/
|
|
# Website deployed
|
|
|
|
# Build website
|
|
site:
|
|
# Building website ...
|
|
hugo --quiet
|
|
|
|
# Build documents of filetype ext
|
|
docs ext:
|
|
#!/usr/bin/env bash
|
|
|
|
echo -e '\033[1m# Checking whether there are new {{uppercase(ext)}}s to build ...\033[0m'
|
|
|
|
export WEBROOT=public
|
|
|
|
published=$(grep -ilr --include \*.md "draft: false" content/posts)
|
|
|
|
todo=""
|
|
|
|
# Iterate through all non-drafts
|
|
for path in $published
|
|
do
|
|
filename=$(basename "$path")
|
|
name=$(echo "${filename%.*}")
|
|
# Check whether target doc is newer than Markdown file
|
|
if [ "$path" -nt "public/$name/$name.{{ext}}" ]
|
|
then
|
|
todo+="$path "
|
|
fi
|
|
done
|
|
|
|
if [ -z "$todo" ]
|
|
then
|
|
echo "No {{uppercase(ext)}}s to build"
|
|
exit 0
|
|
else
|
|
for path in $todo
|
|
do
|
|
filename=$(basename "$path")
|
|
name=$(echo "${filename%.*}")
|
|
echo "Generating $name.{{ext}}"
|
|
|
|
if [ "{{ext}}" == "pdf" ]
|
|
then
|
|
pandoc --quiet -f markdown -t pdf --lua-filter=pandoc_config/images.lua --pdf-engine=xelatex -V 'linkcolor:blue' --listings -H pandoc_config/styles.tex $path -o public/$name/$name.pdf
|
|
elif [ "{{ext}}" == "epub" ]
|
|
then
|
|
pandoc --quiet -f markdown -t epub3 --lua-filter=pandoc_config/images.lua --pdf-engine=xelatex -V 'linkcolor:blue' --listings -H pandoc_config/styles.tex $path -o public/$name/$name.epub
|
|
elif [ "{{ext}}" == "txt" ]
|
|
then
|
|
pandoc --quiet -f markdown -t plain --lua-filter=pandoc_config/images.lua $path -o public/$name/$name.txt
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# Generate cover images
|
|
images:
|
|
# Generating cover images ...
|
|
# TODO: Generate covers for posts that have changed or that have no cover
|
|
|
|
# Run development server
|
|
serve:
|
|
hugo server -D
|