From a67a4438ad8b9c72c2ae416187c5522c59a74e4f Mon Sep 17 00:00:00 2001 From: Bivekich Date: Sun, 6 Jul 2025 20:23:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BC=D0=B5=D1=82=D0=B0-=D1=82=D0=B5=D0=B3?= =?UTF-8?q?=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D1=81=D1=82=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=86=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=B8=20=D0=BE=D0=BF=D0=BB=D0=B0=D1=82=D1=8B,=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D1=8B=20=D1=81=D1=82=D0=B0=D1=82?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D0=B5=20=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D0=B0-=D1=82=D0=B5=D0=B3=D0=B8=20=D0=BD=D0=B0=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=20MetaTags=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B4=D0=B8=D0=BD=D0=B0=D0=BC=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D1=81=D0=BA=D0=BE=D0=B3=D0=BE=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= =?UTF-8?q?.=20=D0=AD=D1=82=D0=BE=20=D1=83=D0=BB=D1=83=D1=87=D1=88=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=20SEO=20=D0=B8=20=D1=83=D0=BF=D1=80=D0=BE=D1=89?= =?UTF-8?q?=D0=B0=D0=B5=D1=82=20=D1=83=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B5=D1=82=D0=B0-=D1=82=D0=B5?= =?UTF-8?q?=D0=B3=D0=B0=D0=BC=D0=B8=20=D0=BD=D0=B0=20=D1=8D=D1=82=D0=B8?= =?UTF-8?q?=D1=85=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B0=D1=85?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/robots.txt.ts | 36 +++++++++++++++++ src/pages/sitemap.xml.ts | 85 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 src/pages/robots.txt.ts create mode 100644 src/pages/sitemap.xml.ts 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