feat(seo): unify dynamic SEO metadata and title formatting across backend, admin and application
Deploy Canina / deploy (push) Successful in 1m44s
Deploy Canina / deploy (push) Successful in 1m44s
This commit is contained in:
1 parent
df634fdbf5
commit
70d58e7086
39 files changed
+133392
-7694
No files matched your search
@@ -1,21 +1,14 @@
|
||||
import type { Metadata } from "next";
|
||||
import { ShieldCheck, History, Award, CheckCircle } from "lucide-react";
|
||||
import { getPageMetadata } from "../../lib/seo";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "درباره ما - میراث ۴۰ ساله کانیتا آلمان در ایران",
|
||||
description: "داستان کنینا ایران و میراث ۴۰ ساله شرکت Canina pharma GmbH آلمان در تولید مکملهای فوقتخصصی دامپزشکی با گرید دارویی اختصاصی.",
|
||||
alternates: {
|
||||
canonical: "/about",
|
||||
},
|
||||
openGraph: {
|
||||
title: "درباره ما - کنینا ایران",
|
||||
description: "داستان کنینا ایران و میراث ۴۰ ساله شرکت Canina pharma GmbH آلمان در تولید مکملهای فوقتخصصی دامپزشکی.",
|
||||
url: "https://canina.ir/about",
|
||||
siteName: "کنینا ایران",
|
||||
locale: "fa_IR",
|
||||
type: "website",
|
||||
}
|
||||
};
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('about', {
|
||||
canonicalPath: '/about',
|
||||
fallbackTitle: 'درباره شرکت کنینا ایران و اصالت آلمانی',
|
||||
fallbackDesc: 'داستان کنینا ایران و بیش از ۴۰ سال سابقه درخشان شرکت Canina pharma GmbH آلمان در تولید مکملهای فوقتخصصی دامپزشکی.',
|
||||
});
|
||||
}
|
||||
|
||||
export default function AboutPage() {
|
||||
return (
|
||||
|
||||
@@ -29,26 +29,35 @@ async function getBlog(slug: string) {
|
||||
|
||||
export const revalidate = 60; // ensure SSR dynamic revalidation works correctly
|
||||
|
||||
import { getSeoConfig, formatPageTitle } from "../../../lib/seo";
|
||||
|
||||
export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
const blog = await getBlog(slug);
|
||||
if (!blog) return { title: 'مقاله یافت نشد | کنینا ایران' };
|
||||
const config = await getSeoConfig();
|
||||
|
||||
if (!blog) {
|
||||
return {
|
||||
title: formatPageTitle('مقاله یافت نشد', config.brandNameFa, config.titleSeparator, config.titlePosition),
|
||||
};
|
||||
}
|
||||
|
||||
const title = `${blog.title} | مجله سلامت کنینا`;
|
||||
const description = blog.excerpt.substring(0, 150).trim();
|
||||
const title = formatPageTitle(blog.title, config.brandNameFa, config.titleSeparator, config.titlePosition, false);
|
||||
const description = blog.excerpt.substring(0, 155).trim() || config.defaultMetaDescription;
|
||||
const canonicalUrl = `${config.canonicalBaseUrl.replace(/\/$/, '')}/blog/${slug}`;
|
||||
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
alternates: {
|
||||
canonical: `/blog/${slug}`,
|
||||
canonical: canonicalUrl,
|
||||
},
|
||||
openGraph: {
|
||||
title,
|
||||
description,
|
||||
images: [blog.image],
|
||||
url: `/blog/${slug}`,
|
||||
siteName: "کنینا ایران",
|
||||
images: [blog.image || config.ogImageUrl],
|
||||
url: canonicalUrl,
|
||||
siteName: config.brandNameFa,
|
||||
type: "article",
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
import BlogPage from "../../components/BlogPage";
|
||||
import type { Metadata } from 'next';
|
||||
import { getPageMetadata } from "../../lib/seo";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "مجله سلامت حیوانات خانگی و مقالات علمی - کنینا ایران",
|
||||
description: "آخرین مقالات، آموزشهای دامپزشکی و اخبار علمی روز دنیا در زمینه نگهداری، تغذیه تخصصی و سلامت سگ و گربه.",
|
||||
alternates: {
|
||||
canonical: "/blog",
|
||||
},
|
||||
openGraph: {
|
||||
title: "مجله سلامت حیوانات خانگی - کنینا ایران",
|
||||
description: "آخرین مقالات، آموزشها و اخبار علمی در زمینه نگهداری، تغذیه و سلامت سگ و گربه.",
|
||||
url: "https://canina.ir/blog",
|
||||
siteName: "کنینا ایران",
|
||||
locale: "fa_IR",
|
||||
type: "website",
|
||||
}
|
||||
};
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('blog', {
|
||||
canonicalPath: '/blog',
|
||||
fallbackTitle: 'مجله سلامت و دانشنامه مقالات تخصصی پت',
|
||||
fallbackDesc: 'جدیدترین مقالات علمی، راهنمای تغذیه، بیماریهای سگ و گربه و توصیههای بالینی متخصصان و دامپزشکان کنینا.',
|
||||
});
|
||||
}
|
||||
|
||||
async function getBlogs() {
|
||||
const rawApiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://127.0.0.1:4001/api';
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
import type { Metadata } from "next";
|
||||
import CatalogClient from "./CatalogClient";
|
||||
import { getPageMetadata } from "../../lib/seo";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "کاتالوگ محصولات Canina - راهنمای مکملهای درمانی سگ و گربه",
|
||||
description: "کاتالوگ جامع محصولات آلمانی کنینا شامل راهنمای ترکیبات، گرید دارویی، دوز مصرفی و موارد درمان بالینی مفصل، پوست و مو و رشد پتها.",
|
||||
alternates: {
|
||||
canonical: "/catalog",
|
||||
},
|
||||
openGraph: {
|
||||
title: "کاتالوگ رسمی مکملهای درمانی Canina Pharma Germany",
|
||||
description: "دانلود و مشاهده آنلاین کاتالوگ مکملهای دارویی حیوانات خانگی کنینا آلمان",
|
||||
url: "https://canina.ir/catalog",
|
||||
siteName: "کنینا ایران",
|
||||
locale: "fa_IR",
|
||||
type: "website",
|
||||
}
|
||||
};
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('catalog', {
|
||||
canonicalPath: '/catalog',
|
||||
fallbackTitle: 'کاتالوگ رسمی مکملهای درمانی و دارویی',
|
||||
fallbackDesc: 'مشاهده و مطالعه کاتالوگ جامع دارویی و مکملهای تغذیهای تخصصی کنینا آلمان با قابلیت ورقزدن تعاملی و ثبت پیشخرید.',
|
||||
});
|
||||
}
|
||||
|
||||
export default function CatalogPage() {
|
||||
return <CatalogClient />;
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
import type { Metadata } from 'next';
|
||||
import CheckoutPage from "../../components/CheckoutPage";
|
||||
import { getPageMetadata } from "../../lib/seo";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('checkout', {
|
||||
canonicalPath: '/checkout',
|
||||
fallbackTitle: 'تسویهحساب و پرداخت امن',
|
||||
fallbackDesc: 'انتخاب آدرس تحویل، روش ارسال و تسویهحساب سریع و امن سفارشات مکملهای کنینا.',
|
||||
noIndex: true,
|
||||
});
|
||||
}
|
||||
|
||||
export default function Checkout() {
|
||||
return <CheckoutPage />;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
import type { Metadata } from "next";
|
||||
import ContactFormClient from "@/components/ContactFormClient";
|
||||
import { getPageMetadata } from "@/lib/seo";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "تماس با ما - نمایندگی رسمی مکملهای کنینا آلمان در ایران",
|
||||
description: "راههای ارتباطی، تلفن تماس ویژه، آدرس دفتر مرکزی و فرم تماس مستقیم با نمایندگی انحصاری کانیتا آلمان در ایران.",
|
||||
alternates: {
|
||||
canonical: "/contact",
|
||||
},
|
||||
openGraph: {
|
||||
title: "تماس با ما - کنینا ایران",
|
||||
description: "راههای ارتباطی با نمایندگی رسمی مکملهای دامپزشکی کنینا در ایران.",
|
||||
url: "https://canina.ir/contact",
|
||||
siteName: "کنینا ایران",
|
||||
locale: "fa_IR",
|
||||
type: "website",
|
||||
}
|
||||
};
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('contact', {
|
||||
canonicalPath: '/contact',
|
||||
fallbackTitle: 'تماس با ما و مشاوره تخصصی دامپزشکی',
|
||||
fallbackDesc: 'راههای ارتباطی با دفتر مرکزی کنینا ایران، مشاوره تلفنی رایگان، پشتیبانی آنلاین و نشانی.',
|
||||
});
|
||||
}
|
||||
|
||||
export default function ContactPage() {
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
import type { Metadata } from 'next';
|
||||
import UserDashboard from "../../components/UserDashboard";
|
||||
import { getPageMetadata } from "../../lib/seo";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('dashboard', {
|
||||
canonicalPath: '/dashboard',
|
||||
fallbackTitle: 'داشبورد کاربری و پیگیری سفارشات',
|
||||
fallbackDesc: 'مشاهده تاریخچه خریدها، وضعیت کیف پول، پیگیری آنلاین بستههای پستی و مدیریت پتها.',
|
||||
noIndex: true,
|
||||
});
|
||||
}
|
||||
|
||||
export default function DashboardPage() {
|
||||
return <UserDashboard />;
|
||||
}
|
||||
|
||||
@@ -1,40 +1,25 @@
|
||||
import type { Metadata } from 'next';
|
||||
import './globals.css';
|
||||
import ClientLayout from './ClientLayout';
|
||||
import { getSeoConfig } from '../lib/seo';
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
let seoSettings: {
|
||||
defaultMetaTitle?: string;
|
||||
defaultMetaDescription?: string;
|
||||
keywords?: string | string[];
|
||||
canonicalBaseUrl?: string;
|
||||
ogImageUrl?: string;
|
||||
} | null = null;
|
||||
const config = await getSeoConfig();
|
||||
const siteUrl = config.canonicalBaseUrl || process.env.NEXT_PUBLIC_SITE_URL || 'https://canina.ir';
|
||||
const titleDefault = config.defaultMetaTitle;
|
||||
const descriptionDefault = config.defaultMetaDescription;
|
||||
const keywordsList = config.keywords;
|
||||
const ogImg = config.ogImageUrl;
|
||||
const brandName = config.brandNameFa;
|
||||
const separator = config.titleSeparator;
|
||||
const position = config.titlePosition;
|
||||
|
||||
try {
|
||||
const apiBase = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4001/api';
|
||||
const res = await fetch(`${apiBase}/settings/seo`, { next: { revalidate: 60 } });
|
||||
if (res.ok) {
|
||||
seoSettings = await res.json();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[SEO] Error fetching dynamic SEO settings:', err);
|
||||
}
|
||||
|
||||
const siteUrl = seoSettings?.canonicalBaseUrl || process.env.NEXT_PUBLIC_SITE_URL || 'https://canina.ir';
|
||||
const titleDefault = seoSettings?.defaultMetaTitle || 'کنینا ایران - مکملهای درمانی حیوانات خانگی با گرید دارویی اختصاصی';
|
||||
const descriptionDefault = seoSettings?.defaultMetaDescription || 'تدارک هوشمندانه سلامت برای همراهان وفادار شما. کنینا ایران واردکننده انحصاری مکملهای درمانی با گرید دارویی اختصاصی از آلمان.';
|
||||
|
||||
let keywordsList: string[] = ['مکمل حیوانات خانگی', 'مکمل سگ', 'مکمل گربه', 'کنینا', 'داروی حیوانات', 'Canina Iran'];
|
||||
if (seoSettings?.keywords) {
|
||||
if (Array.isArray(seoSettings.keywords)) {
|
||||
keywordsList = seoSettings.keywords;
|
||||
} else if (typeof seoSettings.keywords === 'string') {
|
||||
keywordsList = seoSettings.keywords.split(',').map(k => k.trim());
|
||||
}
|
||||
}
|
||||
|
||||
const ogImg = seoSettings?.ogImageUrl || '/assets/images/regenerated_image_1779109861747.png';
|
||||
const templateStr =
|
||||
position === 'prefix'
|
||||
? `${brandName} ${separator} %s`
|
||||
: position === 'none'
|
||||
? '%s'
|
||||
: `%s ${separator} ${brandName}`;
|
||||
|
||||
const isStaging =
|
||||
process.env.NEXT_PUBLIC_APP_ENV === 'staging' ||
|
||||
@@ -48,14 +33,14 @@ export async function generateMetadata(): Promise<Metadata> {
|
||||
return {
|
||||
metadataBase: new URL(siteUrl),
|
||||
title: {
|
||||
template: '%s | کنینا ایران',
|
||||
template: templateStr,
|
||||
default: titleDefault,
|
||||
},
|
||||
description: descriptionDefault,
|
||||
keywords: keywordsList,
|
||||
authors: [{ name: 'Canina Iran' }],
|
||||
creator: 'Canina Iran',
|
||||
publisher: 'Canina Iran',
|
||||
authors: [{ name: brandName }],
|
||||
creator: brandName,
|
||||
publisher: brandName,
|
||||
robots: isStaging ? {
|
||||
index: false,
|
||||
follow: false,
|
||||
@@ -88,7 +73,7 @@ export async function generateMetadata(): Promise<Metadata> {
|
||||
title: titleDefault,
|
||||
description: descriptionDefault,
|
||||
url: siteUrl,
|
||||
siteName: 'کنینا ایران',
|
||||
siteName: brandName,
|
||||
locale: 'fa_IR',
|
||||
type: 'website',
|
||||
images: [
|
||||
|
||||
@@ -1,35 +1,12 @@
|
||||
import type { Metadata } from "next";
|
||||
import HomeClient from "./HomeClient";
|
||||
import { getPageMetadata } from "../lib/seo";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "کنینا ایران - مکملهای درمانی حیوانات خانگی با گرید دارویی اختصاصی",
|
||||
description: "تدارک هوشمندانه سلامت برای همراهان وفادار شما. کنینا ایران واردکننده انحصاری مکملهای درمانی با گرید دارویی اختصاصی از آلمان با پروانه رسمی دامپزشکی.",
|
||||
alternates: {
|
||||
canonical: "/",
|
||||
},
|
||||
openGraph: {
|
||||
title: "کنینا ایران - مکملهای درمانی حیوانات خانگی با گرید دارویی اختصاصی",
|
||||
description: "واردکننده انحصاری مکملهای درمانی با گرید دارویی اختصاصی از آلمان",
|
||||
url: "https://canina.ir",
|
||||
siteName: "کنینا ایران",
|
||||
locale: "fa_IR",
|
||||
type: "website",
|
||||
images: [
|
||||
{
|
||||
url: "/assets/images/regenerated_image_1779109861747.png",
|
||||
width: 1200,
|
||||
height: 630,
|
||||
alt: "کنینا ایران - مکملهای درمانی حیوانات خانگی",
|
||||
}
|
||||
]
|
||||
},
|
||||
twitter: {
|
||||
card: "summary_large_image",
|
||||
title: "کنینا ایران - مکملهای درمانی حیوانات خانگی با گرید دارویی اختصاصی",
|
||||
description: "تدارک هوشمندانه سلامت برای همراهان وفادار شما.",
|
||||
images: ["/assets/images/regenerated_image_1779109861747.png"],
|
||||
}
|
||||
};
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('home', {
|
||||
canonicalPath: '/',
|
||||
});
|
||||
}
|
||||
|
||||
import { HomeApiResponse } from "../lib/types";
|
||||
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Shield } from "lucide-react";
|
||||
import { getPageMetadata } from "../../lib/seo";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "حریم خصوصی کاربران - کنینا ایران",
|
||||
description: "سیاستهای حفاظت از اطلاعات شخصی کاربران، امنیت دادههای پزشکی و پروندههای درمانی پت در وبسایت کنینا ایران.",
|
||||
alternates: {
|
||||
canonical: "/privacy",
|
||||
},
|
||||
openGraph: {
|
||||
title: "حریم خصوصی کاربران - کنینا ایران",
|
||||
description: "سیاستهای حفاظت از اطلاعات شخصی کاربران در وبسایت کنینا ایران.",
|
||||
url: "https://canina.ir/privacy",
|
||||
siteName: "کنینا ایران",
|
||||
locale: "fa_IR",
|
||||
type: "website",
|
||||
}
|
||||
};
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('privacy', {
|
||||
canonicalPath: '/privacy',
|
||||
fallbackTitle: 'حریم خصوصی و شرایط استفاده',
|
||||
fallbackDesc: 'سیاستهای حفاظت از اطلاعات شخصی کاربران، امنیت دادههای پزشکی و قوانین استفاده از خدمات کنینا ایران.',
|
||||
});
|
||||
}
|
||||
|
||||
export default function PrivacyPage() {
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
import type { Metadata } from 'next';
|
||||
import PetProfile from "../../components/PetProfile";
|
||||
import { getPageMetadata } from "../../lib/seo";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('profile_pets', {
|
||||
canonicalPath: '/profile',
|
||||
fallbackTitle: 'پرونده الکترونیک سلامت پت',
|
||||
fallbackDesc: 'مدیریت و ثبت پرونده سلامت سگ و گربه، تنظیم یادآورهای دوز دارو و تاریخچه تغذیه مکملها.',
|
||||
noIndex: true,
|
||||
});
|
||||
}
|
||||
|
||||
export default function ProfilePage() {
|
||||
return <PetProfile />;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import SearchResultsPage from "../../components/SearchResultsPage";
|
||||
import SearchResultsPage from "../../components/SearchResultsPage";
|
||||
import type { Metadata } from 'next';
|
||||
import { getPageMetadata } from "../../lib/seo";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'جستجوی محصولات',
|
||||
description: 'جستجوی مکملهای درمانی حیوانات خانگی، داروها و مقالات سلامت در کنینا ایران.',
|
||||
};
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('search', {
|
||||
canonicalPath: '/search',
|
||||
fallbackTitle: 'جستجوی هوشمند مکملها و دانشنامه سلامت',
|
||||
fallbackDesc: 'جستجوی سریع در کاتالوگ محصولات، بیماریها، علائم بالینی و مقالات سلامت کنینا ایران.',
|
||||
});
|
||||
}
|
||||
|
||||
export default async function SearchPage({ searchParams }: { searchParams: Promise<{ q?: string }> }) {
|
||||
const params = await searchParams;
|
||||
|
||||
@@ -2,25 +2,29 @@ import ProductPage from "../../../components/ProductPage";
|
||||
import { productService } from "../../../lib/services/productService";
|
||||
import type { Metadata } from 'next';
|
||||
import { Suspense } from 'react';
|
||||
import { getSeoConfig, formatPageTitle } from "../../../lib/seo";
|
||||
|
||||
export async function generateMetadata(
|
||||
{ params }: { params: Promise<{ slug: string }> }
|
||||
): Promise<Metadata> {
|
||||
const resolvedParams = await params;
|
||||
const product = await productService.getProductBySlug(resolvedParams.slug);
|
||||
const config = await getSeoConfig();
|
||||
|
||||
if (!product) {
|
||||
return {
|
||||
title: 'خرید مکمل درمانی پت | کنینا ایران',
|
||||
title: formatPageTitle('مکمل درمانی یافت نشد', config.brandNameFa, config.titleSeparator, config.titlePosition),
|
||||
};
|
||||
}
|
||||
|
||||
const nameFa = product.nameFa || product.name;
|
||||
const nameEn = product.nameEn || "";
|
||||
const title = nameFa.includes("Canina") ? nameFa : `${nameFa} (${nameEn}) | برند کنینا آلمان`;
|
||||
const description = (product.shortDescription || product.description || '').substring(0, 150).trim();
|
||||
const nameEn = product.nameEn ? ` (${product.nameEn})` : '';
|
||||
const rawTitle = `${nameFa}${nameEn}`;
|
||||
const title = formatPageTitle(rawTitle, config.brandNameFa, config.titleSeparator, config.titlePosition, false);
|
||||
const description = (product.shortDescription || product.description || '').substring(0, 155).trim() || config.defaultMetaDescription;
|
||||
const rawKeywords = (product as unknown as Record<string, unknown>).keywords;
|
||||
const keywords = typeof rawKeywords === 'string' ? rawKeywords.split(',') : product.main_ingredients;
|
||||
const keywords = typeof rawKeywords === 'string' ? rawKeywords.split(',').map(k => k.trim()) : (product.main_ingredients || config.keywords);
|
||||
const canonicalUrl = `${config.canonicalBaseUrl.replace(/\/$/, '')}/shop/${resolvedParams.slug}`;
|
||||
|
||||
return {
|
||||
title,
|
||||
@@ -29,13 +33,13 @@ export async function generateMetadata(
|
||||
openGraph: {
|
||||
title,
|
||||
description,
|
||||
images: [product.image],
|
||||
url: `/shop/${resolvedParams.slug}`,
|
||||
siteName: "کنینا ایران",
|
||||
images: [product.image || config.ogImageUrl],
|
||||
url: canonicalUrl,
|
||||
siteName: config.brandNameFa,
|
||||
type: "website",
|
||||
},
|
||||
alternates: {
|
||||
canonical: `/shop/${resolvedParams.slug}`,
|
||||
canonical: canonicalUrl,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
import type { Metadata } from "next";
|
||||
import ArchivePage from "../../components/ArchivePage";
|
||||
import { getPageMetadata } from "../../lib/seo";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "فروشگاه تخصصی مکملهای دارویی - کنینا ایران",
|
||||
description: "خرید آنلاین انواع مکملهای درمانی، مفاصل و استخوان، گوارش و ایمنی، ویتامینها و مراقبتهای ویژه سگ و گربه با تضمین اصالت و گواهی سلامت دامپزشکی.",
|
||||
alternates: {
|
||||
canonical: "/shop",
|
||||
},
|
||||
openGraph: {
|
||||
title: "فروشگاه تخصصی مکملهای دارویی - کنینا ایران",
|
||||
description: "خرید آنلاین انواع مکملهای درمانی، مفاصل و استخوان، گوارش و ایمنی، ویتامینها و مراقبتهای ویژه سگ و گربه.",
|
||||
url: "https://canina.ir/shop",
|
||||
siteName: "کنینا ایران",
|
||||
locale: "fa_IR",
|
||||
type: "website",
|
||||
}
|
||||
};
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('shop', {
|
||||
canonicalPath: '/shop',
|
||||
fallbackTitle: 'فروشگاه تخصصی مکملهای دارویی سگ و گربه',
|
||||
fallbackDesc: 'خرید آنلاین انواع مکملهای درمانی مفاصل، پوست و مو، گوارش و ایمنی، رشد و ویتامینه سگ و گربه با ضمانت اصالت کنینا آلمان.',
|
||||
});
|
||||
}
|
||||
|
||||
export default async function Shop({ searchParams }: { searchParams: Promise<{ [key: string]: string | string[] | undefined }> }) {
|
||||
const resolvedParams = await searchParams;
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import type { Metadata } from 'next';
|
||||
import OrderTracking from "../../components/OrderTracking";
|
||||
import { getPageMetadata } from "../../lib/seo";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('track', {
|
||||
canonicalPath: '/track',
|
||||
fallbackTitle: 'پیگیری آنلاین سفارش و مرسوله پستی',
|
||||
fallbackDesc: 'پیگیری وضعیت لحظهای پردازش، بستهبندی و کد رهگیری پست پیشتاز سفارشات کنینا ایران.',
|
||||
});
|
||||
}
|
||||
|
||||
export default function TrackPage() {
|
||||
return <OrderTracking />;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import React from 'react';
|
||||
import { Metadata } from 'next';
|
||||
import type { Metadata } from 'next';
|
||||
import EnamadBadge from '@/components/EnamadBadge';
|
||||
import { ShieldCheck, Award, FileCheck, CheckCircle2, Building2 } from 'lucide-react';
|
||||
import { getPageMetadata } from '@/lib/seo';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'نمادهای اعتماد و مجوزهای رسمی | کنینا ایران',
|
||||
description: 'مشاهده نماد اعتماد الکترونیکی (اینماد)، مجوزهای سازمان دامپزشکی کشور و گواهینامههای اصالت کالاهای کنینا ایران.',
|
||||
};
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('trust_seals', {
|
||||
canonicalPath: '/trust-seals',
|
||||
fallbackTitle: 'مجوزهای رسمی، گواهی اصالت و اینماد',
|
||||
fallbackDesc: 'بررسی تاییدیههای رسمی سازمان دامپزشکی کشور، گواهی استاندارد آلمان و اینماد رسمی کنینا ایران.',
|
||||
});
|
||||
}
|
||||
|
||||
export default function TrustSealsPage() {
|
||||
const licenses = [
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import type { Metadata } from 'next';
|
||||
import VideosPage from "../../components/VideosPage";
|
||||
import { getPageMetadata } from "../../lib/seo";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('videos', {
|
||||
canonicalPath: '/videos',
|
||||
fallbackTitle: 'ویدئوهای آموزشی و توصیههای بالینی دامپزشکان',
|
||||
fallbackDesc: 'مشاهده ویدئوهای تخصصی نحوه مصرف مکملهای درمانی، نظرات دامپزشکان و راهکارهای بالینی تصویری.',
|
||||
});
|
||||
}
|
||||
|
||||
export default function Videos() {
|
||||
return <VideosPage />;
|
||||
}
|
||||
|
||||
@@ -15,14 +15,37 @@ async function getWikiTerm(key: string) {
|
||||
}
|
||||
}
|
||||
|
||||
import { getSeoConfig, formatPageTitle } from "../../../lib/seo";
|
||||
|
||||
export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
const term = await getWikiTerm(slug);
|
||||
if (!term) return { title: 'ترکیب علمی یافت نشد' };
|
||||
const config = await getSeoConfig();
|
||||
|
||||
if (!term) {
|
||||
return {
|
||||
title: formatPageTitle('ترکیب علمی یافت نشد', config.brandNameFa, config.titleSeparator, config.titlePosition),
|
||||
};
|
||||
}
|
||||
|
||||
const rawTitle = term.metaTitle || `ترکیب علمی ${term.term}`;
|
||||
const title = formatPageTitle(rawTitle, config.brandNameFa, config.titleSeparator, config.titlePosition, false);
|
||||
const description = term.metaDescription || term.definition?.replace(/<[^>]+>/g, '').substring(0, 155).trim() || config.defaultMetaDescription;
|
||||
const canonicalUrl = `${config.canonicalBaseUrl.replace(/\/$/, '')}/wiki/${slug}`;
|
||||
|
||||
return {
|
||||
title: term.metaTitle || term.term,
|
||||
description: term.metaDescription || term.definition?.substring(0, 160),
|
||||
title,
|
||||
description,
|
||||
alternates: {
|
||||
canonical: canonicalUrl,
|
||||
},
|
||||
openGraph: {
|
||||
title,
|
||||
description,
|
||||
url: canonicalUrl,
|
||||
siteName: config.brandNameFa,
|
||||
type: "article",
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
import { Suspense } from "react";
|
||||
import IngredientWiki from "../../components/IngredientWiki";
|
||||
import type { Metadata } from 'next';
|
||||
import { getPageMetadata } from "../../lib/seo";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "دانشنامه ترکیبات دارویی و علمی - کنینا ایران",
|
||||
description: "اطلاعات کامل پزشکی در مورد مواد موثره، ویتامینها و ترکیبات گیاهی نایاب به کار رفته در محصولات تخصصی کانیتا آلمان.",
|
||||
alternates: {
|
||||
canonical: "/wiki",
|
||||
},
|
||||
openGraph: {
|
||||
title: "دانشنامه ترکیبات دارویی و علمی - کنینا ایران",
|
||||
description: "اطلاعات کامل در مورد مواد موثره، ویتامینها و ترکیبات گیاهی به کار رفته در محصولات تخصصی کنینا ایران.",
|
||||
url: "https://canina.ir/wiki",
|
||||
siteName: "کنینا ایران",
|
||||
locale: "fa_IR",
|
||||
type: "website",
|
||||
}
|
||||
};
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return getPageMetadata('wiki', {
|
||||
canonicalPath: '/wiki',
|
||||
fallbackTitle: 'دانشنامه علمی ترکیبات و اصطلاحات دارویی',
|
||||
fallbackDesc: 'مرجع تخصصی اثرات بالینی، مواد تشکیلدهنده، ویتامینها و ترکیبات ارگانیک به کار رفته در مکملهای دارویی کنینا آلمان.',
|
||||
});
|
||||
}
|
||||
|
||||
export default function WikiPage() {
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
export interface SeoConfig {
|
||||
brandNameFa: string;
|
||||
brandNameEn: string;
|
||||
titleSeparator: string;
|
||||
titlePosition: 'suffix' | 'prefix' | 'none';
|
||||
defaultMetaTitle: string;
|
||||
defaultMetaDescription: string;
|
||||
keywords: string[];
|
||||
canonicalBaseUrl: string;
|
||||
ogImageUrl: string;
|
||||
texts: Record<string, string>;
|
||||
}
|
||||
|
||||
const DEFAULT_SEO_CONFIG: SeoConfig = {
|
||||
brandNameFa: 'کنینا ایران',
|
||||
brandNameEn: 'Canina Iran',
|
||||
titleSeparator: '|',
|
||||
titlePosition: 'suffix',
|
||||
defaultMetaTitle: 'کنینا ایران | نماینده رسمی مکملهای دارویی Canina آلمان',
|
||||
defaultMetaDescription: 'فروشگاه تخصصی و نماینده انحصاری مکملهای درمانی و تقویتی سگ و گربه کنینا آلمان با فرمولاسیون دارویی و تاییدیه بالینی.',
|
||||
keywords: ['کنینا', 'مکمل حیوانات خانگی', 'مکمل سگ', 'مکمل گربه', 'داروی حیوانات', 'Canina Iran'],
|
||||
canonicalBaseUrl: 'https://canina.ir',
|
||||
ogImageUrl: '/assets/images/regenerated_image_1779109861747.png',
|
||||
texts: {},
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch dynamic SEO settings and UI texts on server with 60-second revalidation
|
||||
*/
|
||||
export async function getSeoConfig(): Promise<SeoConfig> {
|
||||
const apiBase =
|
||||
process.env.INTERNAL_API_URL ||
|
||||
process.env.NEXT_PUBLIC_API_URL ||
|
||||
'http://localhost:4001/api';
|
||||
|
||||
try {
|
||||
const res = await fetch(`${apiBase}/settings/ui-texts`, {
|
||||
next: { revalidate: 60, tags: ['ui-texts', 'settings'] },
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
const texts: Record<string, string> = {};
|
||||
|
||||
if (Array.isArray(data)) {
|
||||
data.forEach((item: { key: string; value: string }) => {
|
||||
if (item?.key) texts[item.key] = item.value;
|
||||
});
|
||||
} else if (typeof data === 'object' && data !== null) {
|
||||
Object.entries(data).forEach(([k, v]) => {
|
||||
texts[k] = String(v);
|
||||
});
|
||||
}
|
||||
|
||||
const brandNameFa =
|
||||
texts['brand_name_fa'] ||
|
||||
texts['BRAND_LOGO_TEXT_FA'] ||
|
||||
texts['site_logo_text_fa'] ||
|
||||
DEFAULT_SEO_CONFIG.brandNameFa;
|
||||
|
||||
const brandNameEn =
|
||||
texts['brand_name_en'] ||
|
||||
texts['BRAND_LOGO_TEXT_EN'] ||
|
||||
DEFAULT_SEO_CONFIG.brandNameEn;
|
||||
|
||||
const titleSeparator =
|
||||
texts['title_separator'] || DEFAULT_SEO_CONFIG.titleSeparator;
|
||||
|
||||
const titlePositionRaw = texts['title_position']?.toLowerCase();
|
||||
const titlePosition: 'suffix' | 'prefix' | 'none' =
|
||||
titlePositionRaw === 'prefix' || titlePositionRaw === 'none'
|
||||
? titlePositionRaw
|
||||
: 'suffix';
|
||||
|
||||
const defaultMetaTitle =
|
||||
texts['defaultMetaTitle'] ||
|
||||
texts['home_meta_title'] ||
|
||||
DEFAULT_SEO_CONFIG.defaultMetaTitle;
|
||||
|
||||
const defaultMetaDescription =
|
||||
texts['defaultMetaDescription'] ||
|
||||
texts['home_meta_desc'] ||
|
||||
DEFAULT_SEO_CONFIG.defaultMetaDescription;
|
||||
|
||||
const rawKeywords = texts['keywords'] || texts['home_keywords'];
|
||||
const keywords = rawKeywords
|
||||
? rawKeywords.split(',').map((k) => k.trim()).filter(Boolean)
|
||||
: DEFAULT_SEO_CONFIG.keywords;
|
||||
|
||||
const canonicalBaseUrl =
|
||||
texts['canonicalBaseUrl'] ||
|
||||
process.env.NEXT_PUBLIC_SITE_URL ||
|
||||
DEFAULT_SEO_CONFIG.canonicalBaseUrl;
|
||||
|
||||
const ogImageUrl =
|
||||
texts['ogImageUrl'] || DEFAULT_SEO_CONFIG.ogImageUrl;
|
||||
|
||||
return {
|
||||
brandNameFa,
|
||||
brandNameEn,
|
||||
titleSeparator,
|
||||
titlePosition,
|
||||
defaultMetaTitle,
|
||||
defaultMetaDescription,
|
||||
keywords,
|
||||
canonicalBaseUrl,
|
||||
ogImageUrl,
|
||||
texts,
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('[SEO] Unable to fetch dynamic settings from backend, using fallback:', error);
|
||||
}
|
||||
|
||||
return DEFAULT_SEO_CONFIG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uniform Page Title Formatter according to Store Brand Configuration
|
||||
*/
|
||||
export function formatPageTitle(
|
||||
rawTitle: string,
|
||||
brandName = 'کنینا ایران',
|
||||
separator = '|',
|
||||
position: 'suffix' | 'prefix' | 'none' = 'suffix',
|
||||
isHomePage = false
|
||||
): string {
|
||||
if (!rawTitle || !rawTitle.trim()) {
|
||||
return brandName;
|
||||
}
|
||||
|
||||
const clean = rawTitle.trim();
|
||||
|
||||
// If this is the home page and has a custom full title configured, return it directly
|
||||
if (isHomePage) {
|
||||
return clean;
|
||||
}
|
||||
|
||||
// Check if the title already explicitly contains the brand name
|
||||
const escapedBrand = brandName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
const brandRegex = new RegExp(`(\\s*[-|•]\\s*${escapedBrand}|${escapedBrand}\\s*[-|•]\\s*)`, 'gi');
|
||||
|
||||
// Strip existing repeated brand affix if present so we can format cleanly
|
||||
const baseTitle = clean.replace(brandRegex, '').trim();
|
||||
|
||||
if (position === 'none') {
|
||||
return baseTitle || clean;
|
||||
}
|
||||
|
||||
if (position === 'prefix') {
|
||||
return `${brandName} ${separator} ${baseTitle || clean}`;
|
||||
}
|
||||
|
||||
// Default: 'suffix' -> "{PageTitle} {separator} {BrandName}"
|
||||
return `${baseTitle || clean} ${separator} ${brandName}`;
|
||||
}
|
||||
|
||||
export interface PageMetadataOptions {
|
||||
fallbackTitle?: string;
|
||||
fallbackDesc?: string;
|
||||
fallbackKeywords?: string[];
|
||||
canonicalPath?: string;
|
||||
ogImage?: string;
|
||||
isDynamicEntity?: boolean; // For PDP / Blog / Wiki detail
|
||||
noIndex?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate standard Next.js Metadata object dynamically from server settings
|
||||
*/
|
||||
export async function getPageMetadata(
|
||||
pageKey: string,
|
||||
options: PageMetadataOptions = {}
|
||||
): Promise<Metadata> {
|
||||
const config = await getSeoConfig();
|
||||
const { texts, brandNameFa, titleSeparator, titlePosition, canonicalBaseUrl, ogImageUrl } = config;
|
||||
|
||||
const isHome = pageKey === 'home';
|
||||
const rawTitle =
|
||||
texts[`${pageKey}_meta_title`] ||
|
||||
options.fallbackTitle ||
|
||||
config.defaultMetaTitle;
|
||||
|
||||
const title = options.isDynamicEntity
|
||||
? formatPageTitle(rawTitle, brandNameFa, titleSeparator, titlePosition, false)
|
||||
: formatPageTitle(rawTitle, brandNameFa, titleSeparator, titlePosition, isHome);
|
||||
|
||||
const description =
|
||||
texts[`${pageKey}_meta_desc`] ||
|
||||
options.fallbackDesc ||
|
||||
config.defaultMetaDescription;
|
||||
|
||||
const rawKeywords = texts[`${pageKey}_keywords`];
|
||||
const keywords = rawKeywords
|
||||
? rawKeywords.split(',').map((k) => k.trim()).filter(Boolean)
|
||||
: options.fallbackKeywords || config.keywords;
|
||||
|
||||
const explicitCanonical = texts[`${pageKey}_canonical`];
|
||||
const relativePath = options.canonicalPath ?? (isHome ? '/' : `/${pageKey.replace(/_/g, '-')}`);
|
||||
const canonicalUrl = explicitCanonical || `${canonicalBaseUrl.replace(/\/$/, '')}${relativePath}`;
|
||||
|
||||
const image = options.ogImage || ogImageUrl;
|
||||
|
||||
const isStaging =
|
||||
options.noIndex ||
|
||||
process.env.NEXT_PUBLIC_APP_ENV === 'staging' ||
|
||||
process.env.NODE_ENV !== 'production' ||
|
||||
(typeof process.env.NEXT_PUBLIC_SITE_URL === 'string' &&
|
||||
(process.env.NEXT_PUBLIC_SITE_URL.includes('stage') ||
|
||||
process.env.NEXT_PUBLIC_SITE_URL.includes('test') ||
|
||||
process.env.NEXT_PUBLIC_SITE_URL.includes('dev')));
|
||||
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
keywords,
|
||||
alternates: {
|
||||
canonical: canonicalUrl,
|
||||
},
|
||||
openGraph: {
|
||||
title,
|
||||
description,
|
||||
url: canonicalUrl,
|
||||
siteName: brandNameFa,
|
||||
locale: 'fa_IR',
|
||||
type: 'website',
|
||||
images: [
|
||||
{
|
||||
url: image,
|
||||
width: 1200,
|
||||
height: 630,
|
||||
alt: title,
|
||||
},
|
||||
],
|
||||
},
|
||||
twitter: {
|
||||
card: 'summary_large_image',
|
||||
title,
|
||||
description,
|
||||
images: [image],
|
||||
},
|
||||
robots: isStaging
|
||||
? {
|
||||
index: false,
|
||||
follow: false,
|
||||
nocache: true,
|
||||
googleBot: {
|
||||
index: false,
|
||||
follow: false,
|
||||
noimageindex: true,
|
||||
},
|
||||
}
|
||||
: {
|
||||
index: true,
|
||||
follow: true,
|
||||
googleBot: {
|
||||
index: true,
|
||||
follow: true,
|
||||
'max-video-preview': -1,
|
||||
'max-image-preview': 'large',
|
||||
'max-snippet': -1,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user