feat: add dynamic sitemap and robots crawler config

This commit is contained in:
AyrisAI
2026-07-12 20:23:47 +03:00
parent cbc59222c2
commit 862544b5a1
2 changed files with 100 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import type { MetadataRoute } from 'next';
const PROTECTED = ['/admin/', '/api/'];
export default function robots(): MetadataRoute.Robots {
return {
rules: [
{
userAgent: '*',
allow: '/',
disallow: PROTECTED,
},
// AI arama / citation botları
{ userAgent: 'OAI-SearchBot', allow: '/', disallow: PROTECTED },
{ userAgent: 'ChatGPT-User', allow: '/', disallow: PROTECTED },
{ userAgent: 'PerplexityBot', allow: '/', disallow: PROTECTED },
{ userAgent: 'Perplexity-User', allow: '/', disallow: PROTECTED },
{ userAgent: 'Claude-SearchBot', allow: '/', disallow: PROTECTED },
{ userAgent: 'Claude-User', allow: '/', disallow: PROTECTED },
// Training crawler'ları engelle
{ userAgent: 'GPTBot', disallow: '/' },
{ userAgent: 'ClaudeBot', disallow: '/' },
{ userAgent: 'Google-Extended', disallow: '/' },
{ userAgent: 'CCBot', disallow: '/' },
{ userAgent: 'Bytespider', disallow: '/' }, // ByteDance/TikTok
{ userAgent: 'Meta-ExternalAgent', disallow: '/' }, // Meta training
],
sitemap: 'https://marmarislocal.com/sitemap.xml',
};
}
+70
View File
@@ -0,0 +1,70 @@
import { MetadataRoute } from 'next'
import { mockDb } from '@/lib/mockDb'
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const baseUrl = 'https://marmarislocal.com'
const locales = ['tr', 'en', 'ru']
// Static routes
const staticRoutes = [
'',
'/apartlar',
'/restoranlar',
'/isletmeler',
'/isletme-ekle',
'/iletisim',
'/hakkinda'
]
const sitemapEntries: MetadataRoute.Sitemap = []
// 1. Generate static routes for each locale
for (const route of staticRoutes) {
for (const locale of locales) {
sitemapEntries.push({
url: `${baseUrl}/${locale}${route}`,
lastModified: new Date(),
changeFrequency: 'weekly',
priority: route === '' ? 1.0 : 0.8,
})
}
}
// 2. Dynamic listing routes
try {
const listings = await mockDb.getListings()
for (const listing of listings) {
// Find the category slug dynamically
const catSlug = listing.category?.slug || 'isletmeler'
for (const locale of locales) {
sitemapEntries.push({
url: `${baseUrl}/${locale}/${catSlug}/${listing.slug}`,
lastModified: listing.updatedAt || new Date(),
changeFrequency: 'weekly',
priority: 0.6,
})
}
}
} catch (e) {
console.error('Sitemap listings fetch error:', e)
}
// 3. Dynamic neighborhood routes
try {
const neighborhoods = await mockDb.getNeighborhoods()
for (const neighborhood of neighborhoods) {
for (const locale of locales) {
sitemapEntries.push({
url: `${baseUrl}/${locale}/mahalle/${neighborhood.slug}`,
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.4,
})
}
}
} catch (e) {
console.error('Sitemap neighborhoods fetch error:', e)
}
return sitemapEntries
}