Hey kirkins,
as lodash
is already included in the project you could simply change the following line:
const desc = `${bodyText.substring(0, 140)} by ${author}`;
to:
const desc = `${_.truncate(bodyText, { length: 140 })} by ${author}`;
This would produce a string with ...
at the end automatically, if you want to have 140 characters and then the dots, use { length: 143 }
, otherwise it will to 137 characters and then the dots to be 140 characters in total.
And of course you first need to import it like: import _ from 'lodash'
.
You can find the documentation here: https://lodash.com/docs/4.17.5#truncate
Best
Thanks, going to give it a try.
Great. You can give me a reply if it worked.
Anyway your implementation would work as well, but why reinventing the wheel? :P
I was thinking what I had should work. Either way I made a new PR based on your suggestion, thanks!
https://github.com/busyorg/busy/pull/1686
This time the build is passing. Thanks for mention me there! It looks like you need to rebase against latest
master
branch.