#!/usr/bin/env bash set -euo pipefail OUTPUT_DIR="${OUTPUT_DIR:-.output/public}" if [[ ! -d "$OUTPUT_DIR" ]]; then echo "Missing generated output directory: $OUTPUT_DIR" >&2 echo "Run 'npm run generate' inside nuxt-web first." >&2 exit 1 fi check_file_contains() { local file="$1" local label="$2" local pattern="$3" if [[ ! -f "$file" ]]; then echo "Missing $label file: $file" >&2 exit 1 fi if ! rg -q "$pattern" "$file"; then echo "Missing expected content in $label file: $file" >&2 echo "Pattern: $pattern" >&2 exit 1 fi } index_file="$OUTPUT_DIR/index.html" news_index_file="$OUTPUT_DIR/news/index.html" cases_index_file="$OUTPUT_DIR/cases/index.html" check_file_contains "$index_file" "homepage" "<(main|section|h1|h2)" check_file_contains "$news_index_file" "news index" "<(article|main|h1|h2|h3)" check_file_contains "$cases_index_file" "cases index" "<(article|main|h1|h2|h3)" news_detail_file="$(find "$OUTPUT_DIR/news" -mindepth 2 -maxdepth 2 -type f -name 'index.html' | head -n 1)" if [[ -z "${news_detail_file:-}" ]]; then echo "Missing generated news detail pages under $OUTPUT_DIR/news" >&2 exit 1 fi case_detail_file="$(find "$OUTPUT_DIR/cases" -mindepth 2 -maxdepth 2 -type f -name 'index.html' | head -n 1)" if [[ -z "${case_detail_file:-}" ]]; then echo "Missing generated case detail pages under $OUTPUT_DIR/cases" >&2 exit 1 fi check_file_contains "$news_detail_file" "news detail" "<(article|main|p|h1|h2)" check_file_contains "$case_detail_file" "case detail" "<(article|main|p|h1|h2)" echo "verify-generated-site.sh: PASS"