#!/usr/bin/env bash
# Serve the jan documentation site locally.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT"
CMD="${1:-serve}"
if [[ "$CMD" == "build" ]]; then
  shift || true
  if command -v uv >/dev/null 2>&1; then
    exec uv run --with-requirements docs/requirements.txt mkdocs build "$@"
  fi
  exec mkdocs build "$@"
fi
if [[ "$CMD" == "serve" ]]; then
  shift || true
fi
if command -v uv >/dev/null 2>&1; then
  exec uv run --with-requirements docs/requirements.txt mkdocs serve "$@"
fi
exec mkdocs serve "$@"
