[build]
  command = "npm run build"
  publish = ".next"

[build.environment]
  NODE_VERSION = "18.17.0"
  NPM_VERSION = "9.6.7"
  NODE_ENV = "production"
  NETLIFY = "true"

# تعليمات النشر واستخدام المتغيرات البيئية
[build.processing]
  skip_processing = false

[build.processing.css]
  bundle = true
  minify = true

[build.processing.js]
  bundle = true
  minify = true

[build.processing.html]
  pretty_urls = true

[build.processing.images]
  compress = true

# التوجيهات والرؤوس
[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200
  force = false
  conditions = {Language = ["ar"]}

# تمكين الضغط لتحسين الأداء
[[headers]]
  for = "/*"
  [headers.values]
    X-Frame-Options = "DENY"
    X-XSS-Protection = "1; mode=block"
    X-Content-Type-Options = "nosniff"
    Content-Security-Policy = "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.google-analytics.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: https://i.postimg.cc; font-src 'self' data: https://fonts.gstatic.com; connect-src 'self' https://www.google-analytics.com"
    Referrer-Policy = "strict-origin-when-cross-origin"
    Strict-Transport-Security = "max-age=31536000; includeSubDomains; preload"
    Cache-Control = "public, max-age=31536000"

# تمكين الضغط للصور والأصول الثابتة الأخرى
[[headers]]
  for = "*.jpg"
  [headers.values]
    Cache-Control = "public, max-age=31536000"

[[headers]]
  for = "*.jpeg"
  [headers.values]
    Cache-Control = "public, max-age=31536000"

[[headers]]
  for = "*.png"
  [headers.values]
    Cache-Control = "public, max-age=31536000"

[[headers]]
  for = "*.gif"
  [headers.values]
    Cache-Control = "public, max-age=31536000"

[[headers]]
  for = "*.svg"
  [headers.values]
    Cache-Control = "public, max-age=31536000"

[[headers]]
  for = "*.webp"
  [headers.values]
    Cache-Control = "public, max-age=31536000"

[[headers]]
  for = "*.js"
  [headers.values]
    Cache-Control = "public, max-age=31536000"

[[headers]]
  for = "*.css"
  [headers.values]
    Cache-Control = "public, max-age=31536000"

# التوجيهات المخصصة للـ SEO
[[redirects]]
  from = "/rss"
  to = "/api/rss"
  status = 200
  force = false

[[redirects]]
  from = "/feed"
  to = "/api/rss"
  status = 200
  force = false

[[redirects]]
  from = "/contact-us"
  to = "/contact"
  status = 301
  force = true

# إعادة توجيه robots.txt و sitemap.xml
[[redirects]]
  from = "/robots.txt"
  to = "/api/robots"
  status = 200
  force = true

[[redirects]]
  from = "/sitemap.xml"
  to = "/api/sitemap"
  status = 200
  force = true 