Версия 1.2.12 В SEO исправлено формирование канонического адреса страницы.

This commit is contained in:
anibilag 2025-11-10 11:41:32 +03:00
parent 593a620f29
commit b968cee091
3 changed files with 19 additions and 8 deletions

View File

@ -1,7 +1,7 @@
{
"name": "vite-react-typescript-starter",
"private": true,
"version": "1.2.11",
"version": "1.2.12",
"type": "module",
"scripts": {
"dev": "vite",

View File

@ -4,6 +4,8 @@ Allow: /article/
Disallow: /admin/
Disallow: /admin/*
Disallow: /login/
Disallow: /login/*
Disallow: /search
Disallow: /search*
Disallow: /bookmarks

View File

@ -1,11 +1,11 @@
import { Helmet } from 'react-helmet-async';
import { useLocation } from 'react-router-dom';
interface SEOProps {
title?: string;
description?: string;
keywords?: string[];
image?: string;
url?: string;
type?: string;
}
@ -14,10 +14,17 @@ export function SEO({
description = 'Последние новинки искусства, музыки, театра и культурных мероприятий Москвы и Санкт-Петербурга.',
keywords = ['культура', 'искусство', 'музыка', 'театр', 'кино'],
image = '/images/Logo-2.webp',
url = typeof window !== 'undefined' ? window.location.href : '',
type = 'website'
type = 'website',
}: SEOProps) {
const siteTitle = title.includes('Культура двух Столиц') ? title : `${title} | Культура двух Столиц`;
const location = useLocation();
const baseUrl = 'https://xn--80aefrggdxongffce6aw8g.xn--p1ai';
const cleanPath = location.pathname; // только путь без query и hash
const canonicalUrl = `${baseUrl}${cleanPath}`;
const siteTitle = title.includes('Культура двух Столиц')
? title
: `${title} | Культура двух Столиц`;
return (
<Helmet>
@ -30,7 +37,7 @@ export function SEO({
<meta property="og:title" content={siteTitle} />
<meta property="og:description" content={description} />
<meta property="og:image" content={image} />
<meta property="og:url" content={url} />
<meta property="og:url" content={canonicalUrl} />
<meta property="og:type" content={type} />
<meta property="og:site_name" content="Культура двух Столиц" />
@ -44,7 +51,9 @@ export function SEO({
<meta name="robots" content="index, follow" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charSet="UTF-8" />
<link rel="canonical" href={url} />
{/* Canonical */}
<link rel="canonical" href={canonicalUrl} />
</Helmet>
);
}
}