Try a slightly revised generateStaticSite script

This commit is contained in:
dannyrb 2019-05-13 14:52:13 -04:00
parent 5e37931aad
commit 1679a0f93e

View File

@ -1,4 +1,9 @@
cd docs #!/bin/bash
# Set directory to location of this script
# https://stackoverflow.com/a/3355423/1867984
cd "$(dirname "$0")"
yarn -v yarn -v
node -v node -v
echo 'Installing Gitbook CLI' echo 'Installing Gitbook CLI'
@ -7,18 +12,22 @@ yarn global add gitbook-cli
echo 'Running Gitbook installation' echo 'Running Gitbook installation'
# Generate all version's GitBook output # Generate all version's GitBook output
# For each directory in /docs ...
cd ./docs/
for D in *; do for D in *; do
if [ -d "${D}" ]; then if [ -d "${D}" ]; then
echo "Generating output for: ${D}"
cd "${D}"
# Clear previous output, generate new echo "Generating output for: ${D}"
rm -rf _book cd "${D}"
gitbook install
gitbook build
cd .. # Clear previous output, generate new
fi rm -rf _book
gitbook install
gitbook build
cd ..
fi
done done
# Move CNAME File into `latest` # Move CNAME File into `latest`
@ -31,10 +40,12 @@ mkdir ./latest/_book/history
for D in *; do for D in *; do
if [ -d "${D}" ]; then if [ -d "${D}" ]; then
if [ "${D}" == v* ] ; then if [ "${D}" == v* ] ; then
echo "Moving ${D} to the latest version's history folder"
echo "Moving ${D} to the latest version's history folder"
mkdir "./latest/_book/history/${D}" mkdir "./latest/_book/history/${D}"
mv -v "./${D}/_book"/**/* "./latest/_book/history/${D}" mv -v -r "./${D}/_book"/* "./latest/_book/history/${D}"
fi fi
fi fi
done done