ads + blog + ...
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user