#!/bin/bash
# Script to handle symbolic links before commit
echo "Processing symbolic links for content..."

declare -A CONTENT_PATHS
# src/content directories
CONTENT_PATHS["posts"]="src/content/posts"
CONTENT_PATHS["projects"]="src/content/projects"
CONTENT_PATHS["configurations"]="src/content/configurations"
CONTENT_PATHS["external-posts"]="src/content/external-posts"
# public/blog directories
CONTENT_PATHS["configs"]="public/blog/configs"
CONTENT_PATHS["images"]="public/blog/images"
CONTENT_PATHS["infrastructure"]="public/blog/infrastructure"
CONTENT_PATHS["blog-posts"]="public/blog/posts"

for dir_name in "${!CONTENT_PATHS[@]}"; do
    dir_path="${CONTENT_PATHS[$dir_name]}"
    if [ -L "$dir_path" ]; then
        echo "Processing $dir_path..."
        target=$(readlink "$dir_path")
        rm "$dir_path"
        mkdir -p "$(dirname "$dir_path")"
        cp -r "$target" "$dir_path"
        git add "$dir_path"
        echo "Processed $dir_path -> $target"
    fi
done
