Skip to content

Commit

Permalink
⚡ perf: Update robots rule (#4141)
Browse files Browse the repository at this point in the history
Co-authored-by: canisminor1990 <i@canisminor.cc>
  • Loading branch information
lobehubbot and canisminor1990 committed Sep 26, 2024
1 parent 6a12d45 commit 03017dd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
5 changes: 5 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ const nextConfig = {
permanent: true,
source: '/sitemap.xml',
},
{
destination: '/sitemap-index.xml',
permanent: true,
source: '/sitemap-0.xml',
},
{
destination: '/manifest.webmanifest',
permanent: true,
Expand Down
33 changes: 26 additions & 7 deletions src/app/robots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,33 @@ import { MetadataRoute } from 'next';
import { sitemapModule } from '@/server/sitemap';
import { getCanonicalUrl } from '@/server/utils/url';

export default function robots(): MetadataRoute.Robots {
const robots = (): MetadataRoute.Robots => {
return {
host: getCanonicalUrl(),
rules: {
allow: ['/'],
disallow: ['/api/*'],
userAgent: '*',
},
rules: [
{
allow: ['/discover/*'],
disallow: ['/discover/search/*'],
userAgent: ['Facebot', 'facebookexternalhit'],
},
{
allow: ['/discover/*'],
disallow: ['/discover/search/*'],
userAgent: 'LinkedInBot',
},
{
allow: ['/discover/*'],
disallow: ['/discover/search/*'],
userAgent: 'Twitterbot',
},
{
allow: ['/'],
disallow: ['/api/*', '/login', '/signup', '/files', '/repos/*', '/discover/search/*'],
userAgent: '*',
},
],
sitemap: sitemapModule.getRobots(),
};
}
};

export default robots;

0 comments on commit 03017dd

Please sign in to comment.