UNPKG

techveda-react-seo

Version:

Complete React SEO automation library with meta tags, robots.txt and sitemap generation

21 lines (18 loc) 796 B
// import fs from 'fs'; // import path from 'path'; // import { GenerateRobotsOptions } from '../types'; // export function generateRobotsFile(options: GenerateRobotsOptions): string { // const { // domain, // allowAll = true, // sitemapPath = '/sitemap.xml', // disallowPaths = [], // outputPath = path.join(process.cwd(), 'public', 'robots.txt') // } = options; // const robotsContent = allowAll // ? `User-agent: *\nAllow: /\n\nSitemap: https://${domain}${sitemapPath}\n` // : `User-agent: *\n${disallowPaths.map(p => `Disallow: ${p}`).join('\n')}\n\nSitemap: https://${domain}${sitemapPath}\n`; // fs.mkdirSync(path.dirname(outputPath), { recursive: true }); // fs.writeFileSync(outputPath, robotsContent.trim(), 'utf-8'); // return outputPath; // }