// 1. Create a sitemap.xml in public folder
// public/sitemap.xml
`<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
                            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
  <!-- Main page -->
  <url>
    <loc>https://www.youdexsof.ir/</loc>
    <lastmod>2023-12-15T12:00:00+00:00</lastmod>
    <priority>1.00</priority>
    <changefreq>weekly</changefreq>
  </url>



  <!-- Add other pages as needed -->
</urlset>`

// 2. Create a robots.txt in public folder
// public/robots.txt
`# Allow all web crawlers
User-agent: *
Allow: /

# Sitemap location
Sitemap: https://www.youdexsof.ir/sitemap.xml

# Prevent crawling of admin or private areas (if applicable)
User-agent: *
Disallow: /api/
Disallow: /admin/`

// 3. Create a site.webmanifest in public folder
// public/site.webmanifest
`{
  "name": "یوسف هاشم زاده | Yousof Hashemzadeh Portfolio",
  "short_name": "Yousof Portfolio",
  "icons": [
    {
      "src": "/favicons/android-chrome-192x192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "/favicons/android-chrome-512x512.png",
      "sizes": "512x512",
      "type": "image/png"
    }
  ],
  "theme_color": "#8B1E24",
  "background_color": "#141010",
  "display": "standalone",
  "start_url": "/"
}`

// 4. Create JSON-LD structured data for Projects (to be included in relevant pages)
// Example for a project page
`<script
  type="application/ld+json"
  dangerouslySetInnerHTML={{
    __html: JSON.stringify({
      "@context": "https://schema.org",
      "@type": "SoftwareApplication",
      "name": "Project Name",
      "applicationCategory": "MobileApplication",
      "operatingSystem": "Android, iOS",
      "offers": {
        "@type": "Offer",
        "price": "0",
        "priceCurrency": "USD"
      },
      "creator": {
        "@type": "Person",
        "name": "یوسف هاشم زاده",
        "alternateName": "Yousof Hashemzadeh",
        "url": "https://www.youdexsof.ir"
      },
      "description": "Description of the project and its features.",
      "image": "https://www.youdexsof.ir/images/projects/project-image.jpg",
      "datePublished": "2023-06-15",
      "softwareVersion": "1.0.0"
    })
  }}
/>`

// 5. Create a Next.js dynamic sitemap generator (optional for more complex sites)
// pages/sitemap.xml.js
`import { projects } from '../data/projects';

function generateSiteMap(baseUrl, projects) {
  return `<?xml version="1.0" encoding="UTF-8"?>
   <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
     <!-- Main pages -->
     <url>
       <loc>${baseUrl}</loc>
       <lastmod>${new Date().toISOString()}</lastmod>
       <changefreq>daily</changefreq>
       <priority>1.0</priority>
     </url>
     <url>
       <loc>${baseUrl}/en</loc>
       <lastmod>${new Date().toISOString()}</lastmod>
       <changefreq>daily</changefreq>
       <priority>0.9</priority>
     </url>
     <!-- Projects pages -->
     ${projects
       .map((project) => {
         return `
       <url>
           <loc>${baseUrl}/projects/${project.slug}</loc>
           <lastmod>${new Date(project.updatedAt || project.createdAt).toISOString()}</lastmod>
           <changefreq>weekly</changefreq>
           <priority>0.8</priority>
       </url>
     `;
       })
       .join('')}
   </urlset>
 `;
}

function SiteMap() {
  // getServerSideProps will do the heavy lifting
}

export async function getServerSideProps({ res }) {
  // Configure domain with your actual domain
  const baseUrl = 'https://www.youdexsof.ir';

  // Generate XML sitemap
  const sitemap = generateSiteMap(baseUrl, projects);

  res.setHeader('Content-Type', 'text/xml');
  res.write(sitemap);
  res.end();

  return {
    props: {},
  };
}

export default SiteMap;`

// 6. Open Graph Image Template (create a template for dynamic OG images)
// pages/api/og.js (requires @vercel/og)
`import { ImageResponse } from '@vercel/og';

export const config = {
  runtime: 'edge',
};

export default async function handler(req) {
  try {
    const { searchParams } = new URL(req.url);

    // Get query params
    const title = searchParams.get('title') || 'یوسف هاشم زاده | توسعه دهنده فلاتر';
    const description = searchParams.get('description') || 'Flutter Developer | Python Backend';

    return new ImageResponse(
      (
        <div
          style={{
            height: '100%',
            width: '100%',
            display: 'flex',
            flexDirection: 'column',
            alignItems: 'center',
            justifyContent: 'center',
            backgroundColor: '#141010',
            backgroundImage: 'linear-gradient(to bottom right, #8B1E24 0%, #141010 100%)',
            padding: '40px',
          }}
        >
          <div
            style={{
              display: 'flex',
              fontSize: 60,
              fontWeight: 'bold',
              color: 'white',
              marginBottom: '20px',
              textAlign: 'center',
              direction: 'rtl',
            }}
          >
            {title}
          </div>
          <div
            style={{
              display: 'flex',
              fontSize: 30,
              color: 'rgba(255, 255, 255, 0.8)',
              textAlign: 'center',
              direction: 'rtl',
            }}
          >
            {description}
          </div>
          <div
            style={{
              position: 'absolute',
              bottom: 40,
              display: 'flex',
              alignItems: 'center',
              justifyContent: 'center'
            }}
          >
            {/* Add your logo here */}
            <div style={{ fontSize: 24, color: 'white', marginLeft: 8 }}>
              © 2023 Yousof Hashemzadeh
            </div>
          </div>
        </div>
      ),
      {
        width: 1200,
        height: 630,
      },
    );
  } catch (e) {
    return new Response(`Failed to generate the image`, {
      status: 500,
    });
  }
}
`
