Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 55 lines (44 sloc) 1.24 KB
#!/bin/bash
set -e
ADDR="http://localhost:30030"
DEST_DIR="docs"
PAGES_DIR="pages"
STATIC_DIR="static"
cd $(dirname $0)/..
echo "starting server..."
node_modules/.bin/next build
node_modules/.bin/next start -p 30030 2>&1 > /dev/null &
#NEXT_PID=$!
#NEXT_PGID=$(ps -aeo pid,pgid | grep -E "$NEXT_PID\s+[0-9]+" | sed "s/$NEXT_PID\s\+\([0-9]\+\)/\1/g")
echo "downloading static assets..."
rm -rf $DEST_DIR
set +e
wget --html-extension \
--recursive \
--page-requisites \
--no-parent \
--directory-prefix "$DEST_DIR" \
--no-host-directories \
--restrict-file-names=unix \
--quiet \
--retry-connrefused \
--waitretry 2 \
--tries 5 \
-i <(find "$PAGES_DIR" -type f | \
sed "s:^$PAGES_DIR\(.*\)\.js\$:\1:g" | \
sed 's:/index$:/:g' | \
sed "s,\(.*\),$ADDR\1,g")
set -e
# fix /_next path
sed -e 's:/_next:_next:g' $DEST_DIR/index.html > $DEST_DIR/index.html.tmp
mv $DEST_DIR/index.html.tmp $DEST_DIR/index.html
echo "closing server..."
pkill -INT -g $$ node
#pkill -INT -g $NEXT_PGID
wait
echo "copying static files.."
mkdir -p $DEST_DIR/static
cp -r $STATIC_DIR/* $DEST_DIR/static
# prevent using jekyll on github pages
touch $DEST_DIR/.nojekyll
echo "done"