diff --git a/.env b/.env new file mode 100644 index 0000000..1605118 --- /dev/null +++ b/.env @@ -0,0 +1,8 @@ +# Shared configuration for all scripts. +# Sourced by scripts/*.sh — do not use Docker --env-file with this. + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[1]}")" && pwd)" +PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" +SITE_DIR="${PROJECT_ROOT}/site" +HUGO_IMAGE="ghcr.io/gohugoio/hugo:latest" +PORT="${PORT:-1313}" diff --git a/scripts/build.sh b/scripts/build.sh index 393e909..1c9e668 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -4,11 +4,8 @@ set -euo pipefail # Build and serve the Hugo site locally using Docker. # Usage: ./scripts/build.sh -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" -SITE_DIR="${PROJECT_ROOT}/site" -HUGO_IMAGE="ghcr.io/gohugoio/hugo:latest" -PORT="${1:-1313}" +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../.env" +PORT="${1:-$PORT}" if [[ ! -d "${SITE_DIR}" ]]; then echo "[build] Site directory not found: ${SITE_DIR}" diff --git a/scripts/serve.sh b/scripts/serve.sh index 33a4a38..d3a1b91 100755 --- a/scripts/serve.sh +++ b/scripts/serve.sh @@ -4,11 +4,8 @@ set -euo pipefail # Serve the Hugo site locally using Docker. # Usage: ./scripts/serve.sh -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" -SITE_DIR="${PROJECT_ROOT}/site" -HUGO_IMAGE="ghcr.io/gohugoio/hugo:latest" -PORT="${1:-1313}" +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../.env" +PORT="${1:-$PORT}" if [[ ! -d "${SITE_DIR}" ]]; then echo "[serve] Site directory not found: ${SITE_DIR}" diff --git a/scripts/setup.sh b/scripts/setup.sh index a13830e..c66535b 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -4,10 +4,7 @@ set -euo pipefail # Initialize a Hugo site with the Terminal theme using Docker. # Usage: ./scripts/setup.sh -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" -SITE_DIR="${PROJECT_ROOT}/site" -HUGO_IMAGE="ghcr.io/gohugoio/hugo:latest" +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../.env" hugo() { docker run --rm \