ads + blog + ...

This commit is contained in:
hamid zarghami
2025-04-19 15:35:22 +03:30
parent cdc611a65d
commit 1bf0b56a63
20 changed files with 236 additions and 73 deletions
+11
View File
@@ -96,3 +96,14 @@ export function toJalaliDate(
return formatter.format(parsedDate);
}
export function limitHtmlWords(htmlString: string, wordLimit: number): string {
// پاک کردن تگ‌ها
const plainText = htmlString.replace(/<[^>]*>/g, "");
// تقسیم و محدود کردن کلمات
const words = plainText.split(/\s+/).slice(0, wordLimit);
const result = words.join(" ") + "...";
return result;
}