diff --git a/src/app/about/page.tsx b/src/app/about/page.tsx index ef1fd298..67705250 100644 --- a/src/app/about/page.tsx +++ b/src/app/about/page.tsx @@ -5,7 +5,7 @@ import Heading from '@/components/Heading/Heading' import AboutPage from '@/components/AboutPage/AboutPage' export const metadata: Metadata = { - title: 'О нас | Иконописная Артель', + title: 'О нас', description: 'Наши мастера создают рукописные иконы в древней технологии яичной темперой, следуя каноническим образцам.', openGraph: { @@ -13,6 +13,9 @@ export const metadata: Metadata = { description: 'Наши мастера создают рукописные иконы в древней технологии яичной темперой, следуя каноническим образцам.', }, + alternates: { + canonical: '/about', + }, } const breadcrumbsList: BreadcrumbItem[] = [ diff --git a/src/app/categories/[categories-detail]/page.tsx b/src/app/categories/[categories-detail]/page.tsx index 99fd44ba..20839fea 100644 --- a/src/app/categories/[categories-detail]/page.tsx +++ b/src/app/categories/[categories-detail]/page.tsx @@ -23,12 +23,12 @@ export async function generateMetadata({ params }: PageProps): Promise if (!category) { return { - title: 'Категория не найдена | Иконописная Артель', + title: 'Категория не найдена', } } return { - title: `${category.title} | Иконописная Артель`, + title: category.title, description: category.description ? category.description.replace(/<[^>]*>/g, '').slice(0, 160) : '', @@ -47,12 +47,12 @@ export async function generateMetadata({ params }: PageProps): Promise : [], }, alternates: { - canonical: `${process.env.SITE_URL || process.env.NEXT_PUBLIC_SITE_URL}/categories/${category.slug || category._id}`, + canonical: `/categories/${category.slug || category._id}`, }, } } catch { return { - title: 'Категория не найдена | Иконописная Артель', + title: 'Категория не найдена', } } } diff --git a/src/app/categories/page.tsx b/src/app/categories/page.tsx index e70d188a..80981b94 100644 --- a/src/app/categories/page.tsx +++ b/src/app/categories/page.tsx @@ -8,12 +8,15 @@ import { fetchCollection, fetchCollectionCount, getImageUrl } from '@/lib/api-cl import { ITEMS_PER_PAGE } from '@/const/const' export const metadata: Metadata = { - title: 'Категории икон | Иконописная Артель', + title: 'Категории икон', description: 'Все категории икон, создаваемых в нашей иконописной мастерской', openGraph: { title: 'Категории икон | Иконописная Артель', description: 'Все категории икон, создаваемых в нашей иконописной мастерской', }, + alternates: { + canonical: '/categories', + }, } const breadcrumbsList: BreadcrumbItem[] = [ diff --git a/src/app/contacts/page.tsx b/src/app/contacts/page.tsx index 8a060c62..14f21e5f 100644 --- a/src/app/contacts/page.tsx +++ b/src/app/contacts/page.tsx @@ -5,7 +5,7 @@ import Heading from '@/components/Heading/Heading' import ContactsPage from '@/components/ContactsPage/ContactsPage' export const metadata: Metadata = { - title: 'Контакты | Иконописная Артель', + title: 'Контакты', description: 'Контактная информация Иконописной Артели. Адрес мастерской, телефон, email для заказа икон. Свяжитесь с нами для консультации.', openGraph: { @@ -13,6 +13,9 @@ export const metadata: Metadata = { description: 'Контактная информация Иконописной Артели. Адрес мастерской, телефон, email для заказа икон.', }, + alternates: { + canonical: '/contacts', + }, } const breadcrumbsList: BreadcrumbItem[] = [ diff --git a/src/app/gallery/[...slug]/page.tsx b/src/app/gallery/[...slug]/page.tsx index c70c5f35..7c97505b 100644 --- a/src/app/gallery/[...slug]/page.tsx +++ b/src/app/gallery/[...slug]/page.tsx @@ -4,7 +4,7 @@ import { notFound } from 'next/navigation' import { BreadcrumbItem, GalleryTreeItem } from '@/types/types' import Heading from '@/components/Heading/Heading' import GalleryPageClient from '@/components/GalleryPage/GalleryPageClient' -import { fetchTree } from '@/lib/api-client' +import { fetchTree, getImageUrl } from '@/lib/api-client' import { prepareGalleryItems, findGalleryItemBySlug, @@ -29,12 +29,35 @@ export async function generateMetadata({ params }: PageProps): Promise } const currentItem = findGalleryItemBySlug(galleryData, lastSlug) + const canonicalPath = `/gallery/${slug.join('/')}` + + let ogImage: string | undefined + if (currentItem) { + const firstImageChild = currentItem._children?.find( + (child) => child.image && child.image._id, + ) + if (firstImageChild?.image?._id) { + ogImage = getImageUrl(firstImageChild.image._id, 1200, 630, { mime: 'jpeg' }) + } + } return { title: currentItem ? `${currentItem.title} | Галерея` : 'Галерея | Иконописная Артель', description: currentItem?.title ? `Фотогалерея: ${currentItem.title}. Иконописная Артель.` : 'Фотогалерея Иконописной Артели. Работы мастеров и события из жизни артели.', + openGraph: { + title: currentItem ? `${currentItem.title} | Галерея` : 'Галерея | Иконописная Артель', + description: currentItem?.title + ? `Фотогалерея: ${currentItem.title}. Иконописная Артель.` + : 'Фотогалерея Иконописной Артели. Работы мастеров и события из жизни артели.', + ...(ogImage && { + images: [{ url: ogImage, width: 1200, height: 630, alt: currentItem?.title || 'Галерея' }], + }), + }, + alternates: { + canonical: canonicalPath, + }, } } diff --git a/src/app/gallery/page.tsx b/src/app/gallery/page.tsx index 3b1b495e..e9d4e579 100644 --- a/src/app/gallery/page.tsx +++ b/src/app/gallery/page.tsx @@ -7,7 +7,7 @@ import { fetchTree } from '@/lib/api-client' import { prepareGalleryItems } from '@/functions/gallery' export const metadata: Metadata = { - title: 'Галерея | Иконописная Артель', + title: 'Галерея', description: 'Фотогалерея Иконописной Артели. Фотографии работ наших мастеров, процесса создания икон, мастерской и событий из жизни артели.', openGraph: { @@ -15,6 +15,9 @@ export const metadata: Metadata = { description: 'Фотогалерея Иконописной Артели. Фотографии работ наших мастеров, процесса создания икон, мастерской и событий.', }, + alternates: { + canonical: '/gallery', + }, } const breadcrumbsList: BreadcrumbItem[] = [ diff --git a/src/app/in-stock/[in-stock-detail]/page.tsx b/src/app/in-stock/[in-stock-detail]/page.tsx index 9c3c312c..18e5378e 100644 --- a/src/app/in-stock/[in-stock-detail]/page.tsx +++ b/src/app/in-stock/[in-stock-detail]/page.tsx @@ -5,6 +5,7 @@ import { BreadcrumbItem, MasterFromServer, SlideItem, WorkFromServer } from '@/t import Heading from '@/components/Heading/Heading' import Detail from '@/components/Detail/Detail' import Master from '@/components/Master/Master' +import ProductJsonLd from '@/components/JsonLd/ProductJsonLd' import { fetchCollectionItem, getImageUrl } from '@/lib/api-client' type PageProps = { @@ -21,14 +22,14 @@ export async function generateMetadata({ params }: PageProps): Promise if (!work) { return { - title: 'Работа не найдена | Иконописная Артель', + title: 'Работа не найдена', } } const description = work.description ? work.description.replace(/<[^>]*>/g, '').slice(0, 160) : '' return { - title: `${work.title} | Иконописная Артель`, + title: work.title, description, openGraph: { title: work.title, @@ -38,7 +39,7 @@ export async function generateMetadata({ params }: PageProps): Promise : [], }, alternates: { - canonical: `${process.env.SITE_URL || process.env.NEXT_PUBLIC_SITE_URL}/in-stock/${work.slug || work._id}`, + canonical: `/in-stock/${work.slug || work._id}`, }, } } @@ -83,35 +84,20 @@ export default async function Page({ params }: PageProps): Promise ? await fetchCollectionItem('masters', work.master?._id) : null - const productSchema = { - '@context': 'https://schema.org', - '@type': 'Product', - name: work.title, - description: work.description - ? work.description.replace(/<[^>]*>/g, '').slice(0, 160) - : work.title, - image: work.image - ? getImageUrl(work.image._id, 1200, 630, { mode: 'thumbnail', mime: 'jpeg' }) - : undefined, - brand: { - '@type': 'Organization', - name: 'Иконописная Артель', - }, - offers: { - '@type': 'Offer', - availability: 'https://schema.org/InStock', - url: `${process.env.SITE_URL || process.env.NEXT_PUBLIC_SITE_URL}/in-stock/${work.slug || work._id}`, - ...(work.price && !isNaN(parseFloat(work.price)) - ? { price: parseFloat(work.price), priceCurrency: 'RUB' } - : {}), - }, - } - return ( <> -