homepageTheme/gen.sh

38 lines
734 B
Bash

#!/usr/bin/env bash
# Init venv
cd `dirname $0` &&
(
if [ ! -d ./venv ]; then
echo "Create venv" &&
python3 -m venv venv
fi
) &&
source ./venv/bin/activate &&
# Install updates
pip install --upgrade pip &&
pip install --upgrade pelican markdown htmlmin &&
# Clean and generate
(rm -rf output || true) &&
python3 -c "import pelican; pelican.main()" content &&
# Optimize
tools/cssfix.py output/theme/css/* &&
(
for i in `find output -wholename "*.html"`
do
htmlmin -c -s "$i" "$i" || exit 1
done
) &&
# Compress
(
for i in `find output -wholename "*.css" -or -wholename "*.js" -or -wholename "*.html"`
do
(gzip --best --keep "$i" && brotli --best --keep "$i") ||
(echo ERROR in file $i; exit 1) || exit 1
done
)