#!/usr/bin/env bash # homepage-render-dev.sh — render jayrup.me locally WITHOUT deploying. # # Runs the same two-pass render (html + txt) as deploy-docker.sh inside the # pinned quarto container, writing output to public/ (gitignored). Use this to # preview blog posts / style changes before committing. # # Usage: # ./homepage-render-dev.sh [repo-dir] # default: current directory # QUARTO_IMAGE= ./homepage-render-dev.sh # override the container image # # Notes: # - The default image digest MUST stay in sync with deploy-docker.sh # (update both deliberately when bumping quarto). # - On voidlaptop, docker needs the docker group: run via `sg docker` or # `DOCKER=(sg docker -c)` wrapper. On other machines plain docker works. # - public/ and .quarto/ are gitignored; nothing here touches origin. set -euo pipefail REPO="${1:-$(pwd)}" cd "$REPO" QUARTO_IMAGE="${QUARTO_IMAGE:-devxygmbh/alpine-quarto@sha256:0c0d785139b467ab75c053bc24463d2450cbf928ca8ece8d9a20dedba9568fa9}" # Inner render script — written to a temp dir and mounted read-only into the # container. Mirrors the logic in deploy-docker.sh; keep the two in sync. TMP_DIR="$(mktemp -d)" trap 'rm -rf "$TMP_DIR"' EXIT RENDER_SCRIPT="$TMP_DIR/homepage-render.sh" cat > "$RENDER_SCRIPT" <<'EOF' #!/usr/bin/env bash set -euo pipefail cd /site rm -rf public quarto render --to html find . -name "*.qmd" -not -path "./.*" -not -path "./public/*" | while read -r file; do rel_dir=$(dirname "${file#./}") base_name=$(basename "$file" .qmd) quarto render "$file" --to plain --output "${base_name}.txt" --output-dir "public/$rel_dir" done EOF chmod +x "$RENDER_SCRIPT" echo ">> rendering with $QUARTO_IMAGE (dev, no deploy)" docker run --rm \ --entrypoint /bin/bash \ -u "$(id -u):$(id -g)" \ -e HOME=/tmp \ -v "$REPO":/site \ -v "$RENDER_SCRIPT":/render.sh:ro \ -w /site \ "$QUARTO_IMAGE" /render.sh echo ">> done — public/ is ready to preview: python3 -m http.server 8099 --directory public"