#!/usr/bin/env bash
#
# Build/serve/deploy the SecureAI MkDocs site while keeping the repository FLAT.
#
# Why this exists: all site content lives in the repository root (index.md, the Workshop*/
# directories, assets/, models/). MkDocs does not allow `docs_dir` to be the directory that
# contains mkdocs.yml, so we cannot point it directly at the root. Instead this script builds a
# gitignored `_docs/` directory of symlinks to the flat content and uses that as the docs dir
# (mkdocs.yml has `docs_dir: _docs`). The repository itself stays flat.
#
# Usage:
#   ./build.sh serve              # local preview at http://127.0.0.1:8000
#   ./build.sh build --strict     # produce ./site
#   ./build.sh gh-deploy --force  # build and publish to the gh-pages branch
#
set -euo pipefail
cd "$(dirname "$0")"

# Content to expose to MkDocs (everything except repo-level files: mkdocs.yml, README, etc.).
CONTENT=(index.md overview.md resources.md program_conclusion.md assets models Workshop*)

rm -rf _docs
mkdir _docs
for item in "${CONTENT[@]}"; do
  [ -e "$item" ] && ln -s "../$item" "_docs/$item"
done

exec mkdocs "$@"
