fix(seo): resolve technical SEO issues (SEO-P0-01, SEO-P0-02, SEO-P1-06, SEO-P2-15)
Deploy Canina / deploy (push) Successful in 2m11s

- SEO-P0-01: prioritize options.canonicalPath in getPageMetadata over shop_canonical text
- SEO-P0-02: invoke notFound() in /shop/[slug] and /wiki/[slug] when entity is missing
- SEO-P1-06: package root JSON-LD Organization and WebSite into @graph structure
- SEO-P2-15: add hreflang fa-IR and x-default alternates in root layout metadata
- Add regression test suite lib/__tests__/seo-technical.test.ts
This commit is contained in:
devops committed 2026-10-17 20:02:56 +00:00
1 parent 87bf867513
commit 5cf2863987
5 files changed
+170 -13

No files matched your search

+10 -1
View File
@@ -71,6 +71,10 @@ export async function generateMetadata(): Promise<Metadata> {
},
alternates: {
canonical: '/',
languages: {
'fa-IR': `${siteUrl}/`,
'x-default': `${siteUrl}/`,
},
},
formatDetection: {
email: false,
@@ -148,7 +152,12 @@ export default async function RootLayout({
},
};
const safeJsonLd = JSON.stringify([orgSchema, webSiteSchema]).replace(/</g, '\\u003c');
const rootSchemaGraph = {
'@context': 'https://schema.org',
'@graph': [orgSchema, webSiteSchema],
};
const safeJsonLd = JSON.stringify(rootSchemaGraph).replace(/</g, '\\u003c');
const gaId = config.googleAnalyticsId?.trim();
const isGaEnabled = Boolean(gaId && config.enableGoogleAnalytics !== false);
@@ -1,3 +1,4 @@
import { notFound } from 'next/navigation';
import ProductPage from "../../../components/ProductPage";
import { productService } from "../../../lib/services/productService";
import type { Metadata } from 'next';
@@ -133,7 +134,7 @@ export default async function ShopProductPage({ params }: { params: Promise<{ sl
const product = await productService.getProductBySlug(resolvedParams.slug);
if (!product) {
return <ProductPage productSlug={resolvedParams.slug} initialProduct={product} />;
notFound();
}
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://canina.ir';
@@ -1,3 +1,4 @@
import { notFound } from 'next/navigation';
import Link from 'next/link';
import { ChevronRight, Sparkles, Package, ArrowLeft, ShieldCheck } from 'lucide-react';
import type { Metadata } from 'next';
@@ -81,15 +82,7 @@ export default async function WikiTermPage({ params }: { params: Promise<{ slug:
const term = await getWikiTerm(slug);
if (!term) {
return (
<div className="min-h-[50vh] flex flex-col items-center justify-center font-vazir text-center px-4" dir="rtl">
<h1 className="text-3xl font-black text-medical-gray-900 mb-4">ترکیب علمی یافت نشد</h1>
<Link href="/wiki" className="text-canina-blue font-bold flex items-center gap-2">
<ChevronRight className="w-4 h-4" />
بازگشت به دانشنامه
</Link>
</div>
);
notFound();
}
const relatedProducts = await getRelatedProducts(term.term);