An adaptation of the educenter Hugo theme
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

65 lines
904 B

#! /bin/bash
usage() {
printf 'usage: %s [--no-gzip]\n' "$0"
exit 0
}
compress() {
f="$1"
zopfli "$f" --stdout > "$f.gz"
}
export -f compress
set -e
script="$0"
scriptdir=$(dirname "$script")
gz=1
if [ "$#" -ge 1 ]; then
if [ "$1" = "--no-gzip" ]; then
gz=0
fi
fi
SITE_DIR="public"
exts="html
css
js
ttf
atom
stl
xml
svg
eot
ico
json"
rm -rf $SITE_DIR
hugo --minify --gc
printf '\nPurging CSS...'
npx purgecss -c "$scriptdir/purgecss.config.js" -o "$SITE_DIR/css"
printf 'Done\n'
sed -i -f "$scriptdir/script.sed" "$SITE_DIR/css/theme.css"
s=""
for t in $exts; do
temp=$(find $SITE_DIR -type f -name "*.$t")
if [ "$temp" != "" ]; then
s=$(printf '%s\n%s' "$temp" "$s")
fi
done
if [ "$gz" -ne 0 ]; then
printf '%s\n' "$s" | parallel --progress --eta -j$CORES compress
fi
rm -rf "$SITE_DIR/purgecss.config.js" "$SITE_DIR/LICENSE.txt" "$SITE_DIR/LICENSE" "$SITE_DIR/build.sh"