From 5e60ac8dd4d89814022e18caa52bc7328ba69bae Mon Sep 17 00:00:00 2001 From: Samandar Turgunboyev Date: Thu, 26 Feb 2026 13:10:48 +0500 Subject: [PATCH] fix --- src/app/[locale]/about/AboutSEO.tsx | 38 +++++++++++++ src/app/[locale]/about/page.tsx | 84 ++++++----------------------- 2 files changed, 54 insertions(+), 68 deletions(-) create mode 100644 src/app/[locale]/about/AboutSEO.tsx diff --git a/src/app/[locale]/about/AboutSEO.tsx b/src/app/[locale]/about/AboutSEO.tsx new file mode 100644 index 0000000..3a27e87 --- /dev/null +++ b/src/app/[locale]/about/AboutSEO.tsx @@ -0,0 +1,38 @@ +'use client'; + +import { partner_api } from '@/features/about/lib/api'; +import { useQuery } from '@tanstack/react-query'; +import { useParams } from 'next/navigation'; +import { useEffect } from 'react'; + +export default function AboutSEO() { + const { locale } = useParams(); + + const { data } = useQuery({ + queryKey: ['aboutData'], + queryFn: async () => (await partner_api.getAbout()).data, + }); + + useEffect(() => { + if (!data) return; + const banner = data.banner; + const title = + locale === 'uz' + ? banner.title_uz + : locale === 'ru' + ? banner.title_ru + : banner.title_en; + const description = + locale === 'uz' + ? banner.description_uz + : locale === 'ru' + ? banner.description_ru + : banner.description_en; + + document.title = title || 'Gastro Market'; + const descMeta = document.querySelector('meta[name="description"]'); + if (descMeta) descMeta.setAttribute('content', description || ''); + }, [data, locale]); + + return null; +} diff --git a/src/app/[locale]/about/page.tsx b/src/app/[locale]/about/page.tsx index f4425a4..d3467c3 100644 --- a/src/app/[locale]/about/page.tsx +++ b/src/app/[locale]/about/page.tsx @@ -1,32 +1,23 @@ // app/[locale]/about/page.tsx -'use client'; - import { partner_api } from '@/features/about/lib/api'; import { AboutContent } from '@/features/about/ui/AboutContent'; import { AboutHero } from '@/features/about/ui/AboutHero'; import { PartnershipForm } from '@/features/about/ui/AboutPage'; import { BASE_URL } from '@/shared/config/api/URLs'; -import { useQuery } from '@tanstack/react-query'; import { Metadata } from 'next'; -import { useParams } from 'next/navigation'; -import { useEffect } from 'react'; +import AboutSEO from './AboutSEO'; -interface Props { - params: { locale: 'uz' | 'ru' | 'en' }; -} - -// Har requestda server-side yangilanishi export const revalidate = 0; -// Helper: full image url function getImageUrl(image?: string | null): string { - if (!image || image.length === 0) return '/placeholder.svg'; + if (!image) return '/placeholder.svg'; return image.includes(BASE_URL) ? image : BASE_URL + image; } -// ==================== -// Server-side Metadata -// ==================== +interface Props { + params: { locale: 'uz' | 'ru' }; +} + export async function generateMetadata({ params }: Props): Promise { const { locale } = params; @@ -48,33 +39,31 @@ export async function generateMetadata({ params }: Props): Promise { ? banner.description_ru : banner.description_en; - const imageUrl = getImageUrl(banner?.image); - return { title: title || 'Gastro Market', description: description || 'Gastro Market mahsulotlarini kashf eting', openGraph: { - title: title || 'Gastro Market', - description: description || 'Gastro Market mahsulotlarini kashf eting', + title, + description, type: 'website', images: [ { - url: imageUrl, + url: getImageUrl(banner.image), width: 1200, height: 630, - alt: title || 'Gastro Market', + alt: title, }, ], }, twitter: { card: 'summary_large_image', - title: title || 'Gastro Market', - description: description || 'Gastro Market mahsulotlarini kashf eting', - images: [imageUrl], + title, + description, + images: [getImageUrl(banner.image)], }, }; - } catch (error) { - console.error('About metadata error:', error); + } catch (err) { + console.error('About metadata error:', err); return { title: 'Gastro Market', description: 'Gastro Market mahsulotlarini kashf eting', @@ -82,51 +71,10 @@ export async function generateMetadata({ params }: Props): Promise { } } -// ==================== -// Client-side SEO Update -// ==================== -function AboutSEO() { - const { locale } = useParams(); - - const { data } = useQuery({ - queryKey: ['aboutData'], - queryFn: async () => (await partner_api.getAbout()).data, - }); - - useEffect(() => { - if (!data) return; - const banner = data.banner; - const title = - locale === 'uz' - ? banner.title_uz - : locale === 'ru' - ? banner.title_ru - : banner.title_en; - const description = - locale === 'uz' - ? banner.description_uz - : locale === 'ru' - ? banner.description_ru - : banner.description_en; - - document.title = title || 'Gastro Market'; - const descMeta = document.querySelector('meta[name="description"]'); - if (descMeta) descMeta.setAttribute('content', description || ''); - }, [data, locale]); - - return null; -} - -// ==================== -// Page Component -// ==================== const AboutPage = async () => { return (
- {/* Client-side SEO yangilash */} - - - {/* Hero + Content + Form */} + {/* Client-side SEO */}