Skip to content

Instantly share code, notes, and snippets.

@epcim
Forked from Integralist/hugo-build.sh
Created September 24, 2017 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epcim/bff541b534716b85bc1d045ddec80565 to your computer and use it in GitHub Desktop.
Save epcim/bff541b534716b85bc1d045ddec80565 to your computer and use it in GitHub Desktop.
[Hugo build script for User page] #github #hugo #build
#!/usr/bin/env bash
function contains {
local e match="$1"
shift
for e; do [[ "$e" == "$match" ]] && return 0; done
return 1
}
function remove_toplevel {
local blacklist=(build.sh CNAME keybase.txt src)
local trigger=0
for i in *; do
if contains "$i" "${blacklist[@]}"; then
trigger=1
echo "this is a blacklist file: $i"
else
rm -rf "$i"
fi
done
if [[ $trigger -eq 1 ]]; then
printf "\n...we won't delete these files.\n\n"
fi
}
function build_site {
pushd "./src" 1>/dev/null
hugo
cp -r ./public/ ../
popd 1>/dev/null
}
remove_toplevel
build_site
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment