Add utility function to truncate long strings

This commit is contained in:
D. Berge
2023-11-08 18:06:20 +01:00
parent b3dbc0f417
commit 436a9b8289

View File

@@ -0,0 +1,10 @@
function truncateText (text, length=20) {
if (text?.length <= length) {
return text;
} else {
return text.slice(0, length/2)+"…"+text.slice(-(length/2));
}
}
export default truncateText;