Complete SEO overhaul
This commit is contained in:
28
scripts/generate-robots.ts
Normal file
28
scripts/generate-robots.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const BASE_URL = process.env.BASE_URL || 'https://bayareait.services';
|
||||
|
||||
const generateRobots = () => {
|
||||
const content = `User-agent: *
|
||||
Allow: /
|
||||
Disallow: /admin
|
||||
Disallow: /api
|
||||
|
||||
Sitemap: ${BASE_URL}/sitemap.xml
|
||||
`;
|
||||
return content;
|
||||
};
|
||||
|
||||
const robots = generateRobots();
|
||||
const outputPath = path.resolve(process.cwd(), 'public/robots.txt');
|
||||
|
||||
// Ensure public directory exists
|
||||
const publicDir = path.dirname(outputPath);
|
||||
if (!fs.existsSync(publicDir)) {
|
||||
fs.mkdirSync(publicDir, { recursive: true });
|
||||
}
|
||||
|
||||
fs.writeFileSync(outputPath, robots);
|
||||
console.log(`✅ Robots.txt generated at ${outputPath}`);
|
||||
Reference in New Issue
Block a user