blob: d8c647be90ae5aa57abff90f7148f0c444f4a4e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/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=<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"
|