docs: document favicon generation; chore: add generate-favicon script and yarn task

This commit is contained in:
2025-08-16 13:22:00 -06:00
parent 7e4b13606c
commit 89a75c94ca
3 changed files with 55 additions and 0 deletions

40
tools/generate-favicon.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/env bash
set -euo pipefail
# Generates a multi-size favicon.ico from public/favicon.svg
# Dependencies:
# - rsvg-convert (from librsvg)
# - ImageMagick (magick)
# macOS install:
# brew install librsvg imagemagick
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
SVG_PATH="${ROOT_DIR}/public/favicon.svg"
OUT_ICO_PATH="${ROOT_DIR}/public/favicon.ico"
if ! command -v rsvg-convert >/dev/null 2>&1; then
echo "ERROR: rsvg-convert not found. Install with: brew install librsvg" >&2
exit 1
fi
if ! command -v magick >/dev/null 2>&1; then
echo "ERROR: ImageMagick (magick) not found. Install with: brew install imagemagick" >&2
exit 1
fi
tmp_dir="$(mktemp -d)"
cleanup() { rm -rf "${tmp_dir}"; }
trap cleanup EXIT
sizes=(16 32 48 64)
pngs=()
for s in "${sizes[@]}"; do
out_png="${tmp_dir}/favicon-${s}.png"
rsvg-convert -w "${s}" -h "${s}" "${SVG_PATH}" -o "${out_png}"
pngs+=("${out_png}")
done
magick "${pngs[@]}" "${OUT_ICO_PATH}"
echo "Generated ${OUT_ICO_PATH}"