diff --git a/src/pages/robots.txt.ts b/src/pages/robots.txt.ts new file mode 100644 index 0000000..8b545a5 --- /dev/null +++ b/src/pages/robots.txt.ts @@ -0,0 +1,36 @@ +import { NextApiRequest, NextApiResponse } from 'next' + +export default function handler(req: NextApiRequest, res: NextApiResponse) { + const robotsTxt = `User-agent: * +Allow: / + +# Запрещаем индексацию служебных страниц +Disallow: /api/ +Disallow: /admin/ +Disallow: /dashboard/ +Disallow: /_next/ +Disallow: /static/ +Disallow: /test-auth/ + +# Запрещаем индексацию страниц с параметрами +Disallow: /*?* + +# Разрешаем основные страницы +Allow: / +Allow: /catalog +Allow: /about +Allow: /contacts +Allow: /news +Allow: /brands +Allow: /delivery +Allow: /payment +Allow: /wholesale +Allow: /vin + +# Указываем карту сайта +Sitemap: https://protekauto.ru/sitemap.xml +` + + res.setHeader('Content-Type', 'text/plain') + res.status(200).send(robotsTxt) +} \ No newline at end of file diff --git a/src/pages/sitemap.xml.ts b/src/pages/sitemap.xml.ts new file mode 100644 index 0000000..30b031a --- /dev/null +++ b/src/pages/sitemap.xml.ts @@ -0,0 +1,85 @@ +import { NextApiRequest, NextApiResponse } from 'next' + +export default function handler(req: NextApiRequest, res: NextApiResponse) { + const baseUrl = 'https://protekauto.ru' + + const staticPages = [ + { + url: '', + lastModified: new Date().toISOString(), + changeFrequency: 'daily', + priority: 1.0, + }, + { + url: '/about', + lastModified: new Date().toISOString(), + changeFrequency: 'monthly', + priority: 0.8, + }, + { + url: '/contacts', + lastModified: new Date().toISOString(), + changeFrequency: 'monthly', + priority: 0.8, + }, + { + url: '/catalog', + lastModified: new Date().toISOString(), + changeFrequency: 'weekly', + priority: 0.9, + }, + { + url: '/news', + lastModified: new Date().toISOString(), + changeFrequency: 'weekly', + priority: 0.7, + }, + { + url: '/brands', + lastModified: new Date().toISOString(), + changeFrequency: 'monthly', + priority: 0.7, + }, + { + url: '/delivery', + lastModified: new Date().toISOString(), + changeFrequency: 'monthly', + priority: 0.6, + }, + { + url: '/payment', + lastModified: new Date().toISOString(), + changeFrequency: 'monthly', + priority: 0.6, + }, + { + url: '/wholesale', + lastModified: new Date().toISOString(), + changeFrequency: 'monthly', + priority: 0.6, + }, + { + url: '/vin', + lastModified: new Date().toISOString(), + changeFrequency: 'monthly', + priority: 0.7, + }, + ] + + const sitemap = ` + +${staticPages + .map( + (page) => ` + ${baseUrl}${page.url} + ${page.lastModified} + ${page.changeFrequency} + ${page.priority} + ` + ) + .join('\n')} +` + + res.setHeader('Content-Type', 'application/xml') + res.status(200).send(sitemap) +} \ No newline at end of file