# PowerShell script to update HTML files with the new navbar include

# Define the templates directory
$templatesDir = "c:\Users\LAPTOP MART\Desktop\software done\instastories.info\instastories.info\templates"

# List of files to update (excluding already updated ones)
$filesToUpdate = @(
    "MP3.html",
    "Photo.html",
    "StoriesDownload.html",
    "storyviewer.html",
    "contact.html",
    "privacy.html",
    "terms.html",
    "preview.html"
)

# Navbar include line
$navbarInclude = @"

  <!-- Include Reusable Navbar -->
  {% include 'navbar.html' %}
"@

foreach ($file in $filesToUpdate) {
    $filePath = Join-Path $templatesDir $file
    
    Write-Host "Processing $file..." -ForegroundColor Cyan
    
    if (Test-Path $filePath) {
        $content = Get-Content $filePath -Raw
        
        # Replace the body tag with body tag + navbar include
        # Pattern: <body> followed by whitespace and <!-- ========================= HERO ========================= -->
        $pattern = '(<body>\r?\n)(\s*<!-- ========================= HERO ========================= -->)'
        $replacement = "`$1$navbarInclude`r`n`$2"
        
        $newContent = $content -replace $pattern, $replacement
        
        # Write back to file
        Set-Content -Path $filePath -Value $newContent -NoNewline
        
        Write-Host "  ✓ Updated $file" -ForegroundColor Green
    } else {
        Write-Host "  ✗ File not found: $file" -ForegroundColor Red
    }
}

Write-Host "`nAll files processed!" -ForegroundColor Green
