#!/bin/bash -e
set -Eeuo pipefail

if [[ ! -f hugo/hugo ]] || ( ! ( hugo/hugo version | grep -q extended ) ); then
  curl -L https://github.com/gohugoio/hugo/releases/download/v0.135.0/hugo_extended_0.135.0_linux-amd64.tar.gz | tar -xvz -C hugo/
fi
export PATH="$(pwd)/hugo:$PATH"

cd siterepo
npm config set registry http://172.19.10.7:4873/
./build.sh
rm ./hugo-static/public/manifest.json # Conflicts with main manifest.
cp -r ./assets/* ./assets/.??* ./hugo-static/public/* ../sitegen/
mkdir -p ../sitegen/worldwideportal
cp -r ./worldwideportal-static/public/* ../sitegen/worldwideportal
