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

4 lines
144 B
TypeScript

export const truncateString = (str: string, maxLength: number) => {
return str.length > maxLength ? `${str.slice(0, maxLength)}...` : str;
};