Skip to content

Commit

Permalink
Fix Hugo command line for building site
Browse files Browse the repository at this point in the history
Also added options for specifying Hugo executable and target directory
to Unix site build script.
  • Loading branch information
sophokles73 committed Nov 27, 2024
1 parent 83ea63e commit 75af402
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 19 deletions.
10 changes: 5 additions & 5 deletions site/build-site.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@rem ***************************************************************************
@rem Copyright (c) 2016, 2022 Contributors to the Eclipse Foundation
@rem Copyright (c) 2016 Contributors to the Eclipse Foundation
@rem
@rem See the NOTICE file(s) distributed with this work for additional
@rem information regarding copyright ownership.
Expand Down Expand Up @@ -30,19 +30,19 @@ IF ERRORLEVEL 1 (
cd homepage
IF NOT "%~1"=="" (
ECHO Going to build homepage in directory: %1
hugo -v -d %1
hugo -d %1
) ELSE (
ECHO Going to build homepage in default directory...
hugo -v
hugo
)
cd ..

cd documentation
IF NOT "%~1"=="" (
ECHO Going to build documentation in directory: %1\docs
hugo -v -d %1\docs
hugo -d %1\docs
) ELSE (
ECHO Going to build documentation in default directory...
hugo -v
hugo
)
cd ..
55 changes: 41 additions & 14 deletions site/build-site.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#*******************************************************************************
# Copyright (c) 2016, 2022 Contributors to the Eclipse Foundation
# Copyright (c) 2016 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
Expand All @@ -12,17 +12,44 @@
# SPDX-License-Identifier: EPL-2.0
#*******************************************************************************

target="public"
hugo_cmd="hugo"

if ! hugo version; then
echo "Please install \"hugo\" to be able to build the hono documentation. See readme.md for further details."
exit 0
fi
print_usage() {
cmd_name=$(basename "$0")
cat <<EOF >&2
Usage: ${cmd_name} OPTIONS ...
OPTIONS
-h | --help Display this usage information.
-H | --hugo The path to the Hugo executable to use for building the site. [$hugo_cmd]
-t | --target PATH The path to the folder to contain the site. [$target]
if [ "$1" ]
then
TARGET="$1"
else
TARGET="public"
EOF
}

while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do case $1 in
-h | --help )
print_usage
exit 1
;;
-H | --hugo )
shift; hugo_cmd=$1
;;
-t | --target )
shift; target=$1
;;
*)
echo "Ignoring unknown option: $1"
echo "Run with flag -h for usage"
;;
esac; shift; done
if [[ "$1" == '--' ]]; then shift; fi

if ! $hugo_cmd version; then
echo "Could not find \"$hugo_cmd\" executable on your PATH. See readme.md for further details."
exit 0
fi

if ! git submodule status; then
Expand All @@ -31,11 +58,11 @@ if ! git submodule status; then
fi

cd homepage || exit
echo "Building homepage in directory: $TARGET"
hugo -v -d $TARGET
echo "Building homepage in directory: $target"
$hugo_cmd -d $target
cd ..

cd documentation || exit
echo "Building documentation in directory: $TARGET/docs"
hugo -v -d $TARGET/docs
echo "Building documentation in directory: $target/docs"
$hugo_cmd -d $target/docs
cd ..

0 comments on commit 75af402

Please sign in to comment.