import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
  // The VPS CPU (QEMU virtual, no x86-64-v2) cannot run sharp >= 0.33, which
  // Next 16's image optimizer requires — with sharp installed it 500s, without
  // it it serves originals through /_next/image (uncacheable by Cloudflare).
  // Instead, source images are pre-sized WebP (960px, 2x the 480px render
  // size) served directly from /public, which Cloudflare edge-caches.
  images: {
    unoptimized: true,
  },

  async redirects() {
    // 301s for URLs from the old WordPress/legacy sites that still linger in
    // Google's index. All of these 404 today (verified 2026-06-07 against the
    // live site + Wayback Machine archive). Redirecting them to the homepage
    // passes link equity and makes Google drop the stale entries faster.
    //
    // SAFETY: never add rules for the live pages —
    // /, /privacy-policy, /terms-conditions, /refund-policy
    return [
      // WordPress remnants
      { source: '/wp-login.php', destination: '/', statusCode: 301 },
      { source: '/wp-admin', destination: '/', statusCode: 301 },
      { source: '/wp-admin/:path*', destination: '/', statusCode: 301 },
      { source: '/xmlrpc.php', destination: '/', statusCode: 301 },
      // Old WordPress sitemaps (Google may still poll these)
      { source: '/wp-sitemap.xml', destination: '/sitemap.xml', statusCode: 301 },
      { source: '/sitemap_index.xml', destination: '/sitemap.xml', statusCode: 301 },
      { source: '/page-sitemap.xml', destination: '/sitemap.xml', statusCode: 301 },
      // Old site pages that no longer exist
      { source: '/contact', destination: '/', statusCode: 301 },
      { source: '/advertise', destination: '/', statusCode: 301 },
      // Ancient blog-era structure (pre-2024 site)
      { source: '/archives', destination: '/', statusCode: 301 },
      { source: '/archives/:path*', destination: '/', statusCode: 301 },
      { source: '/category/:path*', destination: '/', statusCode: 301 },
    ];
  },
};

export default nextConfig;
