Skip to content

Commit c7be9cc

Browse files
committed
modern support to robot.txt
1 parent 068b0d9 commit c7be9cc

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

public/robots.staging.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

public/robots.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/app/layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import { Container } from '@mui/material';
1414
export const metadata = {
1515
title: 'Mobility Database',
1616
description: 'Mobility Database',
17+
robots: process.env.VERCEL_ENV === 'production'
18+
? 'index, follow'
19+
: 'noindex, nofollow',
1720
};
1821

1922
const mulish = Mulish({

src/app/robots.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { type MetadataRoute } from 'next';
2+
3+
export default function robots(): MetadataRoute.Robots {
4+
const isProd = process.env.VERCEL_ENV === 'production';
5+
6+
return {
7+
rules: [
8+
{
9+
userAgent: '*',
10+
allow: isProd ? '/' : '',
11+
disallow: isProd ? '' : '/',
12+
},
13+
],
14+
sitemap: isProd ? 'https://mobilitydatabase.org/sitemap.xml' : undefined,
15+
};
16+
}

0 commit comments

Comments
 (0)