mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-14 09:26:49 +02:00
First public commit
This commit is contained in:
commit
e05cd62e53
228 changed files with 17717 additions and 0 deletions
8
utils/prevent-widows.ts
Normal file
8
utils/prevent-widows.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
export const preventWidows = (text: string) => {
|
||||
// This only really makes sense if we have at least 3 words
|
||||
if (text.split(" ").length < 3) {
|
||||
return text;
|
||||
}
|
||||
const index = text.lastIndexOf(" ");
|
||||
return [text.substring(0, index), text.substring(index + 1)].join("\u00a0");
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue