@@ -22,10 +22,17 @@ import AuthorCard from "./components/AuthorCard";
2222import ShowSocialWrapper from "./components/ShowSocialWrapper" ;
2323
2424
25+
26+
2527// ======================================
2628// ✅ Metadata از Supabase
2729// ======================================
2830export 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// ======================================
6572export 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