UNPKG

@dijitrak/react-nextjs-seo-plugin

Version:

A modern, user-friendly SEO plugin for React and Next.js with multilingual support and comprehensive optimization tools

56 lines (47 loc) 1.49 kB
/** * Robots.txt oluşturma işlemleri */ /** * Robots.txt oluşturur * @param {boolean} allowIndexing İndekslemeye izin verilecek mi * @param {string} customRules Özel kurallar * @param {string} siteUrl Sitemap URL'si için site adresi * @returns {string} Robots.txt içeriği */ export function generateRobotsTxt( allowIndexing = true, customRules = '', siteUrl = '' ) { let content = ''; // Varsayılan kullanıcı ajanı (tüm robotlar) content += 'User-agent: *\n'; // Eğer indeksleme kapalıysa, tüm site için disallow ekle if (!allowIndexing) { content += 'Disallow: /\n'; } else { content += 'Allow: /\n'; // Genellikle indekslemek istemediğimiz alanlar content += 'Disallow: /admin/\n'; content += 'Disallow: /wp-admin/\n'; content += 'Disallow: /wp-login.php\n'; content += 'Disallow: /login\n'; content += 'Disallow: /api/\n'; content += 'Disallow: /cart\n'; content += 'Disallow: /checkout\n'; content += 'Disallow: /account\n'; content += 'Disallow: /search\n'; content += 'Disallow: /*?*\n'; // Query parametreleri olan sayfalar } content += '\n'; // Özel kurallar ekle if (customRules && customRules.trim() !== '') { content += `${customRules.trim()}\n\n`; } // Sitemap.xml bağlantısı if (siteUrl) { const baseUrl = siteUrl.endsWith('/') ? siteUrl.slice(0, -1) : siteUrl; content += `Sitemap: ${baseUrl}/sitemap.xml\n`; } return content; }