Files
my-website-v2/frontend/lib/truncate.ts
T

4 lines
181 B
TypeScript
Raw Normal View History

2024-11-27 00:35:32 -05:00
export const truncateString = (str: string, maxLength: number) => {
2025-07-07 21:05:27 -04:00
str = str.replace(/<[^>]*>/g, "");
2024-11-27 00:35:32 -05:00
return str.length > maxLength ? `${str.slice(0, maxLength)}...` : str;
};