mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-06-01 22:50:26 -04:00
10 lines
388 B
TypeScript
10 lines
388 B
TypeScript
/**
|
|
* Truncates plain text to `length` characters, appending `clamp` when truncated.
|
|
*
|
|
* The input is treated strictly as text and is never parsed as HTML, so markup in the input is
|
|
* returned verbatim rather than interpreted.
|
|
*/
|
|
export function truncateText(text: string, length = 20, clamp = "..."): string {
|
|
return text.length > length ? text.slice(0, length) + clamp : text;
|
|
}
|