-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add short widow avoidance in comment text
- Loading branch information
Showing
2 changed files
with
10 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export function avoidShortWidows(text: string) { | ||
const words = text.split(' '); | ||
|
||
const lastWord = words.pop(); | ||
if (!lastWord) return text; | ||
|
||
return words.join(' ') + (words.length > 2 && lastWord.length <= 10 ? ' ' : ' ') + lastWord; | ||
} |
63f2198
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for hackernews-dot-cool ready!
✅ Preview
https://hackernews-dot-cool-owhnhi2w4-jonamil-56ba8df7.vercel.app
Built with commit 63f2198.
This pull request is being automatically deployed with vercel-action