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

5 lines
181 B
TypeScript
Raw Normal View History

export const truncateString = (str: string, maxLength: number) => {
str = str.replace(/<[^>]*>/g, "");
return str.length > maxLength ? `${str.slice(0, maxLength)}...` : str;
};