Skip to content

Commit 136d4d1

Browse files
committed
fix dic metadata articles
1 parent 8440956 commit 136d4d1

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/app/[lang]/articles/categories/[category]/[slug]/components/AuthorSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default function ArticleMeta({
4848
<div className="flex items-center gap-2 text-sm text-gray-600">
4949
<div>
5050
<Image
51-
src={author.avatar || "/articles/author/fallback-avatar.jpg"}
51+
src={author.avatar || "/clogo.png"}
5252
alt={author.name}
5353
width={60}
5454
height={60}

src/app/[lang]/articles/categories/[category]/[slug]/page.jsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,17 @@ import AuthorCard from "./components/AuthorCard";
2222
import ShowSocialWrapper from "./components/ShowSocialWrapper";
2323

2424

25+
26+
2527
// ======================================
2628
// ✅ Metadata از Supabase
2729
// ======================================
2830
export async function generateMetadata({ params }) {
31+
function cleanDescription(html, limit = 255) {
32+
if (!html) return "";
33+
const text = html.replace(/<[^>]*>/g, "").trim(); // حذف HTML
34+
return text.length > limit ? text.slice(0, limit).trim() + "…" : text;
35+
}
2936
const { slug } = params;
3037

3138
const { data: article } = await supabase
@@ -38,11 +45,11 @@ export async function generateMetadata({ params }) {
3845

3946
return {
4047
title: article.title,
41-
description: article.excerpt || article.description || "",
48+
description: cleanDescription(article.description || "مقالات متاورس رنگ"),
4249
authors: [{ name: article.author?.name }],
4350
openGraph: {
4451
title: article.title,
45-
description: article.excerpt || article.description || "",
52+
description: cleanDescription(article.description || "مقالات متاورس رنگ"),
4653
images: article.image ? [{ url: article.image }] : [],
4754
url: `https://rgb.irpsc.com/${params.lang}/articles/categories/${decodeURIComponent(
4855
params.category
@@ -52,7 +59,7 @@ export async function generateMetadata({ params }) {
5259
twitter: {
5360
card: "summary_large_image",
5461
title: article.title,
55-
description: article.excerpt || article.description || "",
62+
description:cleanDescription(article.description || "مقالات متاورس رنگ"),
5663
images: article.image ? [article.image] : [],
5764
},
5865
};
@@ -63,6 +70,11 @@ export async function generateMetadata({ params }) {
6370
// ✅ صفحه مقاله
6471
// ======================================
6572
export default async function ArticlePage({ params }) {
73+
function cleanDescription(html, limit = 100) {
74+
if (!html) return "";
75+
const text = html.replace(/<[^>]*>/g, "").trim(); // حذف HTML
76+
return text.length > limit ? text.slice(0, limit).trim() + "…" : text;
77+
}
6678
try {
6779
const { slug , category } = params;
6880

@@ -108,7 +120,7 @@ export default async function ArticlePage({ params }) {
108120
"@context": "https://schema.org",
109121
"@type": "Article",
110122
headline: article.title,
111-
description: article.excerpt || article.description || "",
123+
description:cleanDescription( article.description || "مقالات متاورس رنگ"),
112124
image: article.image ? [article.image] : undefined,
113125
author: {
114126
"@type": "Person",

0 commit comments

Comments
 (0)