$files = Get-ChildItem -Path "site\blog\articles" -Filter "*.html"
$images = @(
    "../../assets/blog-images/generated/content_marketing.png",
    "../../assets/blog-images/generated/ecommerce_growth.png",
    "../../assets/blog-images/generated/seo_dashboard.png",
    "../../assets/blog-images/generated/technical_seo.png"
)
$count = 0
foreach ($f in $files) {
    $html = Get-Content $f.FullName -Raw
    if ($html -match 'generate-image\.php') {
        $img = $images[$count % 4]
        # Replace the PHP url completely with the static PNG url
        $html = $html -replace '\.\./\.\./assets/blog-images/generate-image\.php\?[^"]*', $img
        Set-Content -Path $f.FullName -Value $html -Encoding UTF8
        $count++
    }
}
Write-Host "Fixed broken images in $count blog articles!"
