wiki: publish pending edits (2026-10-20)

This commit is contained in:
Tony0410
2026-10-20 18:38:11 +08:00
parent 667ab7f41d
commit fbd4f297eb
46 changed files with 1012 additions and 197 deletions
+57 -13
View File
@@ -142,21 +142,65 @@ python3 "$STOCKTAKE_DIR/_freshness_audit.py" "$WIKI_DIR" "$REPORT" 21
echo ""
# =============================================================================
# [3/3] Rebuild Quartz static site
# [3/3] Rebuild Quartz static site and deploy to public/
# =============================================================================
echo "[3/3] Checking Quartz build..."
# Quartz is already built into public/ — if there's a build script, run it
# For now, the public/ dir is the Quartz output, regenerated when content changes
# If Quartz CLI is available, we'd run: npx quartz build
if command -v npx &> /dev/null && [ -f "$WIKI_DIR/quartz.config.ts" ]; then
echo " Running Quartz build..."
cd "$WIKI_DIR"
npx quartz build 2>&1 | head -20 || echo " Quartz build had issues (non-fatal)"
else
echo " Quartz build skipped (no quartz.config.ts or npx not available)"
echo " public/ directory contains the current static site"
# Quartz v4/v5 lives in a SEPARATE source tree (/home/hermes/workspace/quartz-temp);
# the wiki repo only holds the Markdown. The build reads content/ from that tree
# and emits public/ there, which we then deploy into the wiki repo's public/.
#
# PITFALL (hit 2026-10-20): the previous version of this step tested for
# `quartz.config.ts` and `npx`, and the repo has NEITHER — Quartz v4/v5 uses
# `quartz.config.yaml`. The test always failed, so the site silently stopped
# being rebuilt (published site was 40 days stale). Do not reintroduce a
# config-file existence test that isn't the real one: check quartz.config.yaml.
echo "[3/3] Rebuilding Quartz static site..."
QUARTZ_DIR="/home/hermes/workspace/quartz-temp"
QUARTZ_CONTENT="$QUARTZ_DIR/content"
QUARTZ_PUBLIC="$QUARTZ_DIR/public"
QUARTZ_DEPLOY_DIR="$WIKI_DIR/public"
if [ ! -f "$QUARTZ_DIR/quartz.config.yaml" ]; then
echo " ERROR: $QUARTZ_DIR/quartz.config.yaml not found — cannot build the Quartz site." >&2
echo " The published site will stay stale. Fix the Quartz source tree before continuing." >&2
exit 1
fi
# --- sync wiki Markdown into the Quartz content tree -------------------------
# raw/ is excluded on purpose: it holds raw config dumps and the stocktake
# reports, which have never been part of the published site. public/ and .git
# are excluded to avoid copying build output into the input tree.
rm -rf "$QUARTZ_CONTENT"
mkdir -p "$QUARTZ_CONTENT"
tar -C "$WIKI_DIR" \
--exclude=./public --exclude=./.git --exclude=./node_modules --exclude=./raw \
-cf - . | tar -C "$QUARTZ_CONTENT" -xf -
echo " Synced wiki content into $QUARTZ_CONTENT"
# --- build -------------------------------------------------------------------
cd "$QUARTZ_DIR"
# PIPESTATUS is required: a plain pipeline would report tail's exit code (0)
# and silently swallow a failed build.
npx quartz build 2>&1 | tail -8
BUILD_RC=${PIPESTATUS[0]}
if [ "$BUILD_RC" -ne 0 ]; then
echo " ERROR: Quartz build failed (exit $BUILD_RC)." >&2
exit 1
fi
# --- deploy ------------------------------------------------------------------
# Clear the CONTENTS of public/ rather than removing the directory itself:
# hermes-wiki-serve.service runs with its cwd inside public/, so replacing the
# directory inode leaves the running server serving a deleted directory (all
# requests 404) until it is restarted.
find "$QUARTZ_DEPLOY_DIR" -mindepth 1 -delete
cp -a "$QUARTZ_PUBLIC/." "$QUARTZ_DEPLOY_DIR/"
echo " Deployed $(find "$QUARTZ_DEPLOY_DIR" -type f | wc -l) files to $QUARTZ_DEPLOY_DIR"
systemctl --user restart hermes-wiki-serve.service 2>/dev/null \
&& echo " Restarted hermes-wiki-serve.service" \
|| echo " WARNING: could not restart hermes-wiki-serve.service — verify the site manually"
echo ""
echo "[wiki-maintain] Maintenance complete at $(date -Iseconds)"
echo " Freshness report: $REPORT"
@@ -164,4 +208,4 @@ echo ""
# Print summary
head -5 "$REPORT"
tail -3 "$REPORT"
tail -3 "$REPORT"