#!/bin/bash
# Migrate mdbook content to Grav multi-site structure

SRC_BASE="/home/charles/Projects/tsysstatic"
DEST_BASE="/home/charles/Projects/tsysstatic/staticsites.turnsys.com/content"

SITES="charters.turnsys.com
plan.afabn.org
plan.ap4ap.org
plan.ezeda.org
plan.ezpodstack.org
plan.hfnoc.net
plan.knownelement.com
plan.meetmorse.com
plan.merchantsofhope.org
plan.rackrental.net
plan.redwfo.com
plan.rwscp.net
plan.sidedoorgroup.org
plan.sol-calc.com
plan.suborbital-systems.com
plan.teamrental.net
plan.thecampustradingcompany.com
plan.thepeernet.com
plan.turnsys.com
plan.yourdreamnamehere.com
plan.startinglineproductions.com"

for FQDN in $SITES; do
    SRC="$SRC_BASE/$FQDN/src"
    DEST="$DEST_BASE/$FQDN"
    
    if [ ! -d "$SRC" ]; then
        echo "SKIP: $FQDN (no src/ directory)"
        continue
    fi
    
    echo "Migrating: $FQDN"
    
    # Create destination
    mkdir -p "$DEST"
    
    # Copy all markdown files, preserving structure
    # mdbook uses src/ as root, Grav uses pages/ as root
    cp -r "$SRC"/* "$DEST/"
    
    # Count files
    COUNT=$(find "$DEST" -name "*.md" | wc -l)
    echo "  -> $COUNT markdown files copied"
done

echo ""
echo "Migration complete. Content in: $DEST_BASE"
